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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class ApiClient {
async sendRequest<T>(
method: Method,
url: string,
pathParams?: Record<string, string>,
pathParams?: Record<string, string | number>,
queryParams?: Record<string, unknown>,
body?: unknown,
requestContentType?: string,
Expand Down Expand Up @@ -108,7 +108,7 @@ export class ApiClient {
return this._doRequest<T>('delete', url, null, { params }).then((r) => r.body);
}

private resolveUrl(url: string, pathParams?: Record<string, string>): string {
private resolveUrl(url: string, pathParams?: Record<string, string | number>): string {
let resolved = url;
if (pathParams) {
for (const [key, value] of Object.entries(pathParams)) {
Expand Down
103 changes: 103 additions & 0 deletions src/gen/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2698,6 +2698,10 @@ export interface ConfigResponse {
*/
updated_at: TimestampNS;
supported_video_call_harm_types: Array<string>;
/**
* The version of this configuration moderation currently runs
*/
published_version?: number;
/**
* Configurable image moderation label definitions for dashboard rendering
*/
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<ConfigVersionResponse>;
/**
* The version moderation currently runs
*/
published_version?: number;
}

export interface ListDevicesResponse {
duration: string;
/**
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 (<type>:<id>)
Expand Down Expand Up @@ -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
*/
Expand Down
69 changes: 69 additions & 0 deletions src/gen/moderation/ModerationApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@ import type {
GetActionConfigResponse,
GetAppealResponse,
GetConfigResponse,
GetConfigVersionResponse,
ListConfigVersionsResponse,
ListQueuesResponse,
ModerationBanResponse,
MuteRequest,
MuteResponse,
PublishConfigVersionRequest,
PublishConfigVersionResponse,
QueryAppealsRequest,
QueryAppealsResponse,
QueryModerationConfigsRequest,
Expand All @@ -31,6 +35,8 @@ import type {
QueueResponse,
RevealMediaRequest,
RevealMediaResponse,
SaveConfigVersionRequest,
SaveConfigVersionResponse,
SubmitActionRequest,
SubmitActionResponse,
UnbanRequest,
Expand Down Expand Up @@ -219,6 +225,21 @@ export class ModerationApi {
);
}

saveConfigVersion(
request: SaveConfigVersionRequest,
requestOptions?: StreamRequestOptions,
): Promise<StreamResponse<SaveConfigVersionResponse>> {
return this.apiClient.sendRequest<SaveConfigVersionResponse>(
'POST',
'/api/v2/moderation/config/versions',
undefined,
undefined,
request,
'application/json',
requestOptions,
);
}

deleteConfig(
pathParams: { key: string },
request?: { team?: string },
Expand Down Expand Up @@ -251,6 +272,54 @@ export class ModerationApi {
);
}

listConfigVersions(
pathParams: { key: string },
request?: { team?: string },
requestOptions?: StreamRequestOptions,
): Promise<StreamResponse<ListConfigVersionsResponse>> {
return this.apiClient.sendRequest<ListConfigVersionsResponse>(
'GET',
'/api/v2/moderation/config/{key}/versions',
pathParams,
request,
undefined,
undefined,
requestOptions,
);
}

getConfigVersion(
pathParams: { key: string; version: number },
request?: { team?: string },
requestOptions?: StreamRequestOptions,
): Promise<StreamResponse<GetConfigVersionResponse>> {
return this.apiClient.sendRequest<GetConfigVersionResponse>(
'GET',
'/api/v2/moderation/config/{key}/versions/{version}',
pathParams,
request,
undefined,
undefined,
requestOptions,
);
}

publishConfigVersion(
pathParams: { key: string; version: number },
request?: PublishConfigVersionRequest,
requestOptions?: StreamRequestOptions,
): Promise<StreamResponse<PublishConfigVersionResponse>> {
return this.apiClient.sendRequest<PublishConfigVersionResponse>(
'POST',
'/api/v2/moderation/config/{key}/versions/{version}/publish',
pathParams,
undefined,
request ?? {},
'application/json',
requestOptions,
);
}

queryModerationConfigs(
request?: QueryModerationConfigsRequest,
requestOptions?: StreamRequestOptions,
Expand Down
Loading