From 9f3b62d38ae5c2e7cb1938a3c8c3cdb5b86b29b6 Mon Sep 17 00:00:00 2001 From: chrisdengso <8185683+chrisdengso@users.noreply.github.com> Date: Wed, 28 Oct 2026 13:40:37 +0000 Subject: [PATCH] feat: v5.3.0, API changes --- .speakeasy/gen.lock | 168 ++++- .speakeasy/gen.yaml | 2 +- .speakeasy/openapi.json | 674 ++++++++++++++++++ CHANGELOG.md | 14 + README.md | 18 +- .../operations/allow-content-request-body.md | 18 + .../operations/allow-content-request.md | 20 + .../operations/allow-content-response.md | 19 + .../operations/block-author-request-body.md | 15 + .../models/operations/block-author-request.md | 20 + .../operations/block-author-response.md | 19 + .../operations/execute-action-request-body.md | 18 +- .../operations/reject-content-request-body.md | 18 + .../operations/reject-content-request.md | 20 + .../operations/reject-content-response.md | 19 + .../operations/suspend-author-request-body.md | 16 + .../operations/suspend-author-request.md | 20 + .../operations/suspend-author-response.md | 19 + .../operations/unblock-author-request-body.md | 15 + .../operations/unblock-author-request.md | 20 + .../operations/unblock-author-response.md | 19 + docs/sdks/authors/README.md | 234 ++++++ docs/sdks/content/README.md | 156 ++++ jsr.json | 2 +- package.json | 2 +- src/funcs/authors-block.ts | 206 ++++++ src/funcs/authors-suspend.ts | 206 ++++++ src/funcs/authors-unblock.ts | 206 ++++++ src/funcs/content-allow.ts | 206 ++++++ src/funcs/content-reject.ts | 206 ++++++ src/lib/config.ts | 4 +- src/models/operations/allow-content.ts | 120 ++++ src/models/operations/block-author.ts | 102 +++ src/models/operations/execute-action.ts | 12 + src/models/operations/index.ts | 5 + src/models/operations/reject-content.ts | 120 ++++ src/models/operations/suspend-author.ts | 108 +++ src/models/operations/unblock-author.ts | 102 +++ src/sdk/authors.ts | 66 ++ src/sdk/content.ts | 44 ++ src/sdk/sdk.ts | 10 +- 41 files changed, 3252 insertions(+), 36 deletions(-) create mode 100644 docs/models/operations/allow-content-request-body.md create mode 100644 docs/models/operations/allow-content-request.md create mode 100644 docs/models/operations/allow-content-response.md create mode 100644 docs/models/operations/block-author-request-body.md create mode 100644 docs/models/operations/block-author-request.md create mode 100644 docs/models/operations/block-author-response.md create mode 100644 docs/models/operations/reject-content-request-body.md create mode 100644 docs/models/operations/reject-content-request.md create mode 100644 docs/models/operations/reject-content-response.md create mode 100644 docs/models/operations/suspend-author-request-body.md create mode 100644 docs/models/operations/suspend-author-request.md create mode 100644 docs/models/operations/suspend-author-response.md create mode 100644 docs/models/operations/unblock-author-request-body.md create mode 100644 docs/models/operations/unblock-author-request.md create mode 100644 docs/models/operations/unblock-author-response.md create mode 100644 src/funcs/authors-block.ts create mode 100644 src/funcs/authors-suspend.ts create mode 100644 src/funcs/authors-unblock.ts create mode 100644 src/funcs/content-allow.ts create mode 100644 src/funcs/content-reject.ts create mode 100644 src/models/operations/allow-content.ts create mode 100644 src/models/operations/block-author.ts create mode 100644 src/models/operations/reject-content.ts create mode 100644 src/models/operations/suspend-author.ts create mode 100644 src/models/operations/unblock-author.ts diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 1a3d5e3..49cb0eb 100644 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,12 +1,12 @@ lockVersion: 2.0.0 id: 2331670b-5789-4489-85ed-fb316d2d6d7e management: - docChecksum: ed2fd953cba3e99fb81365252925a0d4 + docChecksum: d6bce8a263f0ec11d54bdf026957ba2f docVersion: 1.1.0 speakeasyVersion: internal generationVersion: internal - releaseVersion: 5.2.0 - configChecksum: 4dbda5aa25bde9974dca06741a29c5d2 + releaseVersion: 5.3.0 + configChecksum: 4db92c10204c0001d42fcc5e63b9d1e6 repoURL: https://github.com/moderation-api/sdk-typescript installationURL: https://github.com/moderation-api/sdk-typescript published: true @@ -105,6 +105,12 @@ trackedFiles: last_write_checksum: sha1:4e214f5df85ac11c27e3f396de9840e361f0da30 docs/models/operations/alcohol.md: last_write_checksum: sha1:474037fa5ff911f6dab84fcc9c86f7143538b07e + docs/models/operations/allow-content-request-body.md: + last_write_checksum: sha1:d2401eef9207bad17b83155f389b4b4eb4426f4e + docs/models/operations/allow-content-request.md: + last_write_checksum: sha1:bb159c883c82bad4477cab07ce6a4ec5660c14f2 + docs/models/operations/allow-content-response.md: + last_write_checksum: sha1:f5a5f4e550e8897ca2b23b5c6b4f87f6436d8bd7 docs/models/operations/audio-request.md: last_write_checksum: sha1:d87d21d3c592300cd1bc050bbb037ef01232e784 docs/models/operations/audio-response.md: @@ -113,6 +119,12 @@ trackedFiles: last_write_checksum: sha1:a240bc22dc6e64b409101f9393d9c8f06b2bb590 docs/models/operations/behavior.md: last_write_checksum: sha1:2dc87fd2bca28e87b5e9e1b59dbdfea803edf944 + docs/models/operations/block-author-request-body.md: + last_write_checksum: sha1:74c25a87782c951e6a06052b9e7648b42317d842 + docs/models/operations/block-author-request.md: + last_write_checksum: sha1:8f33a03684c59c0f143921cf221f232cf5259d0e + docs/models/operations/block-author-response.md: + last_write_checksum: sha1:b5a23a3f3eefa631fc33c73df6a95bab386c2e94 docs/models/operations/block.md: last_write_checksum: sha1:65a37cde96d35aa3e9ef59e2c38fa72ae0868bcf docs/models/operations/brand-impersonation.md: @@ -268,7 +280,7 @@ trackedFiles: docs/models/operations/evaluation.md: last_write_checksum: sha1:aee5c69f547a5f5b2b338f973a425e3cce1d7ed5 docs/models/operations/execute-action-request-body.md: - last_write_checksum: sha1:9d7b79817b40f70a62dc09087042d390e14101b3 + last_write_checksum: sha1:f0a1da7c4a8f3a25377b263ba751e89964603c4e docs/models/operations/execute-action-request.md: last_write_checksum: sha1:bb82c15d20dffdd3ae7206224f27dcc8cc8a42d5 docs/models/operations/execute-action-response.md: @@ -521,6 +533,12 @@ trackedFiles: last_write_checksum: sha1:26f74f9e85d3a097658fdbae0ec2f0766be3797d docs/models/operations/recommendation.md: last_write_checksum: sha1:159ef93a181cd94d8a58009f6639d903be5b55b4 + docs/models/operations/reject-content-request-body.md: + last_write_checksum: sha1:cb328f2331de1673b5fb0a5fdbec630e9576c769 + docs/models/operations/reject-content-request.md: + last_write_checksum: sha1:859d514de541d3ffe2171206ce87caaad2b4a2b9 + docs/models/operations/reject-content-response.md: + last_write_checksum: sha1:f7a1c6d6919c0eed70429c02038616e5f213a469 docs/models/operations/religion.md: last_write_checksum: sha1:ebb4d54c6e5080e8cc95379858faba8ad981c8d0 docs/models/operations/remove-wordlist-words-request.md: @@ -581,6 +599,12 @@ trackedFiles: last_write_checksum: sha1:618ad532892eacee33fb6764913f6108b5130d98 docs/models/operations/submit-content-response.md: last_write_checksum: sha1:6b2df2610c83c88c210b2c5eae5a777a72669787 + docs/models/operations/suspend-author-request-body.md: + last_write_checksum: sha1:7105a3c4ef724b9e99caeabe7f635009dfdf6985 + docs/models/operations/suspend-author-request.md: + last_write_checksum: sha1:443cfd6c4bb09a294f4d3d609980caa079e7612a + docs/models/operations/suspend-author-response.md: + last_write_checksum: sha1:297e20ac6f1fd9fef1c7d9d21df818613ce87aa1 docs/models/operations/text-request.md: last_write_checksum: sha1:6737b0c0a8d8692dde7211d87fe89238aef52e94 docs/models/operations/text-response.md: @@ -603,6 +627,12 @@ trackedFiles: last_write_checksum: sha1:5e0c833fe16e96ce671fa036f19a7ccb0a22b13f docs/models/operations/trust-level.md: last_write_checksum: sha1:78da4e58c4a4fd23904f507ab74a713dcd2172c5 + docs/models/operations/unblock-author-request-body.md: + last_write_checksum: sha1:cb2529b0568f3ce2ddd1a9791fa53d9274b4c6a5 + docs/models/operations/unblock-author-request.md: + last_write_checksum: sha1:c93d7e2bde27f41d5d146844d69359059bf90384 + docs/models/operations/unblock-author-response.md: + last_write_checksum: sha1:d2815f1bfccd8b2a758bd6a6283f19b9a9405ac7 docs/models/operations/unicode-spoofing.md: last_write_checksum: sha1:46001ecb3e3d7cceb9d0bda3687ce1cf001ab296 docs/models/operations/unresolve-queue-item-request.md: @@ -760,11 +790,11 @@ trackedFiles: docs/sdks/apikeys/README.md: last_write_checksum: sha1:a092ea30162aba4182557f85a1332122c79cfaac docs/sdks/authors/README.md: - last_write_checksum: sha1:075e8e8ecf7556fa7b7e0ea8d520c1afe42ed15b + last_write_checksum: sha1:85dbbcd6b538febb20f953bdb89a7deac978c9c3 docs/sdks/channels/README.md: last_write_checksum: sha1:0dc23f6f60598b2cbd22b0437e671cfda686562c docs/sdks/content/README.md: - last_write_checksum: sha1:25b36c70c1cab595dd4c193c3069001bb8bb64a6 + last_write_checksum: sha1:9e9abd673525af4df450c9b153ac89d2459bf3bd docs/sdks/feedback/README.md: last_write_checksum: sha1:209a6ea1eab58021ca88d175ca9304087eef15f8 docs/sdks/items/README.md: @@ -790,9 +820,9 @@ trackedFiles: examples/package.json: last_write_checksum: sha1:72d702bad23c84698d27164ca08d5f0ff931af65 jsr.json: - last_write_checksum: sha1:06dd576f267b7cd04041eba64710d91e07f1b7e9 + last_write_checksum: sha1:c08dd2de7d37fbb01aaa3255378f71d68683a9eb package.json: - last_write_checksum: sha1:e317ca7d796fde818116327831b8246a129b5d41 + last_write_checksum: sha1:027f40f096049bc8c4c80810d48c67e1a7c99382 src/core.ts: last_write_checksum: sha1:72b4c09e9228c63a9cc3335baa0ae5be47c2bc9c src/funcs/account-retrieve.ts: @@ -821,6 +851,8 @@ trackedFiles: last_write_checksum: sha1:6081e08cbc3a84abf954c50274b2d0eb0828c309 src/funcs/analytics-volumes.ts: last_write_checksum: sha1:ba7c046dcc29244ee55f2b6713992d0b4d5fd1b6 + src/funcs/authors-block.ts: + last_write_checksum: sha1:35adf87945cdf22ea0df581fd41fac98d5e36626 src/funcs/authors-create.ts: last_write_checksum: sha1:926d3251f649dc8e8a301acbed96427e712db3b1 src/funcs/authors-delete.ts: @@ -829,6 +861,10 @@ trackedFiles: last_write_checksum: sha1:ecb7897c309109435e738f06f399021f80cb9e37 src/funcs/authors-retrieve.ts: last_write_checksum: sha1:2b7dab0749ee6eeb86204e14bd794dbac65b9ace + src/funcs/authors-suspend.ts: + last_write_checksum: sha1:6480ebe48ee6573fb0bcacdf9a3fe8b0b31426f4 + src/funcs/authors-unblock.ts: + last_write_checksum: sha1:eae4d69313f05d4fdca5ef1d52076355d76e187b src/funcs/authors-update.ts: last_write_checksum: sha1:61397530220919796adea8763dce45a8fbc0d858 src/funcs/channels-create.ts: @@ -843,6 +879,10 @@ trackedFiles: last_write_checksum: sha1:0b47cbf8c128ff86ff6a8264321c08ea3b07702f src/funcs/channels-update.ts: last_write_checksum: sha1:d28482419848661dc8a626a089112e73d1f8134e + src/funcs/content-allow.ts: + last_write_checksum: sha1:8158f0282832bd7d3534f956d0ac80d37fa8dfc9 + src/funcs/content-reject.ts: + last_write_checksum: sha1:197ff4634c40bab554454b386f29383ff04a1123 src/funcs/content-submit.ts: last_write_checksum: sha1:fdca5b9045341128939058fb21071d48d2c01eb0 src/funcs/feedback-create.ts: @@ -912,7 +952,7 @@ trackedFiles: src/lib/base64.ts: last_write_checksum: sha1:8c94164f2f78e6041c853186fa01f659591f5913 src/lib/config.ts: - last_write_checksum: sha1:bf890a8476bcdeee22e18f4a132009d36534a226 + last_write_checksum: sha1:09f9426a004967ef918057af692641868b6659e4 src/lib/encodings.ts: last_write_checksum: sha1:4481b2a380f8a16856ef92c66fb370299f56d135 src/lib/env.ts: @@ -981,6 +1021,10 @@ trackedFiles: last_write_checksum: sha1:3f2385a6f32bdc7a3a40e711cc2103f20929179c src/models/operations/add-wordlist-words.ts: last_write_checksum: sha1:bca0ce826472d0d4ff7e3bc8034cafc93513c652 + src/models/operations/allow-content.ts: + last_write_checksum: sha1:4ff7b550412eef6a42cb76a3300bfcd0bd92340a + src/models/operations/block-author.ts: + last_write_checksum: sha1:46e9cfc274e6b5734a4d2de975815300e51d8d47 src/models/operations/create-action.ts: last_write_checksum: sha1:465b5a649cce0ae44431b729dad38b70d2e70196 src/models/operations/create-author.ts: @@ -1012,7 +1056,7 @@ trackedFiles: src/models/operations/duplicate-project.ts: last_write_checksum: sha1:111826d4d5e53c6622cce8be741c81b39b13d1d7 src/models/operations/execute-action.ts: - last_write_checksum: sha1:6cb2505aa4ddd4d5f9b439189f95fd024525c099 + last_write_checksum: sha1:3b733d87712ca55eef5f2b47849afa03e4d2d205 src/models/operations/get-account.ts: last_write_checksum: sha1:45071f887a86c43c4cf29f07ca70be8261aae3e2 src/models/operations/get-action.ts: @@ -1048,7 +1092,7 @@ trackedFiles: src/models/operations/get-wordlist.ts: last_write_checksum: sha1:0cfd3f20b74b9dafa1c2ab8159bf165bc99ae830 src/models/operations/index.ts: - last_write_checksum: sha1:af2ba2596503a29cb1551928ad84be82ccb6a1f0 + last_write_checksum: sha1:b31c360b2106982c2875c35819b79fcc74663973 src/models/operations/list-actions.ts: last_write_checksum: sha1:2d872ead1fa82d0e580eae92cfcb6593b71972cb src/models/operations/list-authors.ts: @@ -1065,6 +1109,8 @@ trackedFiles: last_write_checksum: sha1:f7571c32c6ed72a21fa4d2f9408daf4c614e99d0 src/models/operations/list-wordlists.ts: last_write_checksum: sha1:9ac9dc22488a6c34c99dcf4180b08406986c8152 + src/models/operations/reject-content.ts: + last_write_checksum: sha1:3fe59efd6ba71b014a1b8cdec8b626ca0f6bb8dd src/models/operations/remove-wordlist-words.ts: last_write_checksum: sha1:494ac821a6346f6b08e16b57b95b895300c887a1 src/models/operations/resolve-queue-item.ts: @@ -1073,6 +1119,10 @@ trackedFiles: last_write_checksum: sha1:36c6625998810befaf0dc01f6b0f9bd080376beb src/models/operations/submit-content.ts: last_write_checksum: sha1:74f926880df58f87473373c25f10f31bf052272d + src/models/operations/suspend-author.ts: + last_write_checksum: sha1:05f2fdd6cb81b91ce569a898714d00e9809f69bd + src/models/operations/unblock-author.ts: + last_write_checksum: sha1:38abae3ee704f300d903f44301fc64b576e81600 src/models/operations/unresolve-queue-item.ts: last_write_checksum: sha1:1a8c9d9bed905a703b8ac81a2d486a70ee014760 src/models/operations/update-action.ts: @@ -1118,11 +1168,11 @@ trackedFiles: src/sdk/api-keys.ts: last_write_checksum: sha1:ce7ee16b0359bab65b9715e0abf84e6a8fff7eb2 src/sdk/authors.ts: - last_write_checksum: sha1:8b8e4087f217fa252dedd2c724f4082d9a54b308 + last_write_checksum: sha1:65aaa93b03023aeae6496bb02b26e6ee6e87def6 src/sdk/channels.ts: last_write_checksum: sha1:30ea1fc231cc208918a776570e51d37b21969e01 src/sdk/content.ts: - last_write_checksum: sha1:7a941de88ba8482161ee358018d683b4e8cac9fd + last_write_checksum: sha1:b1b8b75e2c99656eb9606d0204d0bddc468e6b27 src/sdk/feedback.ts: last_write_checksum: sha1:cfc19d13959b3e43a97772382809ee2561187d96 src/sdk/index.ts: @@ -1134,7 +1184,7 @@ trackedFiles: src/sdk/queue.ts: last_write_checksum: sha1:6a346243301e89e4f43fa50344325a81b325eafc src/sdk/sdk.ts: - last_write_checksum: sha1:510b6ee3687be90e994b5bb85751eb5073cbeb45 + last_write_checksum: sha1:7845491693dcc9c1b082b292e211e96588980e0b src/sdk/webhook-secret.ts: last_write_checksum: sha1:47978211eeb6939caf86d3c42fb241a6c0501f09 src/sdk/webhooks.ts: @@ -2132,4 +2182,94 @@ examples: application/json: {"type": "not_found_error", "code": "resource_not_found", "message": "Not found", "request_id": "h8fkz6kkzoa446ffve37atys", "doc_url": "https://impractical-bin.info/"} "429": application/json: {"type": "rate_limit_error", "code": "rate_limit_exceeded", "message": "Rate limit exceeded", "request_id": "h8fkz6kkzoa446ffve37atys", "doc_url": "https://damaged-bandwidth.name"} + blockAuthor: + speakeasy-default-block-author: + parameters: + path: + id: "" + requestBody: + application/json: {} + responses: + "200": + application/json: {"success": false} + "400": + application/json: {"type": "invalid_request_error", "code": "invalid_request", "message": "Invalid input data", "request_id": "h8fkz6kkzoa446ffve37atys", "doc_url": "https://mammoth-appliance.org/"} + "401": + application/json: {"type": "authentication_error", "code": "unauthorized", "message": "Authorization not provided", "request_id": "h8fkz6kkzoa446ffve37atys", "doc_url": "https://clumsy-ectoderm.com/"} + "404": + application/json: {"type": "not_found_error", "code": "resource_not_found", "message": "Not found", "request_id": "h8fkz6kkzoa446ffve37atys", "doc_url": "https://square-custody.com"} + "429": + application/json: {"type": "rate_limit_error", "code": "rate_limit_exceeded", "message": "Rate limit exceeded", "request_id": "h8fkz6kkzoa446ffve37atys", "doc_url": "https://mysterious-dime.name/"} + suspendAuthor: + speakeasy-default-suspend-author: + parameters: + path: + id: "" + requestBody: + application/json: {} + responses: + "200": + application/json: {"success": true} + "400": + application/json: {"type": "invalid_request_error", "code": "invalid_request", "message": "Invalid input data", "request_id": "h8fkz6kkzoa446ffve37atys", "doc_url": "https://cluttered-hubris.name/"} + "401": + application/json: {"type": "authentication_error", "code": "unauthorized", "message": "Authorization not provided", "request_id": "h8fkz6kkzoa446ffve37atys", "doc_url": "https://far-off-farm.net/"} + "404": + application/json: {"type": "not_found_error", "code": "resource_not_found", "message": "Not found", "request_id": "h8fkz6kkzoa446ffve37atys", "doc_url": "https://scented-farmer.info"} + "429": + application/json: {"type": "rate_limit_error", "code": "rate_limit_exceeded", "message": "Rate limit exceeded", "request_id": "h8fkz6kkzoa446ffve37atys", "doc_url": "https://miserly-cuckoo.org/"} + unblockAuthor: + speakeasy-default-unblock-author: + parameters: + path: + id: "" + requestBody: + application/json: {} + responses: + "200": + application/json: {"success": false} + "400": + application/json: {"type": "invalid_request_error", "code": "invalid_request", "message": "Invalid input data", "request_id": "h8fkz6kkzoa446ffve37atys", "doc_url": "https://utter-cornet.org"} + "401": + application/json: {"type": "authentication_error", "code": "unauthorized", "message": "Authorization not provided", "request_id": "h8fkz6kkzoa446ffve37atys", "doc_url": "https://oddball-bathhouse.biz/"} + "404": + application/json: {"type": "not_found_error", "code": "resource_not_found", "message": "Not found", "request_id": "h8fkz6kkzoa446ffve37atys", "doc_url": "https://apprehensive-fisherman.info/"} + "429": + application/json: {"type": "rate_limit_error", "code": "rate_limit_exceeded", "message": "Rate limit exceeded", "request_id": "h8fkz6kkzoa446ffve37atys", "doc_url": "https://unhappy-simple.net/"} + rejectContent: + speakeasy-default-reject-content: + parameters: + path: + id: "" + requestBody: + application/json: {} + responses: + "200": + application/json: {"success": true} + "400": + application/json: {"type": "invalid_request_error", "code": "invalid_request", "message": "Invalid input data", "request_id": "h8fkz6kkzoa446ffve37atys", "doc_url": "https://expert-pasta.com"} + "401": + application/json: {"type": "authentication_error", "code": "unauthorized", "message": "Authorization not provided", "request_id": "h8fkz6kkzoa446ffve37atys", "doc_url": "https://vibrant-adaptation.name"} + "404": + application/json: {"type": "not_found_error", "code": "resource_not_found", "message": "Not found", "request_id": "h8fkz6kkzoa446ffve37atys", "doc_url": "https://boiling-gym.com/"} + "429": + application/json: {"type": "rate_limit_error", "code": "rate_limit_exceeded", "message": "Rate limit exceeded", "request_id": "h8fkz6kkzoa446ffve37atys", "doc_url": "https://spanish-backburn.net"} + allowContent: + speakeasy-default-allow-content: + parameters: + path: + id: "" + requestBody: + application/json: {} + responses: + "200": + application/json: {"success": true} + "400": + application/json: {"type": "invalid_request_error", "code": "invalid_request", "message": "Invalid input data", "request_id": "h8fkz6kkzoa446ffve37atys", "doc_url": "https://earnest-fishery.com"} + "401": + application/json: {"type": "authentication_error", "code": "unauthorized", "message": "Authorization not provided", "request_id": "h8fkz6kkzoa446ffve37atys", "doc_url": "https://meager-climb.biz/"} + "404": + application/json: {"type": "not_found_error", "code": "resource_not_found", "message": "Not found", "request_id": "h8fkz6kkzoa446ffve37atys", "doc_url": "https://confused-bell.org"} + "429": + application/json: {"type": "rate_limit_error", "code": "rate_limit_exceeded", "message": "Rate limit exceeded", "request_id": "h8fkz6kkzoa446ffve37atys", "doc_url": "https://nervous-partridge.org/"} examplesVersion: 1.0.2 diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index aee97b4..e2b89ef 100644 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -32,7 +32,7 @@ generation: generateNewTests: true skipResponseBodyAssertions: false typescript: - version: 5.2.0 + version: 5.3.0 acceptHeaderEnum: false additionalDependencies: dependencies: {} diff --git a/.speakeasy/openapi.json b/.speakeasy/openapi.json index cabb255..9a2cf7e 100644 --- a/.speakeasy/openapi.json +++ b/.speakeasy/openapi.json @@ -5103,6 +5103,14 @@ "description": "Optional duration in milliseconds for actions with timeouts", "type": "number", "minimum": 0 + }, + "moderator": { + "description": "The user ID or email of the organization member who made the decision. The action is recorded as theirs.", + "type": "string" + }, + "createCasebookCase": { + "description": "Record an allow or reject decision as a casebook case. Defaults to true when `moderator` is set, else false. Without `moderator`, the case is recorded as System.", + "type": "boolean" } }, "required": [ @@ -5342,6 +5350,672 @@ "x-speakeasy-ignore": true } }, + "/content/{id}/reject": { + "post": { + "operationId": "rejectContent", + "summary": "Reject content", + "description": "Reject a content item with the built-in reject action, and resolve it in the review queue.", + "tags": [ + "Content" + ], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "in": "path", + "name": "id", + "schema": { + "type": "string", + "description": "The content ID you sent when you submitted the content, or the ID Moderation API assigned." + }, + "required": true, + "description": "The content ID you sent when you submitted the content, or the ID Moderation API assigned." + }, + { + "in": "header", + "name": "Project-Id", + "required": false, + "schema": { + "type": "string" + }, + "description": "The project to act on, by ID or name. Required with an organization key unless the key reaches only one project; list projects with GET /projects. A project key acts on its own project and needs no value: naming another one is an error.", + "x-speakeasy-name-override": "projectId" + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "reason": { + "description": "Why the action was taken. Saved with the action and sent in the webhook event.", + "type": "string" + }, + "queueId": { + "description": "The queue the content is reviewed in. Defaults to the project's default queue.", + "type": "string" + }, + "moderator": { + "description": "The user ID or email of the organization member who made the decision. The action is recorded as theirs.", + "type": "string" + }, + "createCasebookCase": { + "description": "Record an allow or reject decision as a casebook case. Defaults to true when `moderator` is set, else false. Without `moderator`, the case is recorded as System.", + "type": "boolean" + } + } + }, + "example": { + "reason": "Spam" + } + } + } + }, + "responses": { + "200": { + "description": "Action executed successfully", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "success": { + "type": "boolean", + "description": "Whether the action was executed successfully" + } + }, + "required": [ + "success" + ], + "additionalProperties": false, + "description": "Execution result" + } + } + } + }, + "400": { + "description": "Invalid input data", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/BadRequestError" + } + } + } + }, + "401": { + "description": "Authorization not provided", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AuthenticationError" + } + } + } + }, + "404": { + "description": "Not found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/NotFoundError" + } + } + } + }, + "429": { + "description": "Too many requests. Retry after the number of seconds in the `Retry-After` header.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/RateLimitError" + } + } + } + } + }, + "x-speakeasy-group": "content", + "x-speakeasy-name-override": "reject", + "x-speakeasy-mcp": { + "title": "Reject content", + "scopes": [ + "destructive" + ], + "readOnlyHint": false, + "destructiveHint": true + } + } + }, + "/content/{id}/allow": { + "post": { + "operationId": "allowContent", + "summary": "Allow content", + "description": "Allow a content item with the built-in allow action, and resolve it in the review queue.", + "tags": [ + "Content" + ], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "in": "path", + "name": "id", + "schema": { + "type": "string", + "description": "The content ID you sent when you submitted the content, or the ID Moderation API assigned." + }, + "required": true, + "description": "The content ID you sent when you submitted the content, or the ID Moderation API assigned." + }, + { + "in": "header", + "name": "Project-Id", + "required": false, + "schema": { + "type": "string" + }, + "description": "The project to act on, by ID or name. Required with an organization key unless the key reaches only one project; list projects with GET /projects. A project key acts on its own project and needs no value: naming another one is an error.", + "x-speakeasy-name-override": "projectId" + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "reason": { + "description": "Why the action was taken. Saved with the action and sent in the webhook event.", + "type": "string" + }, + "queueId": { + "description": "The queue the content is reviewed in. Defaults to the project's default queue.", + "type": "string" + }, + "moderator": { + "description": "The user ID or email of the organization member who made the decision. The action is recorded as theirs.", + "type": "string" + }, + "createCasebookCase": { + "description": "Record an allow or reject decision as a casebook case. Defaults to true when `moderator` is set, else false. Without `moderator`, the case is recorded as System.", + "type": "boolean" + } + } + } + } + } + }, + "responses": { + "200": { + "description": "Action executed successfully", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "success": { + "type": "boolean", + "description": "Whether the action was executed successfully" + } + }, + "required": [ + "success" + ], + "additionalProperties": false, + "description": "Execution result" + } + } + } + }, + "400": { + "description": "Invalid input data", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/BadRequestError" + } + } + } + }, + "401": { + "description": "Authorization not provided", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AuthenticationError" + } + } + } + }, + "404": { + "description": "Not found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/NotFoundError" + } + } + } + }, + "429": { + "description": "Too many requests. Retry after the number of seconds in the `Retry-After` header.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/RateLimitError" + } + } + } + } + }, + "x-speakeasy-group": "content", + "x-speakeasy-name-override": "allow", + "x-speakeasy-mcp": { + "title": "Allow content", + "scopes": [ + "write" + ], + "readOnlyHint": false, + "destructiveHint": false + } + } + }, + "/authors/{id}/block": { + "post": { + "operationId": "blockAuthor", + "summary": "Block author", + "description": "Block an author with the built-in block action. A blocked author cannot post new content until unblocked.", + "tags": [ + "Authors" + ], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "in": "path", + "name": "id", + "schema": { + "type": "string", + "description": "Either external ID or the ID assigned by moderation API." + }, + "required": true, + "description": "Either external ID or the ID assigned by moderation API." + }, + { + "in": "header", + "name": "Project-Id", + "required": false, + "schema": { + "type": "string" + }, + "description": "The project to act on, by ID or name. Required with an organization key unless the key reaches only one project; list projects with GET /projects. A project key acts on its own project and needs no value: naming another one is an error.", + "x-speakeasy-name-override": "projectId" + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "reason": { + "description": "Why the action was taken. Saved with the action and sent in the webhook event.", + "type": "string" + } + } + } + } + } + }, + "responses": { + "200": { + "description": "Action executed successfully", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "success": { + "type": "boolean", + "description": "Whether the action was executed successfully" + } + }, + "required": [ + "success" + ], + "additionalProperties": false, + "description": "Execution result" + } + } + } + }, + "400": { + "description": "Invalid input data", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/BadRequestError" + } + } + } + }, + "401": { + "description": "Authorization not provided", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AuthenticationError" + } + } + } + }, + "404": { + "description": "Not found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/NotFoundError" + } + } + } + }, + "429": { + "description": "Too many requests. Retry after the number of seconds in the `Retry-After` header.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/RateLimitError" + } + } + } + } + }, + "x-speakeasy-group": "authors", + "x-speakeasy-name-override": "block", + "x-speakeasy-mcp": { + "title": "Block author", + "scopes": [ + "destructive" + ], + "readOnlyHint": false, + "destructiveHint": true + } + } + }, + "/authors/{id}/suspend": { + "post": { + "operationId": "suspendAuthor", + "summary": "Suspend author", + "description": "Block an author for a limited time with the built-in suspend action.", + "tags": [ + "Authors" + ], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "in": "path", + "name": "id", + "schema": { + "type": "string", + "description": "Either external ID or the ID assigned by moderation API." + }, + "required": true, + "description": "Either external ID or the ID assigned by moderation API." + }, + { + "in": "header", + "name": "Project-Id", + "required": false, + "schema": { + "type": "string" + }, + "description": "The project to act on, by ID or name. Required with an organization key unless the key reaches only one project; list projects with GET /projects. A project key acts on its own project and needs no value: naming another one is an error.", + "x-speakeasy-name-override": "projectId" + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "reason": { + "description": "Why the action was taken. Saved with the action and sent in the webhook event.", + "type": "string" + }, + "duration": { + "description": "How long the suspension lasts, in milliseconds. Defaults to 24 hours.", + "type": "number", + "minimum": 0 + } + } + }, + "example": { + "reason": "Violation of community guidelines", + "duration": 604800000 + } + } + } + }, + "responses": { + "200": { + "description": "Action executed successfully", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "success": { + "type": "boolean", + "description": "Whether the action was executed successfully" + } + }, + "required": [ + "success" + ], + "additionalProperties": false, + "description": "Execution result" + } + } + } + }, + "400": { + "description": "Invalid input data", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/BadRequestError" + } + } + } + }, + "401": { + "description": "Authorization not provided", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AuthenticationError" + } + } + } + }, + "404": { + "description": "Not found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/NotFoundError" + } + } + } + }, + "429": { + "description": "Too many requests. Retry after the number of seconds in the `Retry-After` header.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/RateLimitError" + } + } + } + } + }, + "x-speakeasy-group": "authors", + "x-speakeasy-name-override": "suspend", + "x-speakeasy-mcp": { + "title": "Suspend author", + "scopes": [ + "destructive" + ], + "readOnlyHint": false, + "destructiveHint": true + } + } + }, + "/authors/{id}/unblock": { + "post": { + "operationId": "unblockAuthor", + "summary": "Unblock author", + "description": "Unblock a blocked or suspended author with the built-in unblock action, so they can post new content again.", + "tags": [ + "Authors" + ], + "security": [ + { + "Authorization": [] + } + ], + "parameters": [ + { + "in": "path", + "name": "id", + "schema": { + "type": "string", + "description": "Either external ID or the ID assigned by moderation API." + }, + "required": true, + "description": "Either external ID or the ID assigned by moderation API." + }, + { + "in": "header", + "name": "Project-Id", + "required": false, + "schema": { + "type": "string" + }, + "description": "The project to act on, by ID or name. Required with an organization key unless the key reaches only one project; list projects with GET /projects. A project key acts on its own project and needs no value: naming another one is an error.", + "x-speakeasy-name-override": "projectId" + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "reason": { + "description": "Why the action was taken. Saved with the action and sent in the webhook event.", + "type": "string" + } + } + } + } + } + }, + "responses": { + "200": { + "description": "Action executed successfully", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "success": { + "type": "boolean", + "description": "Whether the action was executed successfully" + } + }, + "required": [ + "success" + ], + "additionalProperties": false, + "description": "Execution result" + } + } + } + }, + "400": { + "description": "Invalid input data", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/BadRequestError" + } + } + } + }, + "401": { + "description": "Authorization not provided", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AuthenticationError" + } + } + } + }, + "404": { + "description": "Not found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/NotFoundError" + } + } + } + }, + "429": { + "description": "Too many requests. Retry after the number of seconds in the `Retry-After` header.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/RateLimitError" + } + } + } + } + }, + "x-speakeasy-group": "authors", + "x-speakeasy-name-override": "unblock", + "x-speakeasy-mcp": { + "title": "Unblock author", + "scopes": [ + "write" + ], + "readOnlyHint": false, + "destructiveHint": false + } + } + }, "/webhooks": { "get": { "operationId": "listWebhooks", diff --git a/CHANGELOG.md b/CHANGELOG.md index d55b7e5..f78e53b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +## 5.3.0 (2026-10-28) + +Full Changelog: [v5.2.0...v5.3.0](https://github.com/moderation-api/sdk-typescript/compare/v5.2.0...v5.3.0) + +### API changes + +- `POST /actions/execute`: added the new optional request property `createCasebookCase` +- `POST /actions/execute`: added the new optional request property `moderator` +- `POST /authors/{id}/block`: endpoint added +- `POST /authors/{id}/suspend`: endpoint added +- `POST /authors/{id}/unblock`: endpoint added +- `POST /content/{id}/allow`: endpoint added +- `POST /content/{id}/reject`: endpoint added + ## 5.2.0 (2026-10-26) Full Changelog: [v5.1.1...v5.2.0](https://github.com/moderation-api/sdk-typescript/compare/v5.1.1...v5.2.0) diff --git a/README.md b/README.md index 7aaf234..d6cc533 100644 --- a/README.md +++ b/README.md @@ -403,6 +403,9 @@ Create the organization client only where you manage projects and channels, for * [retrieve](docs/sdks/authors/README.md#retrieve) - Get author details * [update](docs/sdks/authors/README.md#update) - Update author details * [delete](docs/sdks/authors/README.md#delete) - Delete an author +* [block](docs/sdks/authors/README.md#block) - Block author +* [suspend](docs/sdks/authors/README.md#suspend) - Suspend author +* [unblock](docs/sdks/authors/README.md#unblock) - Unblock author ### [Channels](docs/sdks/channels/README.md) @@ -415,6 +418,8 @@ Create the organization client only where you manage projects and channels, for ### [Content](docs/sdks/content/README.md) +* [reject](docs/sdks/content/README.md#reject) - Reject content +* [allow](docs/sdks/content/README.md#allow) - Allow content * [submit](docs/sdks/content/README.md#submit) - Submit content ### [Feedback](docs/sdks/feedback/README.md) @@ -503,10 +508,13 @@ To read more about standalone functions, check [FUNCTIONS.md](./FUNCTIONS.md). - [`analyticsPolicies`](docs/sdks/analytics/README.md#policies) - Get the most flagged policies - [`analyticsSummary`](docs/sdks/analytics/README.md#summary) - Get the analytics summary - [`analyticsVolumes`](docs/sdks/analytics/README.md#volumes) - Get volumes over time +- [`authorsBlock`](docs/sdks/authors/README.md#block) - Block author - [`authorsCreate`](docs/sdks/authors/README.md#create) - Create a new author - [`authorsDelete`](docs/sdks/authors/README.md#delete) - Delete an author - [`authorsList`](docs/sdks/authors/README.md#list) - List authors - [`authorsRetrieve`](docs/sdks/authors/README.md#retrieve) - Get author details +- [`authorsSuspend`](docs/sdks/authors/README.md#suspend) - Suspend author +- [`authorsUnblock`](docs/sdks/authors/README.md#unblock) - Unblock author - [`authorsUpdate`](docs/sdks/authors/README.md#update) - Update author details - [`channelsCreate`](docs/sdks/channels/README.md#create) - Create a channel - [`channelsDelete`](docs/sdks/channels/README.md#delete) - Delete a channel @@ -514,6 +522,8 @@ To read more about standalone functions, check [FUNCTIONS.md](./FUNCTIONS.md). - [`channelsList`](docs/sdks/channels/README.md#list) - List channels - [`channelsRetrieve`](docs/sdks/channels/README.md#retrieve) - Get a channel - [`channelsUpdate`](docs/sdks/channels/README.md#update) - Update a channel +- [`contentAllow`](docs/sdks/content/README.md#allow) - Allow content +- [`contentReject`](docs/sdks/content/README.md#reject) - Reject content - [`contentSubmit`](docs/sdks/content/README.md#submit) - Submit content - [`feedbackCreate`](docs/sdks/feedback/README.md#create) - Send feedback - [`projectsApiKeysCreate`](docs/sdks/apikeys/README.md#create) - Create a project API key @@ -719,10 +729,10 @@ run(); **Inherit from [`ModerationAPIError`](./src/models/errors/moderation-api-error.ts)**: -* [`NotFoundError`](./src/models/errors/not-found-error.ts): The resource does not exist or the key cannot see it. Status code `404`. Applicable to 39 of 53 methods.* -* [`PermissionDeniedError`](./src/models/errors/permission-denied-error.ts): The API key cannot do this, or the plan limit for this resource is reached. Status code `403`. Applicable to 36 of 53 methods.* -* [`InternalServerError`](./src/models/errors/internal-server-error.ts): Something went wrong on our side. Retry with backoff. Status code `500`. Applicable to 23 of 53 methods.* -* [`ConflictError`](./src/models/errors/conflict-error.ts): The request conflicts with the current state of a resource. Status code `409`. Applicable to 2 of 53 methods.* +* [`NotFoundError`](./src/models/errors/not-found-error.ts): The resource does not exist or the key cannot see it. Status code `404`. Applicable to 44 of 58 methods.* +* [`PermissionDeniedError`](./src/models/errors/permission-denied-error.ts): The API key cannot do this, or the plan limit for this resource is reached. Status code `403`. Applicable to 36 of 58 methods.* +* [`InternalServerError`](./src/models/errors/internal-server-error.ts): Something went wrong on our side. Retry with backoff. Status code `500`. Applicable to 23 of 58 methods.* +* [`ConflictError`](./src/models/errors/conflict-error.ts): The request conflicts with the current state of a resource. Status code `409`. Applicable to 2 of 58 methods.* * [`ResponseValidationError`](./src/models/errors/response-validation-error.ts): Type mismatch between the data returned from the server and the structure expected by the SDK. See `error.rawValue` for the raw value and `error.pretty()` for a nicely formatted multi-line string. diff --git a/docs/models/operations/allow-content-request-body.md b/docs/models/operations/allow-content-request-body.md new file mode 100644 index 0000000..e453417 --- /dev/null +++ b/docs/models/operations/allow-content-request-body.md @@ -0,0 +1,18 @@ +# AllowContentRequestBody + +## Example Usage + +```typescript +import { AllowContentRequestBody } from "@moderation-api/sdk/models/operations"; + +let value: AllowContentRequestBody = {}; +``` + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `reason` | *string* | :heavy_minus_sign: | Why the action was taken. Saved with the action and sent in the webhook event. | +| `queueId` | *string* | :heavy_minus_sign: | The queue the content is reviewed in. Defaults to the project's default queue. | +| `moderator` | *string* | :heavy_minus_sign: | The user ID or email of the organization member who made the decision. The action is recorded as theirs. | +| `createCasebookCase` | *boolean* | :heavy_minus_sign: | Record an allow or reject decision as a casebook case. Defaults to true when `moderator` is set, else false. Without `moderator`, the case is recorded as System. | \ No newline at end of file diff --git a/docs/models/operations/allow-content-request.md b/docs/models/operations/allow-content-request.md new file mode 100644 index 0000000..0309c92 --- /dev/null +++ b/docs/models/operations/allow-content-request.md @@ -0,0 +1,20 @@ +# AllowContentRequest + +## Example Usage + +```typescript +import { AllowContentRequest } from "@moderation-api/sdk/models/operations"; + +let value: AllowContentRequest = { + id: "", + body: {}, +}; +``` + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `id` | *string* | :heavy_check_mark: | The content ID you sent when you submitted the content, or the ID Moderation API assigned. | +| `projectId` | *string* | :heavy_minus_sign: | The project to act on, by ID or name. Required with an organization key unless the key reaches only one project; list projects with GET /projects. A project key acts on its own project and needs no value: naming another one is an error. | +| `body` | [operations.AllowContentRequestBody](../../models/operations/allow-content-request-body.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/operations/allow-content-response.md b/docs/models/operations/allow-content-response.md new file mode 100644 index 0000000..eb26761 --- /dev/null +++ b/docs/models/operations/allow-content-response.md @@ -0,0 +1,19 @@ +# AllowContentResponse + +Execution result + +## Example Usage + +```typescript +import { AllowContentResponse } from "@moderation-api/sdk/models/operations"; + +let value: AllowContentResponse = { + success: true, +}; +``` + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------- | -------------------------------------------- | -------------------------------------------- | -------------------------------------------- | +| `success` | *boolean* | :heavy_check_mark: | Whether the action was executed successfully | \ No newline at end of file diff --git a/docs/models/operations/block-author-request-body.md b/docs/models/operations/block-author-request-body.md new file mode 100644 index 0000000..8d33cc5 --- /dev/null +++ b/docs/models/operations/block-author-request-body.md @@ -0,0 +1,15 @@ +# BlockAuthorRequestBody + +## Example Usage + +```typescript +import { BlockAuthorRequestBody } from "@moderation-api/sdk/models/operations"; + +let value: BlockAuthorRequestBody = {}; +``` + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | +| `reason` | *string* | :heavy_minus_sign: | Why the action was taken. Saved with the action and sent in the webhook event. | \ No newline at end of file diff --git a/docs/models/operations/block-author-request.md b/docs/models/operations/block-author-request.md new file mode 100644 index 0000000..cf70a37 --- /dev/null +++ b/docs/models/operations/block-author-request.md @@ -0,0 +1,20 @@ +# BlockAuthorRequest + +## Example Usage + +```typescript +import { BlockAuthorRequest } from "@moderation-api/sdk/models/operations"; + +let value: BlockAuthorRequest = { + id: "", + body: {}, +}; +``` + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `id` | *string* | :heavy_check_mark: | Either external ID or the ID assigned by moderation API. | +| `projectId` | *string* | :heavy_minus_sign: | The project to act on, by ID or name. Required with an organization key unless the key reaches only one project; list projects with GET /projects. A project key acts on its own project and needs no value: naming another one is an error. | +| `body` | [operations.BlockAuthorRequestBody](../../models/operations/block-author-request-body.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/operations/block-author-response.md b/docs/models/operations/block-author-response.md new file mode 100644 index 0000000..58a155a --- /dev/null +++ b/docs/models/operations/block-author-response.md @@ -0,0 +1,19 @@ +# BlockAuthorResponse + +Execution result + +## Example Usage + +```typescript +import { BlockAuthorResponse } from "@moderation-api/sdk/models/operations"; + +let value: BlockAuthorResponse = { + success: false, +}; +``` + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------- | -------------------------------------------- | -------------------------------------------- | -------------------------------------------- | +| `success` | *boolean* | :heavy_check_mark: | Whether the action was executed successfully | \ No newline at end of file diff --git a/docs/models/operations/execute-action-request-body.md b/docs/models/operations/execute-action-request-body.md index bfe93d8..9d2d18b 100644 --- a/docs/models/operations/execute-action-request-body.md +++ b/docs/models/operations/execute-action-request-body.md @@ -14,11 +14,13 @@ let value: ExecuteActionRequestBody = { ## Fields -| Field | Type | Required | Description | -| --------------------------------------------------------------------------- | --------------------------------------------------------------------------- | --------------------------------------------------------------------------- | --------------------------------------------------------------------------- | -| `actionKey` | *string* | :heavy_check_mark: | ID or key of the action to execute | -| `contentIds` | *string*[] | :heavy_minus_sign: | IDs of the content items to apply the action to. Provide this or authorIds. | -| `authorIds` | *string*[] | :heavy_minus_sign: | IDs of the authors to apply the action to. Provide this or contentIds. | -| `value` | *string* | :heavy_minus_sign: | Optional value to provide with the action | -| `queueId` | *string* | :heavy_minus_sign: | Optional queue ID if the action is queue-specific | -| `duration` | *number* | :heavy_minus_sign: | Optional duration in milliseconds for actions with timeouts | \ No newline at end of file +| Field | Type | Required | Description | +| ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `actionKey` | *string* | :heavy_check_mark: | ID or key of the action to execute | +| `contentIds` | *string*[] | :heavy_minus_sign: | IDs of the content items to apply the action to. Provide this or authorIds. | +| `authorIds` | *string*[] | :heavy_minus_sign: | IDs of the authors to apply the action to. Provide this or contentIds. | +| `value` | *string* | :heavy_minus_sign: | Optional value to provide with the action | +| `queueId` | *string* | :heavy_minus_sign: | Optional queue ID if the action is queue-specific | +| `duration` | *number* | :heavy_minus_sign: | Optional duration in milliseconds for actions with timeouts | +| `moderator` | *string* | :heavy_minus_sign: | The user ID or email of the organization member who made the decision. The action is recorded as theirs. | +| `createCasebookCase` | *boolean* | :heavy_minus_sign: | Record an allow or reject decision as a casebook case. Defaults to true when `moderator` is set, else false. Without `moderator`, the case is recorded as System. | \ No newline at end of file diff --git a/docs/models/operations/reject-content-request-body.md b/docs/models/operations/reject-content-request-body.md new file mode 100644 index 0000000..3f4b04c --- /dev/null +++ b/docs/models/operations/reject-content-request-body.md @@ -0,0 +1,18 @@ +# RejectContentRequestBody + +## Example Usage + +```typescript +import { RejectContentRequestBody } from "@moderation-api/sdk/models/operations"; + +let value: RejectContentRequestBody = {}; +``` + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `reason` | *string* | :heavy_minus_sign: | Why the action was taken. Saved with the action and sent in the webhook event. | +| `queueId` | *string* | :heavy_minus_sign: | The queue the content is reviewed in. Defaults to the project's default queue. | +| `moderator` | *string* | :heavy_minus_sign: | The user ID or email of the organization member who made the decision. The action is recorded as theirs. | +| `createCasebookCase` | *boolean* | :heavy_minus_sign: | Record an allow or reject decision as a casebook case. Defaults to true when `moderator` is set, else false. Without `moderator`, the case is recorded as System. | \ No newline at end of file diff --git a/docs/models/operations/reject-content-request.md b/docs/models/operations/reject-content-request.md new file mode 100644 index 0000000..8e5319f --- /dev/null +++ b/docs/models/operations/reject-content-request.md @@ -0,0 +1,20 @@ +# RejectContentRequest + +## Example Usage + +```typescript +import { RejectContentRequest } from "@moderation-api/sdk/models/operations"; + +let value: RejectContentRequest = { + id: "", + body: {}, +}; +``` + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `id` | *string* | :heavy_check_mark: | The content ID you sent when you submitted the content, or the ID Moderation API assigned. | +| `projectId` | *string* | :heavy_minus_sign: | The project to act on, by ID or name. Required with an organization key unless the key reaches only one project; list projects with GET /projects. A project key acts on its own project and needs no value: naming another one is an error. | +| `body` | [operations.RejectContentRequestBody](../../models/operations/reject-content-request-body.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/operations/reject-content-response.md b/docs/models/operations/reject-content-response.md new file mode 100644 index 0000000..3215870 --- /dev/null +++ b/docs/models/operations/reject-content-response.md @@ -0,0 +1,19 @@ +# RejectContentResponse + +Execution result + +## Example Usage + +```typescript +import { RejectContentResponse } from "@moderation-api/sdk/models/operations"; + +let value: RejectContentResponse = { + success: true, +}; +``` + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------- | -------------------------------------------- | -------------------------------------------- | -------------------------------------------- | +| `success` | *boolean* | :heavy_check_mark: | Whether the action was executed successfully | \ No newline at end of file diff --git a/docs/models/operations/suspend-author-request-body.md b/docs/models/operations/suspend-author-request-body.md new file mode 100644 index 0000000..e67ebb0 --- /dev/null +++ b/docs/models/operations/suspend-author-request-body.md @@ -0,0 +1,16 @@ +# SuspendAuthorRequestBody + +## Example Usage + +```typescript +import { SuspendAuthorRequestBody } from "@moderation-api/sdk/models/operations"; + +let value: SuspendAuthorRequestBody = {}; +``` + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | +| `reason` | *string* | :heavy_minus_sign: | Why the action was taken. Saved with the action and sent in the webhook event. | +| `duration` | *number* | :heavy_minus_sign: | How long the suspension lasts, in milliseconds. Defaults to 24 hours. | \ No newline at end of file diff --git a/docs/models/operations/suspend-author-request.md b/docs/models/operations/suspend-author-request.md new file mode 100644 index 0000000..c3ccea5 --- /dev/null +++ b/docs/models/operations/suspend-author-request.md @@ -0,0 +1,20 @@ +# SuspendAuthorRequest + +## Example Usage + +```typescript +import { SuspendAuthorRequest } from "@moderation-api/sdk/models/operations"; + +let value: SuspendAuthorRequest = { + id: "", + body: {}, +}; +``` + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `id` | *string* | :heavy_check_mark: | Either external ID or the ID assigned by moderation API. | +| `projectId` | *string* | :heavy_minus_sign: | The project to act on, by ID or name. Required with an organization key unless the key reaches only one project; list projects with GET /projects. A project key acts on its own project and needs no value: naming another one is an error. | +| `body` | [operations.SuspendAuthorRequestBody](../../models/operations/suspend-author-request-body.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/operations/suspend-author-response.md b/docs/models/operations/suspend-author-response.md new file mode 100644 index 0000000..11b7e2c --- /dev/null +++ b/docs/models/operations/suspend-author-response.md @@ -0,0 +1,19 @@ +# SuspendAuthorResponse + +Execution result + +## Example Usage + +```typescript +import { SuspendAuthorResponse } from "@moderation-api/sdk/models/operations"; + +let value: SuspendAuthorResponse = { + success: false, +}; +``` + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------- | -------------------------------------------- | -------------------------------------------- | -------------------------------------------- | +| `success` | *boolean* | :heavy_check_mark: | Whether the action was executed successfully | \ No newline at end of file diff --git a/docs/models/operations/unblock-author-request-body.md b/docs/models/operations/unblock-author-request-body.md new file mode 100644 index 0000000..d195000 --- /dev/null +++ b/docs/models/operations/unblock-author-request-body.md @@ -0,0 +1,15 @@ +# UnblockAuthorRequestBody + +## Example Usage + +```typescript +import { UnblockAuthorRequestBody } from "@moderation-api/sdk/models/operations"; + +let value: UnblockAuthorRequestBody = {}; +``` + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | +| `reason` | *string* | :heavy_minus_sign: | Why the action was taken. Saved with the action and sent in the webhook event. | \ No newline at end of file diff --git a/docs/models/operations/unblock-author-request.md b/docs/models/operations/unblock-author-request.md new file mode 100644 index 0000000..979ec50 --- /dev/null +++ b/docs/models/operations/unblock-author-request.md @@ -0,0 +1,20 @@ +# UnblockAuthorRequest + +## Example Usage + +```typescript +import { UnblockAuthorRequest } from "@moderation-api/sdk/models/operations"; + +let value: UnblockAuthorRequest = { + id: "", + body: {}, +}; +``` + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `id` | *string* | :heavy_check_mark: | Either external ID or the ID assigned by moderation API. | +| `projectId` | *string* | :heavy_minus_sign: | The project to act on, by ID or name. Required with an organization key unless the key reaches only one project; list projects with GET /projects. A project key acts on its own project and needs no value: naming another one is an error. | +| `body` | [operations.UnblockAuthorRequestBody](../../models/operations/unblock-author-request-body.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/operations/unblock-author-response.md b/docs/models/operations/unblock-author-response.md new file mode 100644 index 0000000..f6053b5 --- /dev/null +++ b/docs/models/operations/unblock-author-response.md @@ -0,0 +1,19 @@ +# UnblockAuthorResponse + +Execution result + +## Example Usage + +```typescript +import { UnblockAuthorResponse } from "@moderation-api/sdk/models/operations"; + +let value: UnblockAuthorResponse = { + success: true, +}; +``` + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------- | -------------------------------------------- | -------------------------------------------- | -------------------------------------------- | +| `success` | *boolean* | :heavy_check_mark: | Whether the action was executed successfully | \ No newline at end of file diff --git a/docs/sdks/authors/README.md b/docs/sdks/authors/README.md index bd2a7f1..d09258e 100644 --- a/docs/sdks/authors/README.md +++ b/docs/sdks/authors/README.md @@ -9,6 +9,9 @@ * [retrieve](#retrieve) - Get author details * [update](#update) - Update author details * [delete](#delete) - Delete an author +* [block](#block) - Block author +* [suspend](#suspend) - Suspend author +* [unblock](#unblock) - Unblock author ## list @@ -417,4 +420,235 @@ run(); | errors.NotFoundError | 404 | application/json | | errors.RateLimitError | 429 | application/json | | errors.InternalServerError | 500 | application/json | +| errors.ModerationAPIDefaultError | 4XX, 5XX | \*/\* | + +## block + +Block an author with the built-in block action. A blocked author cannot post new content until unblocked. + +### Example Usage + + +```typescript +import { ModerationApi } from "@moderation-api/sdk"; + +const moderationApi = new ModerationApi({ + secretKey: process.env["MODAPI_SECRET_KEY"] ?? "", +}); + +async function run() { + const result = await moderationApi.authors.block("", {}); + + console.log(result); +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { ModerationApiCore } from "@moderation-api/sdk/core.js"; +import { authorsBlock } from "@moderation-api/sdk/funcs/authors-block.js"; + +// Use `ModerationApiCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const moderationApi = new ModerationApiCore({ + secretKey: process.env["MODAPI_SECRET_KEY"] ?? "", +}); + +async function run() { + const res = await authorsBlock(moderationApi, "", {}); + if (res.ok) { + const { value: result } = res; + console.log(result); + } else { + console.log("authorsBlock failed:", res.error); + } +} + +run(); +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `id` | *string* | :heavy_check_mark: | Either external ID or the ID assigned by moderation API. | +| `body` | [operations.BlockAuthorRequestBody](../../models/operations/block-author-request-body.md) | :heavy_check_mark: | N/A | +| `projectId` | *string* | :heavy_minus_sign: | The project to act on, by ID or name. Required with an organization key unless the key reaches only one project; list projects with GET /projects. A project key acts on its own project and needs no value: naming another one is an error. | +| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. | +| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | +| `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | + +### Response + +**Promise\<[operations.BlockAuthorResponse](../../models/operations/block-author-response.md)\>** + +### Errors + +| Error Type | Status Code | Content Type | +| -------------------------------- | -------------------------------- | -------------------------------- | +| errors.BadRequestError | 400 | application/json | +| errors.AuthenticationError | 401 | application/json | +| errors.NotFoundError | 404 | application/json | +| errors.RateLimitError | 429 | application/json | +| errors.ModerationAPIDefaultError | 4XX, 5XX | \*/\* | + +## suspend + +Block an author for a limited time with the built-in suspend action. + +### Example Usage + + +```typescript +import { ModerationApi } from "@moderation-api/sdk"; + +const moderationApi = new ModerationApi({ + secretKey: process.env["MODAPI_SECRET_KEY"] ?? "", +}); + +async function run() { + const result = await moderationApi.authors.suspend("", { + reason: "Violation of community guidelines", + duration: 604800000, + }); + + console.log(result); +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { ModerationApiCore } from "@moderation-api/sdk/core.js"; +import { authorsSuspend } from "@moderation-api/sdk/funcs/authors-suspend.js"; + +// Use `ModerationApiCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const moderationApi = new ModerationApiCore({ + secretKey: process.env["MODAPI_SECRET_KEY"] ?? "", +}); + +async function run() { + const res = await authorsSuspend(moderationApi, "", { + reason: "Violation of community guidelines", + duration: 604800000, + }); + if (res.ok) { + const { value: result } = res; + console.log(result); + } else { + console.log("authorsSuspend failed:", res.error); + } +} + +run(); +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `id` | *string* | :heavy_check_mark: | Either external ID or the ID assigned by moderation API. | +| `body` | [operations.SuspendAuthorRequestBody](../../models/operations/suspend-author-request-body.md) | :heavy_check_mark: | N/A | +| `projectId` | *string* | :heavy_minus_sign: | The project to act on, by ID or name. Required with an organization key unless the key reaches only one project; list projects with GET /projects. A project key acts on its own project and needs no value: naming another one is an error. | +| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. | +| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | +| `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | + +### Response + +**Promise\<[operations.SuspendAuthorResponse](../../models/operations/suspend-author-response.md)\>** + +### Errors + +| Error Type | Status Code | Content Type | +| -------------------------------- | -------------------------------- | -------------------------------- | +| errors.BadRequestError | 400 | application/json | +| errors.AuthenticationError | 401 | application/json | +| errors.NotFoundError | 404 | application/json | +| errors.RateLimitError | 429 | application/json | +| errors.ModerationAPIDefaultError | 4XX, 5XX | \*/\* | + +## unblock + +Unblock a blocked or suspended author with the built-in unblock action, so they can post new content again. + +### Example Usage + + +```typescript +import { ModerationApi } from "@moderation-api/sdk"; + +const moderationApi = new ModerationApi({ + secretKey: process.env["MODAPI_SECRET_KEY"] ?? "", +}); + +async function run() { + const result = await moderationApi.authors.unblock("", {}); + + console.log(result); +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { ModerationApiCore } from "@moderation-api/sdk/core.js"; +import { authorsUnblock } from "@moderation-api/sdk/funcs/authors-unblock.js"; + +// Use `ModerationApiCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const moderationApi = new ModerationApiCore({ + secretKey: process.env["MODAPI_SECRET_KEY"] ?? "", +}); + +async function run() { + const res = await authorsUnblock(moderationApi, "", {}); + if (res.ok) { + const { value: result } = res; + console.log(result); + } else { + console.log("authorsUnblock failed:", res.error); + } +} + +run(); +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `id` | *string* | :heavy_check_mark: | Either external ID or the ID assigned by moderation API. | +| `body` | [operations.UnblockAuthorRequestBody](../../models/operations/unblock-author-request-body.md) | :heavy_check_mark: | N/A | +| `projectId` | *string* | :heavy_minus_sign: | The project to act on, by ID or name. Required with an organization key unless the key reaches only one project; list projects with GET /projects. A project key acts on its own project and needs no value: naming another one is an error. | +| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. | +| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | +| `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | + +### Response + +**Promise\<[operations.UnblockAuthorResponse](../../models/operations/unblock-author-response.md)\>** + +### Errors + +| Error Type | Status Code | Content Type | +| -------------------------------- | -------------------------------- | -------------------------------- | +| errors.BadRequestError | 400 | application/json | +| errors.AuthenticationError | 401 | application/json | +| errors.NotFoundError | 404 | application/json | +| errors.RateLimitError | 429 | application/json | | errors.ModerationAPIDefaultError | 4XX, 5XX | \*/\* | \ No newline at end of file diff --git a/docs/sdks/content/README.md b/docs/sdks/content/README.md index ea43e19..fe78ae0 100644 --- a/docs/sdks/content/README.md +++ b/docs/sdks/content/README.md @@ -4,8 +4,164 @@ ### Available Operations +* [reject](#reject) - Reject content +* [allow](#allow) - Allow content * [submit](#submit) - Submit content +## reject + +Reject a content item with the built-in reject action, and resolve it in the review queue. + +### Example Usage + + +```typescript +import { ModerationApi } from "@moderation-api/sdk"; + +const moderationApi = new ModerationApi({ + secretKey: process.env["MODAPI_SECRET_KEY"] ?? "", +}); + +async function run() { + const result = await moderationApi.content.reject("", { + reason: "Spam", + }); + + console.log(result); +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { ModerationApiCore } from "@moderation-api/sdk/core.js"; +import { contentReject } from "@moderation-api/sdk/funcs/content-reject.js"; + +// Use `ModerationApiCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const moderationApi = new ModerationApiCore({ + secretKey: process.env["MODAPI_SECRET_KEY"] ?? "", +}); + +async function run() { + const res = await contentReject(moderationApi, "", { + reason: "Spam", + }); + if (res.ok) { + const { value: result } = res; + console.log(result); + } else { + console.log("contentReject failed:", res.error); + } +} + +run(); +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `id` | *string* | :heavy_check_mark: | The content ID you sent when you submitted the content, or the ID Moderation API assigned. | +| `body` | [operations.RejectContentRequestBody](../../models/operations/reject-content-request-body.md) | :heavy_check_mark: | N/A | +| `projectId` | *string* | :heavy_minus_sign: | The project to act on, by ID or name. Required with an organization key unless the key reaches only one project; list projects with GET /projects. A project key acts on its own project and needs no value: naming another one is an error. | +| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. | +| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | +| `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | + +### Response + +**Promise\<[operations.RejectContentResponse](../../models/operations/reject-content-response.md)\>** + +### Errors + +| Error Type | Status Code | Content Type | +| -------------------------------- | -------------------------------- | -------------------------------- | +| errors.BadRequestError | 400 | application/json | +| errors.AuthenticationError | 401 | application/json | +| errors.NotFoundError | 404 | application/json | +| errors.RateLimitError | 429 | application/json | +| errors.ModerationAPIDefaultError | 4XX, 5XX | \*/\* | + +## allow + +Allow a content item with the built-in allow action, and resolve it in the review queue. + +### Example Usage + + +```typescript +import { ModerationApi } from "@moderation-api/sdk"; + +const moderationApi = new ModerationApi({ + secretKey: process.env["MODAPI_SECRET_KEY"] ?? "", +}); + +async function run() { + const result = await moderationApi.content.allow("", {}); + + console.log(result); +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { ModerationApiCore } from "@moderation-api/sdk/core.js"; +import { contentAllow } from "@moderation-api/sdk/funcs/content-allow.js"; + +// Use `ModerationApiCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const moderationApi = new ModerationApiCore({ + secretKey: process.env["MODAPI_SECRET_KEY"] ?? "", +}); + +async function run() { + const res = await contentAllow(moderationApi, "", {}); + if (res.ok) { + const { value: result } = res; + console.log(result); + } else { + console.log("contentAllow failed:", res.error); + } +} + +run(); +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `id` | *string* | :heavy_check_mark: | The content ID you sent when you submitted the content, or the ID Moderation API assigned. | +| `body` | [operations.AllowContentRequestBody](../../models/operations/allow-content-request-body.md) | :heavy_check_mark: | N/A | +| `projectId` | *string* | :heavy_minus_sign: | The project to act on, by ID or name. Required with an organization key unless the key reaches only one project; list projects with GET /projects. A project key acts on its own project and needs no value: naming another one is an error. | +| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. | +| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | +| `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | + +### Response + +**Promise\<[operations.AllowContentResponse](../../models/operations/allow-content-response.md)\>** + +### Errors + +| Error Type | Status Code | Content Type | +| -------------------------------- | -------------------------------- | -------------------------------- | +| errors.BadRequestError | 400 | application/json | +| errors.AuthenticationError | 401 | application/json | +| errors.NotFoundError | 404 | application/json | +| errors.RateLimitError | 429 | application/json | +| errors.ModerationAPIDefaultError | 4XX, 5XX | \*/\* | + ## submit Submit content diff --git a/jsr.json b/jsr.json index 8d7a9ee..59ea71b 100644 --- a/jsr.json +++ b/jsr.json @@ -2,7 +2,7 @@ { "name": "@moderation-api/sdk", - "version": "5.2.0", + "version": "5.3.0", "exports": { ".": "./src/index.ts", "./models/errors": "./src/models/errors/index.ts", diff --git a/package.json b/package.json index 6f678f8..0f2156d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@moderation-api/sdk", - "version": "5.2.0", + "version": "5.3.0", "author": "Moderation API", "license": "Apache-2.0", "type": "module", diff --git a/src/funcs/authors-block.ts b/src/funcs/authors-block.ts new file mode 100644 index 0000000..da2a7ec --- /dev/null +++ b/src/funcs/authors-block.ts @@ -0,0 +1,206 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod/v4-mini"; +import { ModerationApiCore } from "../core.js"; +import { encodeJSON, encodeSimple } from "../lib/encodings.js"; +import { matchStatusCode } from "../lib/http.js"; +import * as M from "../lib/matchers.js"; +import { compactMap } from "../lib/primitives.js"; +import { safeParse } from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../models/errors/http-client-errors.js"; +import * as errors from "../models/errors/index.js"; +import { ModerationAPIError } from "../models/errors/moderation-api-error.js"; +import { ResponseValidationError } from "../models/errors/response-validation-error.js"; +import { SDKValidationError } from "../models/errors/sdk-validation-error.js"; +import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; +import { Result } from "../types/fp.js"; + +/** + * Block author + * + * @remarks + * Block an author with the built-in block action. A blocked author cannot post new content until unblocked. + */ +export function authorsBlock( + client: ModerationApiCore, + id: string, + body: operations.BlockAuthorRequestBody, + projectId?: string | undefined, + options?: RequestOptions, +): APIPromise< + Result< + operations.BlockAuthorResponse, + | errors.BadRequestError + | errors.AuthenticationError + | errors.NotFoundError + | errors.RateLimitError + | ModerationAPIError + | ResponseValidationError + | ConnectionError + | RequestAbortedError + | RequestTimeoutError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError + > +> { + return new APIPromise($do( + client, + id, + body, + projectId, + options, + )); +} + +async function $do( + client: ModerationApiCore, + id: string, + body: operations.BlockAuthorRequestBody, + projectId?: string | undefined, + options?: RequestOptions, +): Promise< + [ + Result< + operations.BlockAuthorResponse, + | errors.BadRequestError + | errors.AuthenticationError + | errors.NotFoundError + | errors.RateLimitError + | ModerationAPIError + | ResponseValidationError + | ConnectionError + | RequestAbortedError + | RequestTimeoutError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError + >, + APICall, + ] +> { + const input: operations.BlockAuthorRequest = { + id: id, + body: body, + projectId: projectId, + }; + + const parsed = safeParse( + input, + (value) => z.parse(operations.BlockAuthorRequest$outboundSchema, value), + "Input validation failed", + ); + if (!parsed.ok) { + return [parsed, { status: "invalid" }]; + } + const payload = parsed.value; + const body$ = encodeJSON("body", payload.body, { explode: true }); + + const pathParams = { + id: encodeSimple("id", payload.id, { + explode: false, + charEncoding: "percent", + }), + }; + const path = pathToFunc("/authors/{id}/block")(pathParams); + + const headers = new Headers(compactMap({ + "Content-Type": "application/json", + Accept: "application/json", + "Project-Id": encodeSimple("Project-Id", payload.projectId, { + explode: false, + charEncoding: "none", + }), + })); + + const secConfig = await extractSecurity(client._options.secretKey); + const securityInput = secConfig == null ? {} : { secretKey: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + + const context = { + options: client._options, + baseURL: options?.serverURL ?? client._baseURL ?? "", + operationID: "blockAuthor", + oAuth2Scopes: null, + + resolvedSecurity: requestSecurity, + + securitySource: client._options.secretKey, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + }; + + const requestRes = client._createRequest(context, { + security: requestSecurity, + method: "POST", + baseURL: options?.serverURL, + path: path, + headers: headers, + body: body$, + userAgent: client._options.userAgent, + timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return [requestRes, { status: "invalid" }]; + } + const req = requestRes.value; + + const doResult = await client._do(req, { + context, + isErrorStatusCode: (statusCode: number) => + matchStatusCode({ status: statusCode } as Response, ["4XX", "5XX"]), + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, + }); + if (!doResult.ok) { + return [doResult, { status: "request-error", request: req }]; + } + const response = doResult.value; + + const responseFields = { + HttpMeta: { Response: response, Request: req }, + }; + + const [result] = await M.match< + operations.BlockAuthorResponse, + | errors.BadRequestError + | errors.AuthenticationError + | errors.NotFoundError + | errors.RateLimitError + | ModerationAPIError + | ResponseValidationError + | ConnectionError + | RequestAbortedError + | RequestTimeoutError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError + >( + M.json(200, operations.BlockAuthorResponse$inboundSchema), + M.jsonErr(400, errors.BadRequestError$inboundSchema), + M.jsonErr(401, errors.AuthenticationError$inboundSchema), + M.jsonErr(404, errors.NotFoundError$inboundSchema), + M.jsonErr(429, errors.RateLimitError$inboundSchema), + M.fail("4XX"), + M.fail("5XX"), + )(response, req, { extraFields: responseFields }); + if (!result.ok) { + return [result, { status: "complete", request: req, response }]; + } + + return [result, { status: "complete", request: req, response }]; +} diff --git a/src/funcs/authors-suspend.ts b/src/funcs/authors-suspend.ts new file mode 100644 index 0000000..774d51b --- /dev/null +++ b/src/funcs/authors-suspend.ts @@ -0,0 +1,206 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod/v4-mini"; +import { ModerationApiCore } from "../core.js"; +import { encodeJSON, encodeSimple } from "../lib/encodings.js"; +import { matchStatusCode } from "../lib/http.js"; +import * as M from "../lib/matchers.js"; +import { compactMap } from "../lib/primitives.js"; +import { safeParse } from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../models/errors/http-client-errors.js"; +import * as errors from "../models/errors/index.js"; +import { ModerationAPIError } from "../models/errors/moderation-api-error.js"; +import { ResponseValidationError } from "../models/errors/response-validation-error.js"; +import { SDKValidationError } from "../models/errors/sdk-validation-error.js"; +import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; +import { Result } from "../types/fp.js"; + +/** + * Suspend author + * + * @remarks + * Block an author for a limited time with the built-in suspend action. + */ +export function authorsSuspend( + client: ModerationApiCore, + id: string, + body: operations.SuspendAuthorRequestBody, + projectId?: string | undefined, + options?: RequestOptions, +): APIPromise< + Result< + operations.SuspendAuthorResponse, + | errors.BadRequestError + | errors.AuthenticationError + | errors.NotFoundError + | errors.RateLimitError + | ModerationAPIError + | ResponseValidationError + | ConnectionError + | RequestAbortedError + | RequestTimeoutError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError + > +> { + return new APIPromise($do( + client, + id, + body, + projectId, + options, + )); +} + +async function $do( + client: ModerationApiCore, + id: string, + body: operations.SuspendAuthorRequestBody, + projectId?: string | undefined, + options?: RequestOptions, +): Promise< + [ + Result< + operations.SuspendAuthorResponse, + | errors.BadRequestError + | errors.AuthenticationError + | errors.NotFoundError + | errors.RateLimitError + | ModerationAPIError + | ResponseValidationError + | ConnectionError + | RequestAbortedError + | RequestTimeoutError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError + >, + APICall, + ] +> { + const input: operations.SuspendAuthorRequest = { + id: id, + body: body, + projectId: projectId, + }; + + const parsed = safeParse( + input, + (value) => z.parse(operations.SuspendAuthorRequest$outboundSchema, value), + "Input validation failed", + ); + if (!parsed.ok) { + return [parsed, { status: "invalid" }]; + } + const payload = parsed.value; + const body$ = encodeJSON("body", payload.body, { explode: true }); + + const pathParams = { + id: encodeSimple("id", payload.id, { + explode: false, + charEncoding: "percent", + }), + }; + const path = pathToFunc("/authors/{id}/suspend")(pathParams); + + const headers = new Headers(compactMap({ + "Content-Type": "application/json", + Accept: "application/json", + "Project-Id": encodeSimple("Project-Id", payload.projectId, { + explode: false, + charEncoding: "none", + }), + })); + + const secConfig = await extractSecurity(client._options.secretKey); + const securityInput = secConfig == null ? {} : { secretKey: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + + const context = { + options: client._options, + baseURL: options?.serverURL ?? client._baseURL ?? "", + operationID: "suspendAuthor", + oAuth2Scopes: null, + + resolvedSecurity: requestSecurity, + + securitySource: client._options.secretKey, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + }; + + const requestRes = client._createRequest(context, { + security: requestSecurity, + method: "POST", + baseURL: options?.serverURL, + path: path, + headers: headers, + body: body$, + userAgent: client._options.userAgent, + timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return [requestRes, { status: "invalid" }]; + } + const req = requestRes.value; + + const doResult = await client._do(req, { + context, + isErrorStatusCode: (statusCode: number) => + matchStatusCode({ status: statusCode } as Response, ["4XX", "5XX"]), + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, + }); + if (!doResult.ok) { + return [doResult, { status: "request-error", request: req }]; + } + const response = doResult.value; + + const responseFields = { + HttpMeta: { Response: response, Request: req }, + }; + + const [result] = await M.match< + operations.SuspendAuthorResponse, + | errors.BadRequestError + | errors.AuthenticationError + | errors.NotFoundError + | errors.RateLimitError + | ModerationAPIError + | ResponseValidationError + | ConnectionError + | RequestAbortedError + | RequestTimeoutError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError + >( + M.json(200, operations.SuspendAuthorResponse$inboundSchema), + M.jsonErr(400, errors.BadRequestError$inboundSchema), + M.jsonErr(401, errors.AuthenticationError$inboundSchema), + M.jsonErr(404, errors.NotFoundError$inboundSchema), + M.jsonErr(429, errors.RateLimitError$inboundSchema), + M.fail("4XX"), + M.fail("5XX"), + )(response, req, { extraFields: responseFields }); + if (!result.ok) { + return [result, { status: "complete", request: req, response }]; + } + + return [result, { status: "complete", request: req, response }]; +} diff --git a/src/funcs/authors-unblock.ts b/src/funcs/authors-unblock.ts new file mode 100644 index 0000000..b96d47c --- /dev/null +++ b/src/funcs/authors-unblock.ts @@ -0,0 +1,206 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod/v4-mini"; +import { ModerationApiCore } from "../core.js"; +import { encodeJSON, encodeSimple } from "../lib/encodings.js"; +import { matchStatusCode } from "../lib/http.js"; +import * as M from "../lib/matchers.js"; +import { compactMap } from "../lib/primitives.js"; +import { safeParse } from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../models/errors/http-client-errors.js"; +import * as errors from "../models/errors/index.js"; +import { ModerationAPIError } from "../models/errors/moderation-api-error.js"; +import { ResponseValidationError } from "../models/errors/response-validation-error.js"; +import { SDKValidationError } from "../models/errors/sdk-validation-error.js"; +import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; +import { Result } from "../types/fp.js"; + +/** + * Unblock author + * + * @remarks + * Unblock a blocked or suspended author with the built-in unblock action, so they can post new content again. + */ +export function authorsUnblock( + client: ModerationApiCore, + id: string, + body: operations.UnblockAuthorRequestBody, + projectId?: string | undefined, + options?: RequestOptions, +): APIPromise< + Result< + operations.UnblockAuthorResponse, + | errors.BadRequestError + | errors.AuthenticationError + | errors.NotFoundError + | errors.RateLimitError + | ModerationAPIError + | ResponseValidationError + | ConnectionError + | RequestAbortedError + | RequestTimeoutError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError + > +> { + return new APIPromise($do( + client, + id, + body, + projectId, + options, + )); +} + +async function $do( + client: ModerationApiCore, + id: string, + body: operations.UnblockAuthorRequestBody, + projectId?: string | undefined, + options?: RequestOptions, +): Promise< + [ + Result< + operations.UnblockAuthorResponse, + | errors.BadRequestError + | errors.AuthenticationError + | errors.NotFoundError + | errors.RateLimitError + | ModerationAPIError + | ResponseValidationError + | ConnectionError + | RequestAbortedError + | RequestTimeoutError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError + >, + APICall, + ] +> { + const input: operations.UnblockAuthorRequest = { + id: id, + body: body, + projectId: projectId, + }; + + const parsed = safeParse( + input, + (value) => z.parse(operations.UnblockAuthorRequest$outboundSchema, value), + "Input validation failed", + ); + if (!parsed.ok) { + return [parsed, { status: "invalid" }]; + } + const payload = parsed.value; + const body$ = encodeJSON("body", payload.body, { explode: true }); + + const pathParams = { + id: encodeSimple("id", payload.id, { + explode: false, + charEncoding: "percent", + }), + }; + const path = pathToFunc("/authors/{id}/unblock")(pathParams); + + const headers = new Headers(compactMap({ + "Content-Type": "application/json", + Accept: "application/json", + "Project-Id": encodeSimple("Project-Id", payload.projectId, { + explode: false, + charEncoding: "none", + }), + })); + + const secConfig = await extractSecurity(client._options.secretKey); + const securityInput = secConfig == null ? {} : { secretKey: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + + const context = { + options: client._options, + baseURL: options?.serverURL ?? client._baseURL ?? "", + operationID: "unblockAuthor", + oAuth2Scopes: null, + + resolvedSecurity: requestSecurity, + + securitySource: client._options.secretKey, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + }; + + const requestRes = client._createRequest(context, { + security: requestSecurity, + method: "POST", + baseURL: options?.serverURL, + path: path, + headers: headers, + body: body$, + userAgent: client._options.userAgent, + timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return [requestRes, { status: "invalid" }]; + } + const req = requestRes.value; + + const doResult = await client._do(req, { + context, + isErrorStatusCode: (statusCode: number) => + matchStatusCode({ status: statusCode } as Response, ["4XX", "5XX"]), + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, + }); + if (!doResult.ok) { + return [doResult, { status: "request-error", request: req }]; + } + const response = doResult.value; + + const responseFields = { + HttpMeta: { Response: response, Request: req }, + }; + + const [result] = await M.match< + operations.UnblockAuthorResponse, + | errors.BadRequestError + | errors.AuthenticationError + | errors.NotFoundError + | errors.RateLimitError + | ModerationAPIError + | ResponseValidationError + | ConnectionError + | RequestAbortedError + | RequestTimeoutError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError + >( + M.json(200, operations.UnblockAuthorResponse$inboundSchema), + M.jsonErr(400, errors.BadRequestError$inboundSchema), + M.jsonErr(401, errors.AuthenticationError$inboundSchema), + M.jsonErr(404, errors.NotFoundError$inboundSchema), + M.jsonErr(429, errors.RateLimitError$inboundSchema), + M.fail("4XX"), + M.fail("5XX"), + )(response, req, { extraFields: responseFields }); + if (!result.ok) { + return [result, { status: "complete", request: req, response }]; + } + + return [result, { status: "complete", request: req, response }]; +} diff --git a/src/funcs/content-allow.ts b/src/funcs/content-allow.ts new file mode 100644 index 0000000..03bf56f --- /dev/null +++ b/src/funcs/content-allow.ts @@ -0,0 +1,206 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod/v4-mini"; +import { ModerationApiCore } from "../core.js"; +import { encodeJSON, encodeSimple } from "../lib/encodings.js"; +import { matchStatusCode } from "../lib/http.js"; +import * as M from "../lib/matchers.js"; +import { compactMap } from "../lib/primitives.js"; +import { safeParse } from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../models/errors/http-client-errors.js"; +import * as errors from "../models/errors/index.js"; +import { ModerationAPIError } from "../models/errors/moderation-api-error.js"; +import { ResponseValidationError } from "../models/errors/response-validation-error.js"; +import { SDKValidationError } from "../models/errors/sdk-validation-error.js"; +import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; +import { Result } from "../types/fp.js"; + +/** + * Allow content + * + * @remarks + * Allow a content item with the built-in allow action, and resolve it in the review queue. + */ +export function contentAllow( + client: ModerationApiCore, + id: string, + body: operations.AllowContentRequestBody, + projectId?: string | undefined, + options?: RequestOptions, +): APIPromise< + Result< + operations.AllowContentResponse, + | errors.BadRequestError + | errors.AuthenticationError + | errors.NotFoundError + | errors.RateLimitError + | ModerationAPIError + | ResponseValidationError + | ConnectionError + | RequestAbortedError + | RequestTimeoutError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError + > +> { + return new APIPromise($do( + client, + id, + body, + projectId, + options, + )); +} + +async function $do( + client: ModerationApiCore, + id: string, + body: operations.AllowContentRequestBody, + projectId?: string | undefined, + options?: RequestOptions, +): Promise< + [ + Result< + operations.AllowContentResponse, + | errors.BadRequestError + | errors.AuthenticationError + | errors.NotFoundError + | errors.RateLimitError + | ModerationAPIError + | ResponseValidationError + | ConnectionError + | RequestAbortedError + | RequestTimeoutError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError + >, + APICall, + ] +> { + const input: operations.AllowContentRequest = { + id: id, + body: body, + projectId: projectId, + }; + + const parsed = safeParse( + input, + (value) => z.parse(operations.AllowContentRequest$outboundSchema, value), + "Input validation failed", + ); + if (!parsed.ok) { + return [parsed, { status: "invalid" }]; + } + const payload = parsed.value; + const body$ = encodeJSON("body", payload.body, { explode: true }); + + const pathParams = { + id: encodeSimple("id", payload.id, { + explode: false, + charEncoding: "percent", + }), + }; + const path = pathToFunc("/content/{id}/allow")(pathParams); + + const headers = new Headers(compactMap({ + "Content-Type": "application/json", + Accept: "application/json", + "Project-Id": encodeSimple("Project-Id", payload.projectId, { + explode: false, + charEncoding: "none", + }), + })); + + const secConfig = await extractSecurity(client._options.secretKey); + const securityInput = secConfig == null ? {} : { secretKey: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + + const context = { + options: client._options, + baseURL: options?.serverURL ?? client._baseURL ?? "", + operationID: "allowContent", + oAuth2Scopes: null, + + resolvedSecurity: requestSecurity, + + securitySource: client._options.secretKey, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + }; + + const requestRes = client._createRequest(context, { + security: requestSecurity, + method: "POST", + baseURL: options?.serverURL, + path: path, + headers: headers, + body: body$, + userAgent: client._options.userAgent, + timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return [requestRes, { status: "invalid" }]; + } + const req = requestRes.value; + + const doResult = await client._do(req, { + context, + isErrorStatusCode: (statusCode: number) => + matchStatusCode({ status: statusCode } as Response, ["4XX", "5XX"]), + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, + }); + if (!doResult.ok) { + return [doResult, { status: "request-error", request: req }]; + } + const response = doResult.value; + + const responseFields = { + HttpMeta: { Response: response, Request: req }, + }; + + const [result] = await M.match< + operations.AllowContentResponse, + | errors.BadRequestError + | errors.AuthenticationError + | errors.NotFoundError + | errors.RateLimitError + | ModerationAPIError + | ResponseValidationError + | ConnectionError + | RequestAbortedError + | RequestTimeoutError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError + >( + M.json(200, operations.AllowContentResponse$inboundSchema), + M.jsonErr(400, errors.BadRequestError$inboundSchema), + M.jsonErr(401, errors.AuthenticationError$inboundSchema), + M.jsonErr(404, errors.NotFoundError$inboundSchema), + M.jsonErr(429, errors.RateLimitError$inboundSchema), + M.fail("4XX"), + M.fail("5XX"), + )(response, req, { extraFields: responseFields }); + if (!result.ok) { + return [result, { status: "complete", request: req, response }]; + } + + return [result, { status: "complete", request: req, response }]; +} diff --git a/src/funcs/content-reject.ts b/src/funcs/content-reject.ts new file mode 100644 index 0000000..ec95e66 --- /dev/null +++ b/src/funcs/content-reject.ts @@ -0,0 +1,206 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod/v4-mini"; +import { ModerationApiCore } from "../core.js"; +import { encodeJSON, encodeSimple } from "../lib/encodings.js"; +import { matchStatusCode } from "../lib/http.js"; +import * as M from "../lib/matchers.js"; +import { compactMap } from "../lib/primitives.js"; +import { safeParse } from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../models/errors/http-client-errors.js"; +import * as errors from "../models/errors/index.js"; +import { ModerationAPIError } from "../models/errors/moderation-api-error.js"; +import { ResponseValidationError } from "../models/errors/response-validation-error.js"; +import { SDKValidationError } from "../models/errors/sdk-validation-error.js"; +import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; +import { Result } from "../types/fp.js"; + +/** + * Reject content + * + * @remarks + * Reject a content item with the built-in reject action, and resolve it in the review queue. + */ +export function contentReject( + client: ModerationApiCore, + id: string, + body: operations.RejectContentRequestBody, + projectId?: string | undefined, + options?: RequestOptions, +): APIPromise< + Result< + operations.RejectContentResponse, + | errors.BadRequestError + | errors.AuthenticationError + | errors.NotFoundError + | errors.RateLimitError + | ModerationAPIError + | ResponseValidationError + | ConnectionError + | RequestAbortedError + | RequestTimeoutError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError + > +> { + return new APIPromise($do( + client, + id, + body, + projectId, + options, + )); +} + +async function $do( + client: ModerationApiCore, + id: string, + body: operations.RejectContentRequestBody, + projectId?: string | undefined, + options?: RequestOptions, +): Promise< + [ + Result< + operations.RejectContentResponse, + | errors.BadRequestError + | errors.AuthenticationError + | errors.NotFoundError + | errors.RateLimitError + | ModerationAPIError + | ResponseValidationError + | ConnectionError + | RequestAbortedError + | RequestTimeoutError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError + >, + APICall, + ] +> { + const input: operations.RejectContentRequest = { + id: id, + body: body, + projectId: projectId, + }; + + const parsed = safeParse( + input, + (value) => z.parse(operations.RejectContentRequest$outboundSchema, value), + "Input validation failed", + ); + if (!parsed.ok) { + return [parsed, { status: "invalid" }]; + } + const payload = parsed.value; + const body$ = encodeJSON("body", payload.body, { explode: true }); + + const pathParams = { + id: encodeSimple("id", payload.id, { + explode: false, + charEncoding: "percent", + }), + }; + const path = pathToFunc("/content/{id}/reject")(pathParams); + + const headers = new Headers(compactMap({ + "Content-Type": "application/json", + Accept: "application/json", + "Project-Id": encodeSimple("Project-Id", payload.projectId, { + explode: false, + charEncoding: "none", + }), + })); + + const secConfig = await extractSecurity(client._options.secretKey); + const securityInput = secConfig == null ? {} : { secretKey: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + + const context = { + options: client._options, + baseURL: options?.serverURL ?? client._baseURL ?? "", + operationID: "rejectContent", + oAuth2Scopes: null, + + resolvedSecurity: requestSecurity, + + securitySource: client._options.secretKey, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + }; + + const requestRes = client._createRequest(context, { + security: requestSecurity, + method: "POST", + baseURL: options?.serverURL, + path: path, + headers: headers, + body: body$, + userAgent: client._options.userAgent, + timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return [requestRes, { status: "invalid" }]; + } + const req = requestRes.value; + + const doResult = await client._do(req, { + context, + isErrorStatusCode: (statusCode: number) => + matchStatusCode({ status: statusCode } as Response, ["4XX", "5XX"]), + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, + }); + if (!doResult.ok) { + return [doResult, { status: "request-error", request: req }]; + } + const response = doResult.value; + + const responseFields = { + HttpMeta: { Response: response, Request: req }, + }; + + const [result] = await M.match< + operations.RejectContentResponse, + | errors.BadRequestError + | errors.AuthenticationError + | errors.NotFoundError + | errors.RateLimitError + | ModerationAPIError + | ResponseValidationError + | ConnectionError + | RequestAbortedError + | RequestTimeoutError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError + >( + M.json(200, operations.RejectContentResponse$inboundSchema), + M.jsonErr(400, errors.BadRequestError$inboundSchema), + M.jsonErr(401, errors.AuthenticationError$inboundSchema), + M.jsonErr(404, errors.NotFoundError$inboundSchema), + M.jsonErr(429, errors.RateLimitError$inboundSchema), + M.fail("4XX"), + M.fail("5XX"), + )(response, req, { extraFields: responseFields }); + if (!result.ok) { + return [result, { status: "complete", request: req, response }]; + } + + return [result, { status: "complete", request: req, response }]; +} diff --git a/src/lib/config.ts b/src/lib/config.ts index 0d3431e..44bd41a 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -58,8 +58,8 @@ export function serverURLFromOptions(options: SDKOptions): URL | null { export const SDK_METADATA = { language: "typescript", openapiDocVersion: "1.1.0", - sdkVersion: "5.2.0", + sdkVersion: "5.3.0", genVersion: "internal", userAgent: - "speakeasy-sdk/typescript 5.2.0 internal 1.1.0 @moderation-api/sdk", + "speakeasy-sdk/typescript 5.3.0 internal 1.1.0 @moderation-api/sdk", } as const; diff --git a/src/models/operations/allow-content.ts b/src/models/operations/allow-content.ts new file mode 100644 index 0000000..1148203 --- /dev/null +++ b/src/models/operations/allow-content.ts @@ -0,0 +1,120 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod/v4-mini"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import * as types from "../../types/primitives.js"; +import { SDKValidationError } from "../errors/sdk-validation-error.js"; + +export type AllowContentRequestBody = { + /** + * Why the action was taken. Saved with the action and sent in the webhook event. + */ + reason?: string | undefined; + /** + * The queue the content is reviewed in. Defaults to the project's default queue. + */ + queueId?: string | undefined; + /** + * The user ID or email of the organization member who made the decision. The action is recorded as theirs. + */ + moderator?: string | undefined; + /** + * Record an allow or reject decision as a casebook case. Defaults to true when `moderator` is set, else false. Without `moderator`, the case is recorded as System. + */ + createCasebookCase?: boolean | undefined; +}; + +export type AllowContentRequest = { + /** + * The content ID you sent when you submitted the content, or the ID Moderation API assigned. + */ + id: string; + /** + * The project to act on, by ID or name. Required with an organization key unless the key reaches only one project; list projects with GET /projects. A project key acts on its own project and needs no value: naming another one is an error. + */ + projectId?: string | undefined; + body: AllowContentRequestBody; +}; + +/** + * Execution result + */ +export type AllowContentResponse = { + /** + * Whether the action was executed successfully + */ + success: boolean; +}; + +/** @internal */ +export type AllowContentRequestBody$Outbound = { + reason?: string | undefined; + queueId?: string | undefined; + moderator?: string | undefined; + createCasebookCase?: boolean | undefined; +}; + +/** @internal */ +export const AllowContentRequestBody$outboundSchema: z.ZodMiniType< + AllowContentRequestBody$Outbound, + AllowContentRequestBody +> = z.object({ + reason: z.optional(z.string()), + queueId: z.optional(z.string()), + moderator: z.optional(z.string()), + createCasebookCase: z.optional(z.boolean()), +}); + +export function allowContentRequestBodyToJSON( + allowContentRequestBody: AllowContentRequestBody, +): string { + return JSON.stringify( + AllowContentRequestBody$outboundSchema.parse(allowContentRequestBody), + ); +} + +/** @internal */ +export type AllowContentRequest$Outbound = { + id: string; + projectId?: string | undefined; + body: AllowContentRequestBody$Outbound; +}; + +/** @internal */ +export const AllowContentRequest$outboundSchema: z.ZodMiniType< + AllowContentRequest$Outbound, + AllowContentRequest +> = z.object({ + id: z.string(), + projectId: z.optional(z.string()), + body: z.lazy(() => AllowContentRequestBody$outboundSchema), +}); + +export function allowContentRequestToJSON( + allowContentRequest: AllowContentRequest, +): string { + return JSON.stringify( + AllowContentRequest$outboundSchema.parse(allowContentRequest), + ); +} + +/** @internal */ +export const AllowContentResponse$inboundSchema: z.ZodMiniType< + AllowContentResponse, + unknown +> = z.object({ + success: types.boolean(), +}); + +export function allowContentResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => AllowContentResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'AllowContentResponse' from JSON`, + ); +} diff --git a/src/models/operations/block-author.ts b/src/models/operations/block-author.ts new file mode 100644 index 0000000..bcf8f80 --- /dev/null +++ b/src/models/operations/block-author.ts @@ -0,0 +1,102 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod/v4-mini"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import * as types from "../../types/primitives.js"; +import { SDKValidationError } from "../errors/sdk-validation-error.js"; + +export type BlockAuthorRequestBody = { + /** + * Why the action was taken. Saved with the action and sent in the webhook event. + */ + reason?: string | undefined; +}; + +export type BlockAuthorRequest = { + /** + * Either external ID or the ID assigned by moderation API. + */ + id: string; + /** + * The project to act on, by ID or name. Required with an organization key unless the key reaches only one project; list projects with GET /projects. A project key acts on its own project and needs no value: naming another one is an error. + */ + projectId?: string | undefined; + body: BlockAuthorRequestBody; +}; + +/** + * Execution result + */ +export type BlockAuthorResponse = { + /** + * Whether the action was executed successfully + */ + success: boolean; +}; + +/** @internal */ +export type BlockAuthorRequestBody$Outbound = { + reason?: string | undefined; +}; + +/** @internal */ +export const BlockAuthorRequestBody$outboundSchema: z.ZodMiniType< + BlockAuthorRequestBody$Outbound, + BlockAuthorRequestBody +> = z.object({ + reason: z.optional(z.string()), +}); + +export function blockAuthorRequestBodyToJSON( + blockAuthorRequestBody: BlockAuthorRequestBody, +): string { + return JSON.stringify( + BlockAuthorRequestBody$outboundSchema.parse(blockAuthorRequestBody), + ); +} + +/** @internal */ +export type BlockAuthorRequest$Outbound = { + id: string; + projectId?: string | undefined; + body: BlockAuthorRequestBody$Outbound; +}; + +/** @internal */ +export const BlockAuthorRequest$outboundSchema: z.ZodMiniType< + BlockAuthorRequest$Outbound, + BlockAuthorRequest +> = z.object({ + id: z.string(), + projectId: z.optional(z.string()), + body: z.lazy(() => BlockAuthorRequestBody$outboundSchema), +}); + +export function blockAuthorRequestToJSON( + blockAuthorRequest: BlockAuthorRequest, +): string { + return JSON.stringify( + BlockAuthorRequest$outboundSchema.parse(blockAuthorRequest), + ); +} + +/** @internal */ +export const BlockAuthorResponse$inboundSchema: z.ZodMiniType< + BlockAuthorResponse, + unknown +> = z.object({ + success: types.boolean(), +}); + +export function blockAuthorResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => BlockAuthorResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'BlockAuthorResponse' from JSON`, + ); +} diff --git a/src/models/operations/execute-action.ts b/src/models/operations/execute-action.ts index 26e2972..9b9edd9 100644 --- a/src/models/operations/execute-action.ts +++ b/src/models/operations/execute-action.ts @@ -36,6 +36,14 @@ export type ExecuteActionRequestBody = { * Optional duration in milliseconds for actions with timeouts */ duration?: number | undefined; + /** + * The user ID or email of the organization member who made the decision. The action is recorded as theirs. + */ + moderator?: string | undefined; + /** + * Record an allow or reject decision as a casebook case. Defaults to true when `moderator` is set, else false. Without `moderator`, the case is recorded as System. + */ + createCasebookCase?: boolean | undefined; }; export type ExecuteActionRequest = { @@ -64,6 +72,8 @@ export type ExecuteActionRequestBody$Outbound = { value?: string | undefined; queueId?: string | undefined; duration?: number | undefined; + moderator?: string | undefined; + createCasebookCase?: boolean | undefined; }; /** @internal */ @@ -77,6 +87,8 @@ export const ExecuteActionRequestBody$outboundSchema: z.ZodMiniType< value: z.optional(z.string()), queueId: z.optional(z.string()), duration: z.optional(z.number()), + moderator: z.optional(z.string()), + createCasebookCase: z.optional(z.boolean()), }); export function executeActionRequestBodyToJSON( diff --git a/src/models/operations/index.ts b/src/models/operations/index.ts index 25871d8..ae9bcf3 100644 --- a/src/models/operations/index.ts +++ b/src/models/operations/index.ts @@ -3,6 +3,8 @@ */ export * from "./add-wordlist-words.js"; +export * from "./allow-content.js"; +export * from "./block-author.js"; export * from "./create-action.js"; export * from "./create-author.js"; export * from "./create-channel.js"; @@ -44,10 +46,13 @@ export * from "./list-queue-items.js"; export * from "./list-queues.js"; export * from "./list-webhooks.js"; export * from "./list-wordlists.js"; +export * from "./reject-content.js"; export * from "./remove-wordlist-words.js"; export * from "./resolve-queue-item.js"; export * from "./resolve-queue-items.js"; export * from "./submit-content.js"; +export * from "./suspend-author.js"; +export * from "./unblock-author.js"; export * from "./unresolve-queue-item.js"; export * from "./update-action.js"; export * from "./update-author.js"; diff --git a/src/models/operations/reject-content.ts b/src/models/operations/reject-content.ts new file mode 100644 index 0000000..32ba521 --- /dev/null +++ b/src/models/operations/reject-content.ts @@ -0,0 +1,120 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod/v4-mini"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import * as types from "../../types/primitives.js"; +import { SDKValidationError } from "../errors/sdk-validation-error.js"; + +export type RejectContentRequestBody = { + /** + * Why the action was taken. Saved with the action and sent in the webhook event. + */ + reason?: string | undefined; + /** + * The queue the content is reviewed in. Defaults to the project's default queue. + */ + queueId?: string | undefined; + /** + * The user ID or email of the organization member who made the decision. The action is recorded as theirs. + */ + moderator?: string | undefined; + /** + * Record an allow or reject decision as a casebook case. Defaults to true when `moderator` is set, else false. Without `moderator`, the case is recorded as System. + */ + createCasebookCase?: boolean | undefined; +}; + +export type RejectContentRequest = { + /** + * The content ID you sent when you submitted the content, or the ID Moderation API assigned. + */ + id: string; + /** + * The project to act on, by ID or name. Required with an organization key unless the key reaches only one project; list projects with GET /projects. A project key acts on its own project and needs no value: naming another one is an error. + */ + projectId?: string | undefined; + body: RejectContentRequestBody; +}; + +/** + * Execution result + */ +export type RejectContentResponse = { + /** + * Whether the action was executed successfully + */ + success: boolean; +}; + +/** @internal */ +export type RejectContentRequestBody$Outbound = { + reason?: string | undefined; + queueId?: string | undefined; + moderator?: string | undefined; + createCasebookCase?: boolean | undefined; +}; + +/** @internal */ +export const RejectContentRequestBody$outboundSchema: z.ZodMiniType< + RejectContentRequestBody$Outbound, + RejectContentRequestBody +> = z.object({ + reason: z.optional(z.string()), + queueId: z.optional(z.string()), + moderator: z.optional(z.string()), + createCasebookCase: z.optional(z.boolean()), +}); + +export function rejectContentRequestBodyToJSON( + rejectContentRequestBody: RejectContentRequestBody, +): string { + return JSON.stringify( + RejectContentRequestBody$outboundSchema.parse(rejectContentRequestBody), + ); +} + +/** @internal */ +export type RejectContentRequest$Outbound = { + id: string; + projectId?: string | undefined; + body: RejectContentRequestBody$Outbound; +}; + +/** @internal */ +export const RejectContentRequest$outboundSchema: z.ZodMiniType< + RejectContentRequest$Outbound, + RejectContentRequest +> = z.object({ + id: z.string(), + projectId: z.optional(z.string()), + body: z.lazy(() => RejectContentRequestBody$outboundSchema), +}); + +export function rejectContentRequestToJSON( + rejectContentRequest: RejectContentRequest, +): string { + return JSON.stringify( + RejectContentRequest$outboundSchema.parse(rejectContentRequest), + ); +} + +/** @internal */ +export const RejectContentResponse$inboundSchema: z.ZodMiniType< + RejectContentResponse, + unknown +> = z.object({ + success: types.boolean(), +}); + +export function rejectContentResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => RejectContentResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'RejectContentResponse' from JSON`, + ); +} diff --git a/src/models/operations/suspend-author.ts b/src/models/operations/suspend-author.ts new file mode 100644 index 0000000..a91f46d --- /dev/null +++ b/src/models/operations/suspend-author.ts @@ -0,0 +1,108 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod/v4-mini"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import * as types from "../../types/primitives.js"; +import { SDKValidationError } from "../errors/sdk-validation-error.js"; + +export type SuspendAuthorRequestBody = { + /** + * Why the action was taken. Saved with the action and sent in the webhook event. + */ + reason?: string | undefined; + /** + * How long the suspension lasts, in milliseconds. Defaults to 24 hours. + */ + duration?: number | undefined; +}; + +export type SuspendAuthorRequest = { + /** + * Either external ID or the ID assigned by moderation API. + */ + id: string; + /** + * The project to act on, by ID or name. Required with an organization key unless the key reaches only one project; list projects with GET /projects. A project key acts on its own project and needs no value: naming another one is an error. + */ + projectId?: string | undefined; + body: SuspendAuthorRequestBody; +}; + +/** + * Execution result + */ +export type SuspendAuthorResponse = { + /** + * Whether the action was executed successfully + */ + success: boolean; +}; + +/** @internal */ +export type SuspendAuthorRequestBody$Outbound = { + reason?: string | undefined; + duration?: number | undefined; +}; + +/** @internal */ +export const SuspendAuthorRequestBody$outboundSchema: z.ZodMiniType< + SuspendAuthorRequestBody$Outbound, + SuspendAuthorRequestBody +> = z.object({ + reason: z.optional(z.string()), + duration: z.optional(z.number()), +}); + +export function suspendAuthorRequestBodyToJSON( + suspendAuthorRequestBody: SuspendAuthorRequestBody, +): string { + return JSON.stringify( + SuspendAuthorRequestBody$outboundSchema.parse(suspendAuthorRequestBody), + ); +} + +/** @internal */ +export type SuspendAuthorRequest$Outbound = { + id: string; + projectId?: string | undefined; + body: SuspendAuthorRequestBody$Outbound; +}; + +/** @internal */ +export const SuspendAuthorRequest$outboundSchema: z.ZodMiniType< + SuspendAuthorRequest$Outbound, + SuspendAuthorRequest +> = z.object({ + id: z.string(), + projectId: z.optional(z.string()), + body: z.lazy(() => SuspendAuthorRequestBody$outboundSchema), +}); + +export function suspendAuthorRequestToJSON( + suspendAuthorRequest: SuspendAuthorRequest, +): string { + return JSON.stringify( + SuspendAuthorRequest$outboundSchema.parse(suspendAuthorRequest), + ); +} + +/** @internal */ +export const SuspendAuthorResponse$inboundSchema: z.ZodMiniType< + SuspendAuthorResponse, + unknown +> = z.object({ + success: types.boolean(), +}); + +export function suspendAuthorResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => SuspendAuthorResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'SuspendAuthorResponse' from JSON`, + ); +} diff --git a/src/models/operations/unblock-author.ts b/src/models/operations/unblock-author.ts new file mode 100644 index 0000000..05ff353 --- /dev/null +++ b/src/models/operations/unblock-author.ts @@ -0,0 +1,102 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod/v4-mini"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import * as types from "../../types/primitives.js"; +import { SDKValidationError } from "../errors/sdk-validation-error.js"; + +export type UnblockAuthorRequestBody = { + /** + * Why the action was taken. Saved with the action and sent in the webhook event. + */ + reason?: string | undefined; +}; + +export type UnblockAuthorRequest = { + /** + * Either external ID or the ID assigned by moderation API. + */ + id: string; + /** + * The project to act on, by ID or name. Required with an organization key unless the key reaches only one project; list projects with GET /projects. A project key acts on its own project and needs no value: naming another one is an error. + */ + projectId?: string | undefined; + body: UnblockAuthorRequestBody; +}; + +/** + * Execution result + */ +export type UnblockAuthorResponse = { + /** + * Whether the action was executed successfully + */ + success: boolean; +}; + +/** @internal */ +export type UnblockAuthorRequestBody$Outbound = { + reason?: string | undefined; +}; + +/** @internal */ +export const UnblockAuthorRequestBody$outboundSchema: z.ZodMiniType< + UnblockAuthorRequestBody$Outbound, + UnblockAuthorRequestBody +> = z.object({ + reason: z.optional(z.string()), +}); + +export function unblockAuthorRequestBodyToJSON( + unblockAuthorRequestBody: UnblockAuthorRequestBody, +): string { + return JSON.stringify( + UnblockAuthorRequestBody$outboundSchema.parse(unblockAuthorRequestBody), + ); +} + +/** @internal */ +export type UnblockAuthorRequest$Outbound = { + id: string; + projectId?: string | undefined; + body: UnblockAuthorRequestBody$Outbound; +}; + +/** @internal */ +export const UnblockAuthorRequest$outboundSchema: z.ZodMiniType< + UnblockAuthorRequest$Outbound, + UnblockAuthorRequest +> = z.object({ + id: z.string(), + projectId: z.optional(z.string()), + body: z.lazy(() => UnblockAuthorRequestBody$outboundSchema), +}); + +export function unblockAuthorRequestToJSON( + unblockAuthorRequest: UnblockAuthorRequest, +): string { + return JSON.stringify( + UnblockAuthorRequest$outboundSchema.parse(unblockAuthorRequest), + ); +} + +/** @internal */ +export const UnblockAuthorResponse$inboundSchema: z.ZodMiniType< + UnblockAuthorResponse, + unknown +> = z.object({ + success: types.boolean(), +}); + +export function unblockAuthorResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => UnblockAuthorResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'UnblockAuthorResponse' from JSON`, + ); +} diff --git a/src/sdk/authors.ts b/src/sdk/authors.ts index ff9f59d..b71f1f5 100644 --- a/src/sdk/authors.ts +++ b/src/sdk/authors.ts @@ -2,10 +2,13 @@ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import { authorsBlock } from "../funcs/authors-block.js"; import { authorsCreate } from "../funcs/authors-create.js"; import { authorsDelete } from "../funcs/authors-delete.js"; import { authorsList } from "../funcs/authors-list.js"; import { authorsRetrieve } from "../funcs/authors-retrieve.js"; +import { authorsSuspend } from "../funcs/authors-suspend.js"; +import { authorsUnblock } from "../funcs/authors-unblock.js"; import { authorsUpdate } from "../funcs/authors-update.js"; import { ClientSDK, RequestOptions } from "../lib/sdks.js"; import * as models from "../models/index.js"; @@ -108,4 +111,67 @@ export class Authors extends ClientSDK { options, )); } + + /** + * Block author + * + * @remarks + * Block an author with the built-in block action. A blocked author cannot post new content until unblocked. + */ + async block( + id: string, + body: operations.BlockAuthorRequestBody, + projectId?: string | undefined, + options?: RequestOptions, + ): Promise { + return unwrapAsync(authorsBlock( + this, + id, + body, + projectId, + options, + )); + } + + /** + * Suspend author + * + * @remarks + * Block an author for a limited time with the built-in suspend action. + */ + async suspend( + id: string, + body: operations.SuspendAuthorRequestBody, + projectId?: string | undefined, + options?: RequestOptions, + ): Promise { + return unwrapAsync(authorsSuspend( + this, + id, + body, + projectId, + options, + )); + } + + /** + * Unblock author + * + * @remarks + * Unblock a blocked or suspended author with the built-in unblock action, so they can post new content again. + */ + async unblock( + id: string, + body: operations.UnblockAuthorRequestBody, + projectId?: string | undefined, + options?: RequestOptions, + ): Promise { + return unwrapAsync(authorsUnblock( + this, + id, + body, + projectId, + options, + )); + } } diff --git a/src/sdk/content.ts b/src/sdk/content.ts index 6bfb9f2..67d84e6 100644 --- a/src/sdk/content.ts +++ b/src/sdk/content.ts @@ -2,12 +2,56 @@ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import { contentAllow } from "../funcs/content-allow.js"; +import { contentReject } from "../funcs/content-reject.js"; import { contentSubmit } from "../funcs/content-submit.js"; import { ClientSDK, RequestOptions } from "../lib/sdks.js"; import * as operations from "../models/operations/index.js"; import { unwrapAsync } from "../types/fp.js"; export class Content extends ClientSDK { + /** + * Reject content + * + * @remarks + * Reject a content item with the built-in reject action, and resolve it in the review queue. + */ + async reject( + id: string, + body: operations.RejectContentRequestBody, + projectId?: string | undefined, + options?: RequestOptions, + ): Promise { + return unwrapAsync(contentReject( + this, + id, + body, + projectId, + options, + )); + } + + /** + * Allow content + * + * @remarks + * Allow a content item with the built-in allow action, and resolve it in the review queue. + */ + async allow( + id: string, + body: operations.AllowContentRequestBody, + projectId?: string | undefined, + options?: RequestOptions, + ): Promise { + return unwrapAsync(contentAllow( + this, + id, + body, + projectId, + options, + )); + } + /** * Submit content */ diff --git a/src/sdk/sdk.ts b/src/sdk/sdk.ts index fbcb901..1841d22 100644 --- a/src/sdk/sdk.ts +++ b/src/sdk/sdk.ts @@ -42,6 +42,11 @@ export class ModerationApi extends ClientSDK { return (this._actions ??= new Actions(this._options)); } + private _content?: Content; + get content(): Content { + return (this._content ??= new Content(this._options)); + } + private _webhooks?: Webhooks; get webhooks(): Webhooks { return (this._webhooks ??= new Webhooks(this._options)); @@ -62,11 +67,6 @@ export class ModerationApi extends ClientSDK { return (this._wordlist ??= new Wordlist(this._options)); } - private _content?: Content; - get content(): Content { - return (this._content ??= new Content(this._options)); - } - private _projects?: Projects; get projects(): Projects { return (this._projects ??= new Projects(this._options));