diff --git a/src/api-client.ts b/src/api-client.ts index 4e4218a8b..19ee3c129 100644 --- a/src/api-client.ts +++ b/src/api-client.ts @@ -54,7 +54,7 @@ export class ApiClient { async sendRequest( method: Method, url: string, - pathParams?: Record, + pathParams?: Record, queryParams?: Record, body?: unknown, requestContentType?: string, @@ -108,7 +108,7 @@ export class ApiClient { return this._doRequest('delete', url, null, { params }).then((r) => r.body); } - private resolveUrl(url: string, pathParams?: Record): string { + private resolveUrl(url: string, pathParams?: Record): string { let resolved = url; if (pathParams) { for (const [key, value] of Object.entries(pathParams)) { diff --git a/src/gen/models/index.ts b/src/gen/models/index.ts index 8dbeae6db..0d60df901 100644 --- a/src/gen/models/index.ts +++ b/src/gen/models/index.ts @@ -2698,6 +2698,10 @@ export interface ConfigResponse { */ updated_at: TimestampNS; supported_video_call_harm_types: Array; + /** + * The version of this configuration moderation currently runs + */ + published_version?: number; /** * Configurable image moderation label definitions for dashboard rendering */ @@ -2726,6 +2730,25 @@ export interface ConfigResponse { video_call_rule_config?: VideoCallRuleConfig; } +export interface ConfigVersionResponse { + /** + * When this version was saved + */ + created_at: TimestampNS; + /** + * ID of the user who saved this version, empty when saved without a user + */ + created_by: string; + /** + * Whether this is the version moderation currently runs + */ + published: boolean; + /** + * Sequential version number, per key and team + */ + version: number; +} + export interface ConnectUserDetailsRequest { id: string; image?: string; @@ -4140,6 +4163,12 @@ export interface GetConfigResponse { config?: ConfigResponse; } +export interface GetConfigVersionResponse { + duration: string; + version: ConfigVersionResponse; + config?: ConfigResponse; +} + export interface GetDraftResponse { /** * Duration of the request in milliseconds @@ -4577,6 +4606,18 @@ export interface ListBlockListResponse { next_cursor?: string; } +export interface ListConfigVersionsResponse { + duration: string; + /** + * Retained versions of this configuration, newest first, including the published one + */ + versions: Array; + /** + * The version moderation currently runs + */ + published_version?: number; +} + export interface ListDevicesResponse { duration: string; /** @@ -7163,6 +7204,18 @@ export interface PrivacySettingsResponse { typing_indicators?: TypingIndicatorsResponse; } +export interface PublishConfigVersionRequest { + /** + * Team associated with the configuration + */ + team?: string; +} + +export interface PublishConfigVersionResponse { + duration: string; + config?: ConfigResponse; +} + export type PushLevel = 'all' | 'all_mentions' | 'mentions' | 'direct_mentions' | 'none'; export interface PushPreferenceInput { @@ -9664,6 +9717,52 @@ export interface RuleBuilderRule { action?: RuleBuilderAction; } +export interface SaveConfigVersionRequest { + /** + * Latest version the edit was based on, 0 for a policy without versions. The save is rejected when a newer version exists + */ + base_version: number; + /** + * Unique identifier for the moderation configuration + */ + key: string; + /** + * Whether moderation should be performed asynchronously + */ + async?: boolean; + /** + * Team associated with the configuration + */ + team?: string; + ai_audio_config?: AIAudioConfigRequest; + ai_image_config?: AIImageConfig; + ai_text_config?: AITextConfig; + ai_video_config?: AIVideoConfigRequest; + automod_platform_circumvention_config?: AutomodPlatformCircumventionConfig; + automod_semantic_filters_config?: AutomodSemanticFiltersConfig; + automod_toxicity_config?: AutomodToxicityConfig; + aws_rekognition_config?: AIImageConfig; + block_list_config?: BlockListConfig; + bodyguard_config?: AITextConfig; + engine?: ModerationEngineConfigRequest; + flood_config?: FloodConfig; + google_vision_config?: GoogleVisionConfig; + intent_config?: IntentConfigRequest; + llm_config?: LLMConfig; + rule_builder_config?: RuleBuilderConfig; + velocity_filter_config?: VelocityFilterConfig; + video_call_rule_config?: VideoCallRuleConfig; +} + +export interface SaveConfigVersionResponse { + duration: string; + version: ConfigVersionResponse; + /** + * The version moderation currently runs + */ + published_version?: number; +} + export interface ScheduledMessageChannelResponse { /** * Channel CID (:) @@ -11841,6 +11940,10 @@ export interface UserBannedEvent { * The type of event: "user.banned" in this case */ type: string; + /** + * Whether the ban also applies to channels created later by the same creator. Without a channel, check user.banned to tell a global ban from a future-channels-only ban + */ + ban_from_future_channels?: boolean; /** * The ID of the channel where the target user was banned */ diff --git a/src/gen/moderation/ModerationApi.ts b/src/gen/moderation/ModerationApi.ts index 78e52f586..e982f72c3 100644 --- a/src/gen/moderation/ModerationApi.ts +++ b/src/gen/moderation/ModerationApi.ts @@ -18,10 +18,14 @@ import type { GetActionConfigResponse, GetAppealResponse, GetConfigResponse, + GetConfigVersionResponse, + ListConfigVersionsResponse, ListQueuesResponse, ModerationBanResponse, MuteRequest, MuteResponse, + PublishConfigVersionRequest, + PublishConfigVersionResponse, QueryAppealsRequest, QueryAppealsResponse, QueryModerationConfigsRequest, @@ -31,6 +35,8 @@ import type { QueueResponse, RevealMediaRequest, RevealMediaResponse, + SaveConfigVersionRequest, + SaveConfigVersionResponse, SubmitActionRequest, SubmitActionResponse, UnbanRequest, @@ -219,6 +225,21 @@ export class ModerationApi { ); } + saveConfigVersion( + request: SaveConfigVersionRequest, + requestOptions?: StreamRequestOptions, + ): Promise> { + return this.apiClient.sendRequest( + 'POST', + '/api/v2/moderation/config/versions', + undefined, + undefined, + request, + 'application/json', + requestOptions, + ); + } + deleteConfig( pathParams: { key: string }, request?: { team?: string }, @@ -251,6 +272,54 @@ export class ModerationApi { ); } + listConfigVersions( + pathParams: { key: string }, + request?: { team?: string }, + requestOptions?: StreamRequestOptions, + ): Promise> { + return this.apiClient.sendRequest( + 'GET', + '/api/v2/moderation/config/{key}/versions', + pathParams, + request, + undefined, + undefined, + requestOptions, + ); + } + + getConfigVersion( + pathParams: { key: string; version: number }, + request?: { team?: string }, + requestOptions?: StreamRequestOptions, + ): Promise> { + return this.apiClient.sendRequest( + 'GET', + '/api/v2/moderation/config/{key}/versions/{version}', + pathParams, + request, + undefined, + undefined, + requestOptions, + ); + } + + publishConfigVersion( + pathParams: { key: string; version: number }, + request?: PublishConfigVersionRequest, + requestOptions?: StreamRequestOptions, + ): Promise> { + return this.apiClient.sendRequest( + 'POST', + '/api/v2/moderation/config/{key}/versions/{version}/publish', + pathParams, + undefined, + request ?? {}, + 'application/json', + requestOptions, + ); + } + queryModerationConfigs( request?: QueryModerationConfigsRequest, requestOptions?: StreamRequestOptions,