@stream-io/node-sdk 0.7.63 → 0.8.0

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.
@@ -19,6 +19,7 @@ import {
19
19
  CheckResponse,
20
20
  CheckS3AccessRequest,
21
21
  CheckS3AccessResponse,
22
+ CreatePolicyTestSetRequest,
22
23
  CreateQueueRequest,
23
24
  CustomCheckRequest,
24
25
  CustomCheckResponse,
@@ -45,6 +46,9 @@ import {
45
46
  ModerationBanResponse,
46
47
  MuteRequest,
47
48
  MuteResponse,
49
+ PolicyTestRunResponse,
50
+ PolicyTestSetListResponse,
51
+ PolicyTestSetResponse,
48
52
  QueryAppealsRequest,
49
53
  QueryAppealsResponse,
50
54
  QueryFeedModerationTemplatesResponse,
@@ -61,6 +65,7 @@ import {
61
65
  QueryReviewQueueRequest,
62
66
  QueryReviewQueueResponse,
63
67
  QueueResponse,
68
+ Response,
64
69
  SubmitActionRequest,
65
70
  SubmitActionResponse,
66
71
  SubmitModerationFeedbackRequest,
@@ -1016,10 +1021,138 @@ export class ModerationApi {
1016
1021
  return { ...response.body, metadata: response.metadata };
1017
1022
  }
1018
1023
 
1019
- async listQueues(): Promise<StreamResponse<ListQueuesResponse>> {
1024
+ async getPolicyTestRun(request: {
1025
+ id: string;
1026
+ }): Promise<StreamResponse<PolicyTestRunResponse>> {
1027
+ const pathParams = {
1028
+ id: request?.id,
1029
+ };
1030
+
1031
+ const response = await this.apiClient.sendRequest<
1032
+ StreamResponse<PolicyTestRunResponse>
1033
+ >(
1034
+ 'GET',
1035
+ '/api/v2/moderation/policy_tests/runs/{id}',
1036
+ pathParams,
1037
+ undefined,
1038
+ );
1039
+
1040
+ decoders.PolicyTestRunResponse?.(response.body);
1041
+
1042
+ return { ...response.body, metadata: response.metadata };
1043
+ }
1044
+
1045
+ async listPolicyTestSets(): Promise<
1046
+ StreamResponse<PolicyTestSetListResponse>
1047
+ > {
1048
+ const response = await this.apiClient.sendRequest<
1049
+ StreamResponse<PolicyTestSetListResponse>
1050
+ >('GET', '/api/v2/moderation/policy_tests/sets', undefined, undefined);
1051
+
1052
+ decoders.PolicyTestSetListResponse?.(response.body);
1053
+
1054
+ return { ...response.body, metadata: response.metadata };
1055
+ }
1056
+
1057
+ async createPolicyTestSet(
1058
+ request: CreatePolicyTestSetRequest,
1059
+ ): Promise<StreamResponse<PolicyTestSetResponse>> {
1060
+ const body = {
1061
+ name: request?.name,
1062
+ config_key: request?.config_key,
1063
+ mode: request?.mode,
1064
+ team: request?.team,
1065
+ rows: request?.rows,
1066
+ seed: request?.seed,
1067
+ };
1068
+
1069
+ const response = await this.apiClient.sendRequest<
1070
+ StreamResponse<PolicyTestSetResponse>
1071
+ >(
1072
+ 'POST',
1073
+ '/api/v2/moderation/policy_tests/sets',
1074
+ undefined,
1075
+ undefined,
1076
+ body,
1077
+ 'application/json',
1078
+ );
1079
+
1080
+ decoders.PolicyTestSetResponse?.(response.body);
1081
+
1082
+ return { ...response.body, metadata: response.metadata };
1083
+ }
1084
+
1085
+ async deletePolicyTestSet(request: {
1086
+ id: string;
1087
+ }): Promise<StreamResponse<Response>> {
1088
+ const pathParams = {
1089
+ id: request?.id,
1090
+ };
1091
+
1092
+ const response = await this.apiClient.sendRequest<StreamResponse<Response>>(
1093
+ 'DELETE',
1094
+ '/api/v2/moderation/policy_tests/sets/{id}',
1095
+ pathParams,
1096
+ undefined,
1097
+ );
1098
+
1099
+ decoders.Response?.(response.body);
1100
+
1101
+ return { ...response.body, metadata: response.metadata };
1102
+ }
1103
+
1104
+ async getPolicyTestSet(request: {
1105
+ id: string;
1106
+ }): Promise<StreamResponse<PolicyTestSetResponse>> {
1107
+ const pathParams = {
1108
+ id: request?.id,
1109
+ };
1110
+
1111
+ const response = await this.apiClient.sendRequest<
1112
+ StreamResponse<PolicyTestSetResponse>
1113
+ >(
1114
+ 'GET',
1115
+ '/api/v2/moderation/policy_tests/sets/{id}',
1116
+ pathParams,
1117
+ undefined,
1118
+ );
1119
+
1120
+ decoders.PolicyTestSetResponse?.(response.body);
1121
+
1122
+ return { ...response.body, metadata: response.metadata };
1123
+ }
1124
+
1125
+ async startPolicyTestRun(request: {
1126
+ id: string;
1127
+ }): Promise<StreamResponse<PolicyTestRunResponse>> {
1128
+ const pathParams = {
1129
+ id: request?.id,
1130
+ };
1131
+
1132
+ const response = await this.apiClient.sendRequest<
1133
+ StreamResponse<PolicyTestRunResponse>
1134
+ >(
1135
+ 'POST',
1136
+ '/api/v2/moderation/policy_tests/sets/{id}/runs',
1137
+ pathParams,
1138
+ undefined,
1139
+ );
1140
+
1141
+ decoders.PolicyTestRunResponse?.(response.body);
1142
+
1143
+ return { ...response.body, metadata: response.metadata };
1144
+ }
1145
+
1146
+ async listQueues(request?: {
1147
+ user_id?: string;
1148
+ }): Promise<StreamResponse<ListQueuesResponse>> {
1149
+ const queryParams = {
1150
+ user_id: request?.user_id,
1151
+ };
1152
+
1020
1153
  const response = await this.apiClient.sendRequest<
1021
1154
  StreamResponse<ListQueuesResponse>
1022
- >('GET', '/api/v2/moderation/queues', undefined, undefined);
1155
+ >('GET', '/api/v2/moderation/queues', undefined, queryParams);
1023
1156
 
1024
1157
  decoders.ListQueuesResponse?.(response.body);
1025
1158
 
@@ -1235,6 +1368,7 @@ export class ModerationApi {
1235
1368
  delete_message: request?.delete_message,
1236
1369
  delete_reaction: request?.delete_reaction,
1237
1370
  delete_user: request?.delete_user,
1371
+ delete_user_messages: request?.delete_user_messages,
1238
1372
  escalate: request?.escalate,
1239
1373
  flag: request?.flag,
1240
1374
  mark_reviewed: request?.mark_reviewed,
@@ -21,6 +21,7 @@ import {
21
21
  GetCallResponse,
22
22
  GetCallSessionParticipantStatsDetailsResponse,
23
23
  GetCallTypeResponse,
24
+ GetDailyDigestResponse,
24
25
  GetEdgesResponse,
25
26
  GetOrCreateCallRequest,
26
27
  GetOrCreateCallResponse,
@@ -1949,4 +1950,22 @@ export class VideoApi {
1949
1950
 
1950
1951
  return { ...response.body, metadata: response.metadata };
1951
1952
  }
1953
+
1954
+ async getDailyDigest(request?: {
1955
+ date?: string;
1956
+ app_id?: string;
1957
+ }): Promise<StreamResponse<GetDailyDigestResponse>> {
1958
+ const queryParams = {
1959
+ date: request?.date,
1960
+ app_id: request?.app_id,
1961
+ };
1962
+
1963
+ const response = await this.apiClient.sendRequest<
1964
+ StreamResponse<GetDailyDigestResponse>
1965
+ >('GET', '/api/v2/video/stats/daily_digest', undefined, queryParams);
1966
+
1967
+ decoders.GetDailyDigestResponse?.(response.body);
1968
+
1969
+ return { ...response.body, metadata: response.metadata };
1970
+ }
1952
1971
  }
@@ -7,19 +7,19 @@ export function JWTUserToken(
7
7
  exp?: number;
8
8
  iat: number;
9
9
  call_cids?: string[];
10
- } & { [key: string]: any },
10
+ } & Record<string, any>,
11
11
  ) {
12
12
  // make sure we return a clear error when jwt is shimmed (ie. browser build)
13
- if (jwt == null || jwt.sign == null) {
13
+ if (jwt?.sign == null) {
14
14
  throw Error(
15
15
  `Unable to find jwt crypto, if you are getting this error is probably because you are trying to generate tokens on browser or React Native (or other environment where crypto functions are not available). Please Note: token should only be generated server-side.`,
16
16
  );
17
17
  }
18
18
 
19
- const opts: SignOptions = Object.assign({
19
+ const opts: SignOptions = {
20
20
  algorithm: 'HS256',
21
21
  noTimestamp: true,
22
- });
22
+ };
23
23
 
24
24
  if (payload.iat) {
25
25
  opts.noTimestamp = false;
@@ -0,0 +1,21 @@
1
+ export const isScalar = (value: any) => {
2
+ const type = typeof value;
3
+ return type === 'string' || type === 'number' || type === 'boolean';
4
+ };
5
+
6
+ /**
7
+ * Scalar arrays go on the wire comma-separated (`ids=a,b`), anything else has
8
+ * to be JSON or it stringifies to `[object Object]`. `null` and `undefined`
9
+ * entries are dropped so that a single empty value can't flip the format.
10
+ */
11
+ export const stringifyArrayParam = (param: any[]) => {
12
+ const entries = [];
13
+ let allScalar = true;
14
+ for (const entry of param) {
15
+ if (entry == null) continue;
16
+ if (!isScalar(entry)) allScalar = false;
17
+ entries.push(entry);
18
+ }
19
+
20
+ return allScalar ? entries.join(',') : JSON.stringify(entries);
21
+ };