stream-chat 9.17.0 → 9.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.browser.cjs +57 -9
- package/dist/cjs/index.browser.cjs.map +2 -2
- package/dist/cjs/index.node.cjs +57 -9
- package/dist/cjs/index.node.cjs.map +2 -2
- package/dist/esm/index.js +57 -9
- package/dist/esm/index.js.map +2 -2
- package/dist/types/moderation.d.ts +29 -1
- package/dist/types/types.d.ts +140 -0
- package/package.json +1 -1
- package/src/moderation.ts +62 -0
- package/src/types.ts +168 -0
- package/src/utils.ts +8 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { APIResponse, CustomCheckFlag, GetConfigResponse, GetUserModerationReportOptions, GetUserModerationReportResponse, ModerationConfig, ModerationFlagOptions, ModerationMuteOptions, Pager, QueryConfigsResponse, QueryModerationConfigsFilters, QueryModerationConfigsSort, RequireAtLeastOne, ReviewQueueFilters, ReviewQueueItem, ReviewQueuePaginationOptions, ReviewQueueResponse, ReviewQueueSort, SubmitActionOptions, UpsertConfigResponse } from './types';
|
|
1
|
+
import type { APIResponse, CustomCheckFlag, GetConfigResponse, GetUserModerationReportOptions, GetUserModerationReportResponse, ModerationConfig, ModerationFlagOptions, ModerationMuteOptions, ModerationRule, ModerationRuleRequest, Pager, QueryConfigsResponse, QueryModerationConfigsFilters, QueryModerationConfigsSort, QueryModerationRulesFilters, QueryModerationRulesResponse, QueryModerationRulesSort, RequireAtLeastOne, ReviewQueueFilters, ReviewQueueItem, ReviewQueuePaginationOptions, ReviewQueueResponse, ReviewQueueSort, SubmitActionOptions, UpsertConfigResponse, UpsertModerationRuleResponse } from './types';
|
|
2
2
|
import type { StreamChat } from './client';
|
|
3
3
|
export declare const MODERATION_ENTITY_TYPES: {
|
|
4
4
|
user: string;
|
|
@@ -199,4 +199,32 @@ export declare class Moderation {
|
|
|
199
199
|
item: ReviewQueueItem;
|
|
200
200
|
status: string;
|
|
201
201
|
} & APIResponse>;
|
|
202
|
+
/**
|
|
203
|
+
* Create or update a moderation rule
|
|
204
|
+
* @param {ModerationRuleRequest} rule Rule configuration to be upserted
|
|
205
|
+
* @returns
|
|
206
|
+
*/
|
|
207
|
+
upsertModerationRule(rule: ModerationRuleRequest): Promise<UpsertModerationRuleResponse>;
|
|
208
|
+
/**
|
|
209
|
+
* Query moderation rules
|
|
210
|
+
* @param {QueryModerationRulesFilters} filterConditions Filter conditions for querying moderation rules
|
|
211
|
+
* @param {QueryModerationRulesSort} sort Sort conditions for querying moderation rules
|
|
212
|
+
* @param {Pager} options Pagination options for querying moderation rules
|
|
213
|
+
* @returns
|
|
214
|
+
*/
|
|
215
|
+
queryModerationRules(filterConditions?: QueryModerationRulesFilters, sort?: QueryModerationRulesSort, options?: Pager): Promise<QueryModerationRulesResponse>;
|
|
216
|
+
/**
|
|
217
|
+
* Get a specific moderation rule by ID
|
|
218
|
+
* @param {string} id ID of the moderation rule to fetch
|
|
219
|
+
* @returns
|
|
220
|
+
*/
|
|
221
|
+
getModerationRule(id: string): Promise<{
|
|
222
|
+
rule: ModerationRule;
|
|
223
|
+
}>;
|
|
224
|
+
/**
|
|
225
|
+
* Delete a moderation rule by ID
|
|
226
|
+
* @param {string} id ID of the moderation rule to delete
|
|
227
|
+
* @returns
|
|
228
|
+
*/
|
|
229
|
+
deleteModerationRule(id: string): Promise<unknown>;
|
|
202
230
|
}
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1726,6 +1726,7 @@ export type AppSettings = {
|
|
|
1726
1726
|
disable_permissions_checks?: boolean;
|
|
1727
1727
|
enforce_unique_usernames?: 'no' | 'app' | 'team';
|
|
1728
1728
|
event_hooks?: Array<EventHook> | null;
|
|
1729
|
+
explicit_event_hooks_deletion?: boolean;
|
|
1729
1730
|
file_upload_config?: FileUploadConfig;
|
|
1730
1731
|
firebase_config?: {
|
|
1731
1732
|
apn_template?: string;
|
|
@@ -2753,6 +2754,143 @@ export type QueryConfigsResponse = {
|
|
|
2753
2754
|
export type UpsertConfigResponse = {
|
|
2754
2755
|
config: ModerationConfigResponse;
|
|
2755
2756
|
};
|
|
2757
|
+
export type ModerationRule = {
|
|
2758
|
+
id: string;
|
|
2759
|
+
name: string;
|
|
2760
|
+
description: string;
|
|
2761
|
+
config_keys: string[];
|
|
2762
|
+
team: string;
|
|
2763
|
+
rule: RuleBuilderRule;
|
|
2764
|
+
enabled: boolean;
|
|
2765
|
+
created_at: string;
|
|
2766
|
+
updated_at: string;
|
|
2767
|
+
};
|
|
2768
|
+
export type ModerationRuleRequest = {
|
|
2769
|
+
name: string;
|
|
2770
|
+
description: string;
|
|
2771
|
+
config_keys: string[];
|
|
2772
|
+
team: string;
|
|
2773
|
+
rule: RuleBuilderRule;
|
|
2774
|
+
enabled: boolean;
|
|
2775
|
+
};
|
|
2776
|
+
export type RuleBuilderRule = {
|
|
2777
|
+
id: string;
|
|
2778
|
+
rule_type: 'user' | 'content';
|
|
2779
|
+
conditions?: RuleBuilderCondition[];
|
|
2780
|
+
logic?: 'AND' | 'OR';
|
|
2781
|
+
groups?: RuleBuilderConditionGroup[];
|
|
2782
|
+
action: RuleBuilderAction;
|
|
2783
|
+
cooldown_period?: string;
|
|
2784
|
+
};
|
|
2785
|
+
export type RuleBuilderCondition = {
|
|
2786
|
+
type: string;
|
|
2787
|
+
confidence?: number;
|
|
2788
|
+
text_rule_params?: TextRuleParameters;
|
|
2789
|
+
image_rule_params?: ImageRuleParameters;
|
|
2790
|
+
video_rule_params?: VideoRuleParameters;
|
|
2791
|
+
user_rule_params?: UserRuleParameters;
|
|
2792
|
+
content_count_rule_params?: ContentCountRuleParameters;
|
|
2793
|
+
text_content_params?: TextContentParameters;
|
|
2794
|
+
image_content_params?: ImageContentParameters;
|
|
2795
|
+
video_content_params?: VideoContentParameters;
|
|
2796
|
+
user_created_within_params?: UserCreatedWithinParameters;
|
|
2797
|
+
user_custom_property_params?: UserCustomPropertyParameters;
|
|
2798
|
+
};
|
|
2799
|
+
export type RuleBuilderConditionGroup = {
|
|
2800
|
+
logic: 'AND' | 'OR';
|
|
2801
|
+
conditions: RuleBuilderCondition[];
|
|
2802
|
+
};
|
|
2803
|
+
export type RuleBuilderAction = {
|
|
2804
|
+
type: string;
|
|
2805
|
+
ban_options?: BanOptions;
|
|
2806
|
+
flag_user_options?: FlagUserOptions;
|
|
2807
|
+
flag_content_options?: FlagContentOptions;
|
|
2808
|
+
remove_content_options?: RemoveContentOptions;
|
|
2809
|
+
shadow_content_options?: ShadowContentOptions;
|
|
2810
|
+
};
|
|
2811
|
+
export type TextRuleParameters = {
|
|
2812
|
+
threshold: number;
|
|
2813
|
+
time_window: string;
|
|
2814
|
+
harm_labels?: string[];
|
|
2815
|
+
llm_harm_labels?: Record<string, string>;
|
|
2816
|
+
contains_url?: boolean;
|
|
2817
|
+
severity?: string;
|
|
2818
|
+
blocklist_match?: string[];
|
|
2819
|
+
};
|
|
2820
|
+
export type ImageRuleParameters = {
|
|
2821
|
+
threshold: number;
|
|
2822
|
+
time_window: string;
|
|
2823
|
+
harm_labels: string[];
|
|
2824
|
+
};
|
|
2825
|
+
export type VideoRuleParameters = {
|
|
2826
|
+
threshold: number;
|
|
2827
|
+
time_window: string;
|
|
2828
|
+
harm_labels: string[];
|
|
2829
|
+
};
|
|
2830
|
+
export type UserRuleParameters = {
|
|
2831
|
+
max_age: string;
|
|
2832
|
+
};
|
|
2833
|
+
export type ContentCountRuleParameters = {
|
|
2834
|
+
threshold: number;
|
|
2835
|
+
time_window: string;
|
|
2836
|
+
};
|
|
2837
|
+
export type TextContentParameters = {
|
|
2838
|
+
harm_labels?: string[];
|
|
2839
|
+
llm_harm_labels?: Record<string, string>;
|
|
2840
|
+
contains_url?: boolean;
|
|
2841
|
+
severity?: string;
|
|
2842
|
+
blocklist_match?: string[];
|
|
2843
|
+
};
|
|
2844
|
+
export type ImageContentParameters = {
|
|
2845
|
+
harm_labels: string[];
|
|
2846
|
+
};
|
|
2847
|
+
export type VideoContentParameters = {
|
|
2848
|
+
harm_labels: string[];
|
|
2849
|
+
};
|
|
2850
|
+
export type UserCreatedWithinParameters = {
|
|
2851
|
+
max_age: string;
|
|
2852
|
+
};
|
|
2853
|
+
export type UserCustomPropertyParameters = {
|
|
2854
|
+
property_key: string;
|
|
2855
|
+
operator: string;
|
|
2856
|
+
expected_value: string;
|
|
2857
|
+
};
|
|
2858
|
+
export type BanOptions = {
|
|
2859
|
+
duration: number;
|
|
2860
|
+
reason: string;
|
|
2861
|
+
shadow_ban: boolean;
|
|
2862
|
+
ip_ban: boolean;
|
|
2863
|
+
};
|
|
2864
|
+
export type FlagUserOptions = {
|
|
2865
|
+
reason: string;
|
|
2866
|
+
};
|
|
2867
|
+
export type FlagContentOptions = {
|
|
2868
|
+
reason: string;
|
|
2869
|
+
};
|
|
2870
|
+
export type RemoveContentOptions = {
|
|
2871
|
+
reason: string;
|
|
2872
|
+
};
|
|
2873
|
+
export type ShadowContentOptions = {
|
|
2874
|
+
reason: string;
|
|
2875
|
+
};
|
|
2876
|
+
export type QueryModerationRulesFilters = QueryFilters<{
|
|
2877
|
+
name?: string;
|
|
2878
|
+
team?: string;
|
|
2879
|
+
enabled?: boolean;
|
|
2880
|
+
rule_type?: string;
|
|
2881
|
+
created_at?: PrimitiveFilter<string>;
|
|
2882
|
+
updated_at?: PrimitiveFilter<string>;
|
|
2883
|
+
}>;
|
|
2884
|
+
export type QueryModerationRulesSort = Array<Sort<'name' | 'enabled' | 'team' | 'created_at' | 'updated_at'>>;
|
|
2885
|
+
export type QueryModerationRulesResponse = {
|
|
2886
|
+
rules: ModerationRule[];
|
|
2887
|
+
default_llm_labels: Record<string, string>;
|
|
2888
|
+
next?: string;
|
|
2889
|
+
prev?: string;
|
|
2890
|
+
};
|
|
2891
|
+
export type UpsertModerationRuleResponse = {
|
|
2892
|
+
rule: ModerationRule;
|
|
2893
|
+
};
|
|
2756
2894
|
export type ModerationFlagOptions = {
|
|
2757
2895
|
custom?: Record<string, unknown>;
|
|
2758
2896
|
moderation_payload?: ModerationPayload;
|
|
@@ -3049,6 +3187,7 @@ export type EventHook = {
|
|
|
3049
3187
|
id?: string;
|
|
3050
3188
|
hook_type?: HookType;
|
|
3051
3189
|
enabled?: boolean;
|
|
3190
|
+
product?: Product | 'all';
|
|
3052
3191
|
event_types?: Array<string>;
|
|
3053
3192
|
webhook_url?: string;
|
|
3054
3193
|
sqs_queue_url?: string;
|
|
@@ -3067,6 +3206,7 @@ export type EventHook = {
|
|
|
3067
3206
|
callback?: {
|
|
3068
3207
|
mode: 'CALLBACK_MODE_NONE' | 'CALLBACK_MODE_REST' | 'CALLBACK_MODE_TWIRP';
|
|
3069
3208
|
};
|
|
3209
|
+
delete?: boolean;
|
|
3070
3210
|
created_at?: string;
|
|
3071
3211
|
updated_at?: string;
|
|
3072
3212
|
};
|
package/package.json
CHANGED
package/src/moderation.ts
CHANGED
|
@@ -7,11 +7,16 @@ import type {
|
|
|
7
7
|
ModerationConfig,
|
|
8
8
|
ModerationFlagOptions,
|
|
9
9
|
ModerationMuteOptions,
|
|
10
|
+
ModerationRule,
|
|
11
|
+
ModerationRuleRequest,
|
|
10
12
|
MuteUserResponse,
|
|
11
13
|
Pager,
|
|
12
14
|
QueryConfigsResponse,
|
|
13
15
|
QueryModerationConfigsFilters,
|
|
14
16
|
QueryModerationConfigsSort,
|
|
17
|
+
QueryModerationRulesFilters,
|
|
18
|
+
QueryModerationRulesResponse,
|
|
19
|
+
QueryModerationRulesSort,
|
|
15
20
|
RequireAtLeastOne,
|
|
16
21
|
ReviewQueueFilters,
|
|
17
22
|
ReviewQueueItem,
|
|
@@ -20,6 +25,7 @@ import type {
|
|
|
20
25
|
ReviewQueueSort,
|
|
21
26
|
SubmitActionOptions,
|
|
22
27
|
UpsertConfigResponse,
|
|
28
|
+
UpsertModerationRuleResponse,
|
|
23
29
|
} from './types';
|
|
24
30
|
import type { StreamChat } from './client';
|
|
25
31
|
import { normalizeQuerySort } from './utils';
|
|
@@ -388,4 +394,60 @@ export class Moderation {
|
|
|
388
394
|
flags,
|
|
389
395
|
);
|
|
390
396
|
}
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* Create or update a moderation rule
|
|
400
|
+
* @param {ModerationRuleRequest} rule Rule configuration to be upserted
|
|
401
|
+
* @returns
|
|
402
|
+
*/
|
|
403
|
+
async upsertModerationRule(rule: ModerationRuleRequest) {
|
|
404
|
+
return await this.client.post<UpsertModerationRuleResponse>(
|
|
405
|
+
this.client.baseURL + '/api/v2/moderation/moderation_rule',
|
|
406
|
+
rule,
|
|
407
|
+
);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* Query moderation rules
|
|
412
|
+
* @param {QueryModerationRulesFilters} filterConditions Filter conditions for querying moderation rules
|
|
413
|
+
* @param {QueryModerationRulesSort} sort Sort conditions for querying moderation rules
|
|
414
|
+
* @param {Pager} options Pagination options for querying moderation rules
|
|
415
|
+
* @returns
|
|
416
|
+
*/
|
|
417
|
+
async queryModerationRules(
|
|
418
|
+
filterConditions: QueryModerationRulesFilters = {},
|
|
419
|
+
sort: QueryModerationRulesSort = [],
|
|
420
|
+
options: Pager = {},
|
|
421
|
+
) {
|
|
422
|
+
return await this.client.post<QueryModerationRulesResponse>(
|
|
423
|
+
this.client.baseURL + '/api/v2/moderation/moderation_rules',
|
|
424
|
+
{
|
|
425
|
+
filter: filterConditions,
|
|
426
|
+
sort,
|
|
427
|
+
...options,
|
|
428
|
+
},
|
|
429
|
+
);
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* Get a specific moderation rule by ID
|
|
434
|
+
* @param {string} id ID of the moderation rule to fetch
|
|
435
|
+
* @returns
|
|
436
|
+
*/
|
|
437
|
+
async getModerationRule(id: string) {
|
|
438
|
+
return await this.client.get<{ rule: ModerationRule }>(
|
|
439
|
+
this.client.baseURL + '/api/v2/moderation/moderation_rule/' + id,
|
|
440
|
+
);
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Delete a moderation rule by ID
|
|
445
|
+
* @param {string} id ID of the moderation rule to delete
|
|
446
|
+
* @returns
|
|
447
|
+
*/
|
|
448
|
+
async deleteModerationRule(id: string) {
|
|
449
|
+
return await this.client.delete(
|
|
450
|
+
this.client.baseURL + '/api/v2/moderation/moderation_rule/' + id,
|
|
451
|
+
);
|
|
452
|
+
}
|
|
391
453
|
}
|
package/src/types.ts
CHANGED
|
@@ -2244,6 +2244,7 @@ export type AppSettings = {
|
|
|
2244
2244
|
disable_permissions_checks?: boolean;
|
|
2245
2245
|
enforce_unique_usernames?: 'no' | 'app' | 'team';
|
|
2246
2246
|
event_hooks?: Array<EventHook> | null;
|
|
2247
|
+
explicit_event_hooks_deletion?: boolean;
|
|
2247
2248
|
// all possible file mime types are https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
2248
2249
|
file_upload_config?: FileUploadConfig;
|
|
2249
2250
|
firebase_config?: {
|
|
@@ -3786,6 +3787,171 @@ export type UpsertConfigResponse = {
|
|
|
3786
3787
|
config: ModerationConfigResponse;
|
|
3787
3788
|
};
|
|
3788
3789
|
|
|
3790
|
+
// Moderation Rule Builder Types
|
|
3791
|
+
export type ModerationRule = {
|
|
3792
|
+
id: string;
|
|
3793
|
+
name: string;
|
|
3794
|
+
description: string;
|
|
3795
|
+
config_keys: string[];
|
|
3796
|
+
team: string;
|
|
3797
|
+
rule: RuleBuilderRule;
|
|
3798
|
+
enabled: boolean;
|
|
3799
|
+
created_at: string;
|
|
3800
|
+
updated_at: string;
|
|
3801
|
+
};
|
|
3802
|
+
|
|
3803
|
+
export type ModerationRuleRequest = {
|
|
3804
|
+
name: string;
|
|
3805
|
+
description: string;
|
|
3806
|
+
config_keys: string[];
|
|
3807
|
+
team: string;
|
|
3808
|
+
rule: RuleBuilderRule;
|
|
3809
|
+
enabled: boolean;
|
|
3810
|
+
};
|
|
3811
|
+
|
|
3812
|
+
export type RuleBuilderRule = {
|
|
3813
|
+
id: string;
|
|
3814
|
+
rule_type: 'user' | 'content';
|
|
3815
|
+
conditions?: RuleBuilderCondition[];
|
|
3816
|
+
logic?: 'AND' | 'OR';
|
|
3817
|
+
groups?: RuleBuilderConditionGroup[];
|
|
3818
|
+
action: RuleBuilderAction;
|
|
3819
|
+
cooldown_period?: string;
|
|
3820
|
+
};
|
|
3821
|
+
|
|
3822
|
+
export type RuleBuilderCondition = {
|
|
3823
|
+
type: string;
|
|
3824
|
+
confidence?: number;
|
|
3825
|
+
text_rule_params?: TextRuleParameters;
|
|
3826
|
+
image_rule_params?: ImageRuleParameters;
|
|
3827
|
+
video_rule_params?: VideoRuleParameters;
|
|
3828
|
+
user_rule_params?: UserRuleParameters;
|
|
3829
|
+
content_count_rule_params?: ContentCountRuleParameters;
|
|
3830
|
+
text_content_params?: TextContentParameters;
|
|
3831
|
+
image_content_params?: ImageContentParameters;
|
|
3832
|
+
video_content_params?: VideoContentParameters;
|
|
3833
|
+
user_created_within_params?: UserCreatedWithinParameters;
|
|
3834
|
+
user_custom_property_params?: UserCustomPropertyParameters;
|
|
3835
|
+
};
|
|
3836
|
+
|
|
3837
|
+
export type RuleBuilderConditionGroup = {
|
|
3838
|
+
logic: 'AND' | 'OR';
|
|
3839
|
+
conditions: RuleBuilderCondition[];
|
|
3840
|
+
};
|
|
3841
|
+
|
|
3842
|
+
export type RuleBuilderAction = {
|
|
3843
|
+
type: string;
|
|
3844
|
+
ban_options?: BanOptions;
|
|
3845
|
+
flag_user_options?: FlagUserOptions;
|
|
3846
|
+
flag_content_options?: FlagContentOptions;
|
|
3847
|
+
remove_content_options?: RemoveContentOptions;
|
|
3848
|
+
shadow_content_options?: ShadowContentOptions;
|
|
3849
|
+
};
|
|
3850
|
+
|
|
3851
|
+
export type TextRuleParameters = {
|
|
3852
|
+
threshold: number;
|
|
3853
|
+
time_window: string;
|
|
3854
|
+
harm_labels?: string[];
|
|
3855
|
+
llm_harm_labels?: Record<string, string>;
|
|
3856
|
+
contains_url?: boolean;
|
|
3857
|
+
severity?: string;
|
|
3858
|
+
blocklist_match?: string[];
|
|
3859
|
+
};
|
|
3860
|
+
|
|
3861
|
+
export type ImageRuleParameters = {
|
|
3862
|
+
threshold: number;
|
|
3863
|
+
time_window: string;
|
|
3864
|
+
harm_labels: string[];
|
|
3865
|
+
};
|
|
3866
|
+
|
|
3867
|
+
export type VideoRuleParameters = {
|
|
3868
|
+
threshold: number;
|
|
3869
|
+
time_window: string;
|
|
3870
|
+
harm_labels: string[];
|
|
3871
|
+
};
|
|
3872
|
+
|
|
3873
|
+
export type UserRuleParameters = {
|
|
3874
|
+
max_age: string;
|
|
3875
|
+
};
|
|
3876
|
+
|
|
3877
|
+
export type ContentCountRuleParameters = {
|
|
3878
|
+
threshold: number;
|
|
3879
|
+
time_window: string;
|
|
3880
|
+
};
|
|
3881
|
+
|
|
3882
|
+
export type TextContentParameters = {
|
|
3883
|
+
harm_labels?: string[];
|
|
3884
|
+
llm_harm_labels?: Record<string, string>;
|
|
3885
|
+
contains_url?: boolean;
|
|
3886
|
+
severity?: string;
|
|
3887
|
+
blocklist_match?: string[];
|
|
3888
|
+
};
|
|
3889
|
+
|
|
3890
|
+
export type ImageContentParameters = {
|
|
3891
|
+
harm_labels: string[];
|
|
3892
|
+
};
|
|
3893
|
+
|
|
3894
|
+
export type VideoContentParameters = {
|
|
3895
|
+
harm_labels: string[];
|
|
3896
|
+
};
|
|
3897
|
+
|
|
3898
|
+
export type UserCreatedWithinParameters = {
|
|
3899
|
+
max_age: string;
|
|
3900
|
+
};
|
|
3901
|
+
|
|
3902
|
+
export type UserCustomPropertyParameters = {
|
|
3903
|
+
property_key: string;
|
|
3904
|
+
operator: string;
|
|
3905
|
+
expected_value: string;
|
|
3906
|
+
};
|
|
3907
|
+
|
|
3908
|
+
export type BanOptions = {
|
|
3909
|
+
duration: number;
|
|
3910
|
+
reason: string;
|
|
3911
|
+
shadow_ban: boolean;
|
|
3912
|
+
ip_ban: boolean;
|
|
3913
|
+
};
|
|
3914
|
+
|
|
3915
|
+
export type FlagUserOptions = {
|
|
3916
|
+
reason: string;
|
|
3917
|
+
};
|
|
3918
|
+
|
|
3919
|
+
export type FlagContentOptions = {
|
|
3920
|
+
reason: string;
|
|
3921
|
+
};
|
|
3922
|
+
|
|
3923
|
+
export type RemoveContentOptions = {
|
|
3924
|
+
reason: string;
|
|
3925
|
+
};
|
|
3926
|
+
|
|
3927
|
+
export type ShadowContentOptions = {
|
|
3928
|
+
reason: string;
|
|
3929
|
+
};
|
|
3930
|
+
|
|
3931
|
+
export type QueryModerationRulesFilters = QueryFilters<{
|
|
3932
|
+
name?: string;
|
|
3933
|
+
team?: string;
|
|
3934
|
+
enabled?: boolean;
|
|
3935
|
+
rule_type?: string;
|
|
3936
|
+
created_at?: PrimitiveFilter<string>;
|
|
3937
|
+
updated_at?: PrimitiveFilter<string>;
|
|
3938
|
+
}>;
|
|
3939
|
+
|
|
3940
|
+
export type QueryModerationRulesSort = Array<
|
|
3941
|
+
Sort<'name' | 'enabled' | 'team' | 'created_at' | 'updated_at'>
|
|
3942
|
+
>;
|
|
3943
|
+
|
|
3944
|
+
export type QueryModerationRulesResponse = {
|
|
3945
|
+
rules: ModerationRule[];
|
|
3946
|
+
default_llm_labels: Record<string, string>;
|
|
3947
|
+
next?: string;
|
|
3948
|
+
prev?: string;
|
|
3949
|
+
};
|
|
3950
|
+
|
|
3951
|
+
export type UpsertModerationRuleResponse = {
|
|
3952
|
+
rule: ModerationRule;
|
|
3953
|
+
};
|
|
3954
|
+
|
|
3789
3955
|
export type ModerationFlagOptions = {
|
|
3790
3956
|
custom?: Record<string, unknown>;
|
|
3791
3957
|
moderation_payload?: ModerationPayload;
|
|
@@ -4206,6 +4372,7 @@ export type EventHook = {
|
|
|
4206
4372
|
id?: string;
|
|
4207
4373
|
hook_type?: HookType;
|
|
4208
4374
|
enabled?: boolean;
|
|
4375
|
+
product?: Product | 'all'; // optional, default is 'all'
|
|
4209
4376
|
event_types?: Array<string>;
|
|
4210
4377
|
webhook_url?: string;
|
|
4211
4378
|
sqs_queue_url?: string;
|
|
@@ -4227,6 +4394,7 @@ export type EventHook = {
|
|
|
4227
4394
|
mode: 'CALLBACK_MODE_NONE' | 'CALLBACK_MODE_REST' | 'CALLBACK_MODE_TWIRP';
|
|
4228
4395
|
};
|
|
4229
4396
|
|
|
4397
|
+
delete?: boolean;
|
|
4230
4398
|
created_at?: string;
|
|
4231
4399
|
updated_at?: string;
|
|
4232
4400
|
};
|
package/src/utils.ts
CHANGED
|
@@ -310,16 +310,16 @@ export function formatMessage(
|
|
|
310
310
|
if (!msg) return null;
|
|
311
311
|
return {
|
|
312
312
|
...msg,
|
|
313
|
-
created_at:
|
|
314
|
-
deleted_at:
|
|
315
|
-
pinned_at:
|
|
313
|
+
created_at: msg.created_at ? new Date(msg.created_at) : new Date(),
|
|
314
|
+
deleted_at: msg.deleted_at ? new Date(msg.deleted_at) : null,
|
|
315
|
+
pinned_at: msg.pinned_at ? new Date(msg.pinned_at) : null,
|
|
316
316
|
reaction_groups: maybeGetReactionGroupsFallback(
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
317
|
+
msg.reaction_groups,
|
|
318
|
+
msg.reaction_counts,
|
|
319
|
+
msg.reaction_scores,
|
|
320
320
|
),
|
|
321
|
-
status:
|
|
322
|
-
updated_at:
|
|
321
|
+
status: msg.status || 'received',
|
|
322
|
+
updated_at: msg.updated_at ? new Date(msg.updated_at) : new Date(),
|
|
323
323
|
};
|
|
324
324
|
};
|
|
325
325
|
|