stream-chat 9.44.2 → 9.45.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.
Files changed (50) hide show
  1. package/dist/cjs/index.browser.js +3460 -2659
  2. package/dist/cjs/index.browser.js.map +4 -4
  3. package/dist/cjs/index.node.js +3469 -2659
  4. package/dist/cjs/index.node.js.map +4 -4
  5. package/dist/esm/index.mjs +3460 -2659
  6. package/dist/esm/index.mjs.map +4 -4
  7. package/dist/types/channel_state.d.ts +1 -1
  8. package/dist/types/client.d.ts +81 -3
  9. package/dist/types/constants.d.ts +1 -0
  10. package/dist/types/messageComposer/LocationComposer.d.ts +1 -1
  11. package/dist/types/messageComposer/configuration/commands.configuration.d.ts +6 -0
  12. package/dist/types/messageComposer/configuration/configuration.d.ts +1 -2
  13. package/dist/types/messageComposer/configuration/index.d.ts +4 -0
  14. package/dist/types/messageComposer/configuration/types.d.ts +21 -0
  15. package/dist/types/messageComposer/fileUtils.d.ts +1 -1
  16. package/dist/types/messageComposer/messageComposer.d.ts +6 -4
  17. package/dist/types/messageComposer/middleware/messageComposer/compositionValidation.d.ts +2 -1
  18. package/dist/types/messageComposer/middleware/messageComposer/textComposer.d.ts +1 -1
  19. package/dist/types/messageComposer/middleware/textComposer/commandUtils.d.ts +10 -1
  20. package/dist/types/messageComposer/middleware/textComposer/mentionUtils.d.ts +8 -0
  21. package/dist/types/messageComposer/middleware/textComposer/mentions.d.ts +77 -15
  22. package/dist/types/messageComposer/middleware/textComposer/types.d.ts +51 -2
  23. package/dist/types/messageComposer/pollComposer.d.ts +2 -2
  24. package/dist/types/messageComposer/textComposer.d.ts +17 -3
  25. package/dist/types/pagination/UserGroupPaginator.d.ts +21 -0
  26. package/dist/types/pagination/index.d.ts +1 -0
  27. package/dist/types/types.d.ts +123 -2
  28. package/dist/types/utils.d.ts +2 -0
  29. package/package.json +38 -31
  30. package/src/client.ts +143 -2
  31. package/src/constants.ts +1 -0
  32. package/src/messageComposer/MessageComposerEffectHandlers.ts +1 -0
  33. package/src/messageComposer/configuration/commands.configuration.ts +55 -0
  34. package/src/messageComposer/configuration/configuration.ts +3 -1
  35. package/src/messageComposer/configuration/index.ts +4 -0
  36. package/src/messageComposer/configuration/types.ts +27 -0
  37. package/src/messageComposer/messageComposer.ts +73 -22
  38. package/src/messageComposer/middleware/messageComposer/compositionValidation.ts +23 -15
  39. package/src/messageComposer/middleware/messageComposer/textComposer.ts +151 -31
  40. package/src/messageComposer/middleware/textComposer/commandUtils.ts +68 -1
  41. package/src/messageComposer/middleware/textComposer/commands.ts +6 -2
  42. package/src/messageComposer/middleware/textComposer/mentionUtils.ts +33 -0
  43. package/src/messageComposer/middleware/textComposer/mentions.ts +596 -66
  44. package/src/messageComposer/middleware/textComposer/types.ts +70 -2
  45. package/src/messageComposer/textComposer.ts +154 -10
  46. package/src/pagination/UserGroupPaginator.ts +93 -0
  47. package/src/pagination/index.ts +1 -0
  48. package/src/permissions.ts +1 -0
  49. package/src/types.ts +152 -2
  50. package/src/utils.ts +1 -0
@@ -88,6 +88,7 @@ export type AppSettingsAPIResponse = APIResponse & {
88
88
  async_url_enrich_enabled?: boolean;
89
89
  auto_translation_enabled?: boolean;
90
90
  before_message_send_hook_url?: string;
91
+ before_message_send_hook_attempt_timeout_ms?: number;
91
92
  campaign_enabled?: boolean;
92
93
  cdn_expiration_seconds?: number;
93
94
  custom_action_handler_url?: string;
@@ -631,6 +632,8 @@ export type MessageResponseBase = MessageBase & {
631
632
  mentioned_users?: UserResponse[];
632
633
  mentioned_channel?: boolean;
633
634
  mentioned_here?: boolean;
635
+ mentioned_group_ids?: string[];
636
+ mentioned_groups?: UserGroupResponse[];
634
637
  mentioned_roles?: string[];
635
638
  message_text_updated_at?: string;
636
639
  moderation?: ModerationResponse;
@@ -766,6 +769,29 @@ export type SearchAPIResponse = APIResponse & {
766
769
  previous?: string;
767
770
  results_warning?: SearchWarning | null;
768
771
  };
772
+ export type RoleResponse = {
773
+ name: Role;
774
+ custom: boolean;
775
+ scopes: string[];
776
+ created_at: string;
777
+ updated_at: string;
778
+ };
779
+ export type CreateRoleAPIResponse = APIResponse & {
780
+ role: RoleResponse;
781
+ };
782
+ export type ListRolesAPIResponse = APIResponse & {
783
+ roles: RoleResponse[];
784
+ };
785
+ export type SearchRolesAPIResponse = APIResponse & {
786
+ roles: RoleResponse[];
787
+ };
788
+ export type SearchRolesOptions = {
789
+ query: string;
790
+ include_global_roles?: boolean;
791
+ limit?: number;
792
+ name_gt?: string;
793
+ role_type?: 'user' | 'channel';
794
+ };
769
795
  export type SearchWarning = {
770
796
  channel_search_cids: string[];
771
797
  channel_search_count: number;
@@ -1870,6 +1896,7 @@ export type AppSettings = {
1870
1896
  async_url_enrich_enabled?: boolean;
1871
1897
  auto_translation_enabled?: boolean;
1872
1898
  before_message_send_hook_url?: string;
1899
+ before_message_send_hook_attempt_timeout_ms?: number;
1873
1900
  cdn_expiration_seconds?: number;
1874
1901
  custom_action_handler_url?: string;
1875
1902
  disable_auth_checks?: boolean;
@@ -2174,6 +2201,9 @@ export type Message = Partial<MessageBase & {
2174
2201
  mentioned_users: string[];
2175
2202
  shared_location?: StaticLocationPayload | LiveLocationPayload;
2176
2203
  mentioned_channel?: boolean;
2204
+ mentioned_here?: boolean;
2205
+ mentioned_group_ids?: string[];
2206
+ mentioned_roles?: string[];
2177
2207
  }>;
2178
2208
  export type MessageBase = CustomMessageData & {
2179
2209
  id: string;
@@ -2327,8 +2357,12 @@ export type TokenProvider = () => Promise<string>;
2327
2357
  export type TranslationLanguages = 'af' | 'am' | 'ar' | 'az' | 'bg' | 'bn' | 'bs' | 'cs' | 'da' | 'de' | 'el' | 'en' | 'es' | 'es-MX' | 'et' | 'fa' | 'fa-AF' | 'fi' | 'fr' | 'fr-CA' | 'ha' | 'he' | 'hi' | 'hr' | 'hu' | 'id' | 'it' | 'ja' | 'ka' | 'ko' | 'lt' | 'lv' | 'ms' | 'nl' | 'no' | 'pl' | 'ps' | 'pt' | 'ro' | 'ru' | 'sk' | 'sl' | 'so' | 'sq' | 'sr' | 'sv' | 'sw' | 'ta' | 'th' | 'tl' | 'tr' | 'uk' | 'ur' | 'vi' | 'zh' | 'zh-TW' | (string & {});
2328
2358
  export type TypingStartEvent = Event;
2329
2359
  export type ReservedUpdatedMessageFields = keyof typeof RESERVED_UPDATED_MESSAGE_FIELDS;
2330
- export type UpdatedMessage = Omit<MessageResponse, ReservedUpdatedMessageFields> & {
2360
+ export type UpdatedMessage = Omit<MessageResponse, ReservedUpdatedMessageFields | 'mentioned_groups'> & {
2331
2361
  mentioned_users?: string[];
2362
+ mentioned_channel?: boolean;
2363
+ mentioned_here?: boolean;
2364
+ mentioned_group_ids?: string[];
2365
+ mentioned_roles?: string[];
2332
2366
  type?: MessageLabel;
2333
2367
  };
2334
2368
  /**
@@ -3338,7 +3372,7 @@ export type GetDraftResponse = APIResponse & {
3338
3372
  export type QueryDraftsResponse = APIResponse & {
3339
3373
  drafts: DraftResponse[];
3340
3374
  } & Omit<Pager, 'limit'>;
3341
- export type DraftMessagePayload = PartializeKeys<DraftMessage, 'id'> & {
3375
+ export type DraftMessagePayload = PartializeKeys<Omit<DraftMessage, 'mentioned_groups'>, 'id'> & {
3342
3376
  user_id?: string;
3343
3377
  };
3344
3378
  export type DraftMessage = {
@@ -3348,6 +3382,11 @@ export type DraftMessage = {
3348
3382
  custom?: {};
3349
3383
  html?: string;
3350
3384
  mentioned_users?: string[];
3385
+ mentioned_channel?: boolean;
3386
+ mentioned_here?: boolean;
3387
+ mentioned_group_ids?: string[];
3388
+ mentioned_groups?: UserGroupResponse[];
3389
+ mentioned_roles?: string[];
3351
3390
  mml?: string;
3352
3391
  parent_id?: string;
3353
3392
  poll_id?: string;
@@ -3478,6 +3517,88 @@ export type QueryRemindersResponse = {
3478
3517
  prev?: string;
3479
3518
  next?: string;
3480
3519
  };
3520
+ export type UserGroupMemberResponse = {
3521
+ group_id: string;
3522
+ user_id: string;
3523
+ is_admin: boolean;
3524
+ created_at: string;
3525
+ };
3526
+ export type UserGroupResponse = {
3527
+ id: string;
3528
+ name: string;
3529
+ created_at: string;
3530
+ updated_at: string;
3531
+ description?: string;
3532
+ team_id?: string;
3533
+ members?: UserGroupMemberResponse[];
3534
+ created_by?: string;
3535
+ };
3536
+ export type CreateUserGroupOptions = {
3537
+ /** Human-readable user group name */
3538
+ name: string;
3539
+ /** Optional user group description shown to members */
3540
+ description?: string;
3541
+ /** Optional custom user group ID. If omitted, the backend generates one */
3542
+ id?: string;
3543
+ /** Optional list of user IDs to add as members when the group is created */
3544
+ member_ids?: string[];
3545
+ /** Optional team ID that scopes the user group to a specific team */
3546
+ team_id?: string;
3547
+ };
3548
+ export type CreateUserGroupResponse = APIResponse & {
3549
+ user_group: UserGroupResponse;
3550
+ };
3551
+ export type GetUserGroupOptions = {
3552
+ team_id?: string;
3553
+ };
3554
+ export type GetUserGroupResponse = APIResponse & {
3555
+ user_group: UserGroupResponse;
3556
+ };
3557
+ export type QueryUserGroupsOptions = {
3558
+ limit?: number;
3559
+ id_gt?: string;
3560
+ created_at_gt?: string;
3561
+ team_id?: string;
3562
+ };
3563
+ export type QueryUserGroupsResponse = APIResponse & {
3564
+ user_groups: UserGroupResponse[];
3565
+ };
3566
+ export type SearchUserGroupsOptions = {
3567
+ query: string;
3568
+ limit?: number;
3569
+ id_gt?: string;
3570
+ name_gt?: string;
3571
+ team_id?: string;
3572
+ };
3573
+ export type SearchUserGroupsResponse = APIResponse & {
3574
+ user_groups: UserGroupResponse[];
3575
+ };
3576
+ export type UpdateUserGroupOptions = {
3577
+ description?: string;
3578
+ name?: string;
3579
+ team_id?: string;
3580
+ };
3581
+ export type UpdateUserGroupResponse = APIResponse & {
3582
+ user_group: UserGroupResponse;
3583
+ };
3584
+ export type DeleteUserGroupOptions = {
3585
+ team_id?: string;
3586
+ };
3587
+ export type AddUserGroupMembersOptions = {
3588
+ member_ids: string[];
3589
+ as_admin?: boolean;
3590
+ team_id?: string;
3591
+ };
3592
+ export type AddUserGroupMembersResponse = APIResponse & {
3593
+ user_group: UserGroupResponse;
3594
+ };
3595
+ export type RemoveUserGroupMembersOptions = {
3596
+ member_ids: string[];
3597
+ team_id?: string;
3598
+ };
3599
+ export type RemoveUserGroupMembersResponse = APIResponse & {
3600
+ user_group: UserGroupResponse;
3601
+ };
3481
3602
  export type HookType = 'webhook' | 'sqs' | 'sns' | 'pending_message';
3482
3603
  export type EventHook = {
3483
3604
  id?: string;
@@ -90,6 +90,7 @@ export declare const toDeletedMessage: ({ message, deletedAt, hardDelete, }: {
90
90
  text?: string | undefined;
91
91
  user_id?: string | undefined;
92
92
  command?: string | undefined;
93
+ mentioned_groups?: import("./types").UserGroupResponse[] | undefined;
93
94
  mentioned_users?: UserResponse[] | undefined;
94
95
  latest_reactions?: import("./types").ReactionResponse[] | undefined;
95
96
  own_reactions?: import("./types").ReactionResponse[] | null | undefined;
@@ -123,6 +124,7 @@ export declare const toDeletedMessage: ({ message, deletedAt, hardDelete, }: {
123
124
  member?: import("./types").ChannelMemberResponse | undefined;
124
125
  mentioned_channel?: boolean | undefined;
125
126
  mentioned_here?: boolean | undefined;
127
+ mentioned_group_ids?: string[] | undefined;
126
128
  mentioned_roles?: string[] | undefined;
127
129
  message_text_updated_at?: string | undefined;
128
130
  moderation?: import("./types").ModerationResponse | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stream-chat",
3
- "version": "9.44.2",
3
+ "version": "9.45.0",
4
4
  "description": "JS SDK for the Stream Chat API",
5
5
  "homepage": "https://getstream.io/chat/",
6
6
  "author": {
@@ -29,11 +29,11 @@
29
29
  }
30
30
  },
31
31
  "browser": {
32
- "https": false,
33
32
  "crypto": false,
34
- "zlib": false,
33
+ "https": false,
35
34
  "jsonwebtoken": false,
36
- "ws": false
35
+ "ws": false,
36
+ "zlib": false
37
37
  },
38
38
  "license": "SEE LICENSE IN LICENSE",
39
39
  "keywords": [
@@ -51,40 +51,39 @@
51
51
  ],
52
52
  "dependencies": {
53
53
  "@types/jsonwebtoken": "^9.0.8",
54
- "@types/ws": "^8.5.14",
55
- "axios": "^1.15.1",
54
+ "@types/ws": "^8.18.1",
55
+ "axios": "^1.16.1",
56
56
  "base64-js": "^1.5.1",
57
- "form-data": "^4.0.4",
57
+ "form-data": "^4.0.5",
58
58
  "isomorphic-ws": "^5.0.0",
59
59
  "jsonwebtoken": "^9.0.3",
60
- "linkifyjs": "^4.3.2",
61
- "ws": "^8.18.1"
60
+ "linkifyjs": "^4.3.3",
61
+ "ws": "^8.20.1"
62
62
  },
63
63
  "devDependencies": {
64
- "@commitlint/cli": "^19.7.1",
65
- "@commitlint/config-conventional": "^19.7.1",
66
- "@eslint/js": "^9.21.0",
64
+ "@commitlint/cli": "^21.0.1",
65
+ "@commitlint/config-conventional": "^21.0.1",
66
+ "@eslint/js": "^9.39.4",
67
67
  "@semantic-release/changelog": "^6.0.3",
68
68
  "@semantic-release/git": "^10.0.1",
69
- "@types/base64-js": "^1.3.0",
70
- "@types/node": "^22.15.21",
69
+ "@types/node": "^22.19.19",
71
70
  "@types/sinon": "^10.0.6",
72
- "@vitest/coverage-v8": "3.1.4",
73
- "concurrently": "^9.1.2",
74
- "conventional-changelog-conventionalcommits": "^8.0.0",
75
- "dotenv": "^8.2.0",
76
- "esbuild": "^0.25.4",
77
- "eslint": "^9.27.0",
78
- "eslint-plugin-import": "^2.31.0",
79
- "globals": "^16.0.0",
71
+ "@vitest/coverage-v8": "^4.1.7",
72
+ "concurrently": "^9.2.1",
73
+ "conventional-changelog-conventionalcommits": "^9.3.1",
74
+ "dotenv": "^17.4.2",
75
+ "esbuild": "^0.28.0",
76
+ "eslint": "^9.39.4",
77
+ "eslint-plugin-import": "^2.32.0",
78
+ "globals": "^17.6.0",
80
79
  "husky": "^9.1.7",
81
- "lint-staged": "^15.2.2",
82
- "prettier": "^3.5.3",
83
- "semantic-release": "^25.0.2",
80
+ "lint-staged": "^17.0.5",
81
+ "prettier": "^3.8.3",
82
+ "semantic-release": "^25.0.3",
84
83
  "sinon": "^12.0.1",
85
- "typescript": "^5.8.3",
86
- "typescript-eslint": "^8.32.1",
87
- "vitest": "^3.1.4"
84
+ "typescript": "^6.0.3",
85
+ "typescript-eslint": "^8.59.4",
86
+ "vitest": "^4.1.7"
88
87
  },
89
88
  "scripts": {
90
89
  "build": "rm -rf dist && concurrently 'tsc' './scripts/bundle.mjs'",
@@ -97,7 +96,6 @@
97
96
  "eslint": "eslint --max-warnings 0",
98
97
  "eslint-fix": "yarn run eslint --fix",
99
98
  "test": "yarn test-unit",
100
- "testwatch": "NODE_ENV=test nodemon ./node_modules/.bin/mocha --timeout 20000 --require test-entry.js test/test.js",
101
99
  "test-types": "yarn run-test-types && yarn run-types-gen",
102
100
  "run-test-types": "node test/typescript/index.js",
103
101
  "run-types-gen": "tsc --esModuleInterop true --noEmit true --strictNullChecks true --noImplicitAny true --strict true test/typescript/*.ts",
@@ -105,10 +103,19 @@
105
103
  "test-coverage": "vitest run --coverage",
106
104
  "fix-staged": "lint-staged --config .lintstagedrc.fix.json --concurrent 1",
107
105
  "semantic-release": "semantic-release",
108
- "prepare": "husky; yarn run build"
106
+ "postinstall": "husky",
107
+ "prepare": "yarn run build"
109
108
  },
110
109
  "engines": {
111
110
  "node": ">=18"
112
111
  },
113
- "packageManager": "yarn@1.22.21+sha1.1959a18351b811cdeedbd484a8f86c3cc3bbaf72"
112
+ "packageManager": "yarn@4.15.0",
113
+ "dependenciesMeta": {
114
+ "esbuild": {
115
+ "built": true
116
+ },
117
+ "husky": {
118
+ "built": true
119
+ }
120
+ }
114
121
  }
package/src/client.ts CHANGED
@@ -42,6 +42,8 @@ import {
42
42
 
43
43
  import type {
44
44
  ActiveLiveLocationsAPIResponse,
45
+ AddUserGroupMembersOptions,
46
+ AddUserGroupMembersResponse,
45
47
  APIErrorResponse,
46
48
  APIResponse,
47
49
  AppSettings,
@@ -86,12 +88,16 @@ import type {
86
88
  CreatePollOptionAPIResponse,
87
89
  CreatePredefinedFilterOptions,
88
90
  CreateReminderOptions,
91
+ CreateRoleAPIResponse,
92
+ CreateUserGroupOptions,
93
+ CreateUserGroupResponse,
89
94
  CustomPermissionOptions,
90
95
  DeactivateUsersOptions,
91
96
  DeleteChannelsResponse,
92
97
  DeleteCommandResponse,
93
98
  DeleteMessageOptions,
94
99
  DeleteRetentionPolicyResponse,
100
+ DeleteUserGroupOptions,
95
101
  DeleteUserOptions,
96
102
  Device,
97
103
  DeviceIdentifier,
@@ -134,12 +140,15 @@ import type {
134
140
  GetThreadOptions,
135
141
  GetUnreadCountAPIResponse,
136
142
  GetUnreadCountBatchAPIResponse,
143
+ GetUserGroupOptions,
144
+ GetUserGroupResponse,
137
145
  ListChannelResponse,
138
146
  ListCommandsResponse,
139
147
  ListImportsPaginationOptions,
140
148
  ListImportsResponse,
141
149
  ListPredefinedFiltersOptions,
142
150
  ListPredefinedFiltersResponse,
151
+ ListRolesAPIResponse,
143
152
  LocalMessage,
144
153
  Logger,
145
154
  MarkChannelsReadOptions,
@@ -197,6 +206,8 @@ import type {
197
206
  QueryTeamUsageStatsResponse,
198
207
  QueryThreadsAPIResponse,
199
208
  QueryThreadsOptions,
209
+ QueryUserGroupsOptions,
210
+ QueryUserGroupsResponse,
200
211
  QueryVotesFilters,
201
212
  QueryVotesOptions,
202
213
  ReactionFilters,
@@ -205,6 +216,8 @@ import type {
205
216
  ReactivateUserOptions,
206
217
  ReactivateUsersOptions,
207
218
  ReminderAPIResponse,
219
+ RemoveUserGroupMembersOptions,
220
+ RemoveUserGroupMembersResponse,
208
221
  ReviewFlagReportOptions,
209
222
  ReviewFlagReportResponse,
210
223
  SdkIdentifier,
@@ -212,6 +225,10 @@ import type {
212
225
  SearchMessageSortBase,
213
226
  SearchOptions,
214
227
  SearchPayload,
228
+ SearchRolesAPIResponse,
229
+ SearchRolesOptions,
230
+ SearchUserGroupsOptions,
231
+ SearchUserGroupsResponse,
215
232
  SegmentData,
216
233
  SegmentResponse,
217
234
  SegmentTargetsResponse,
@@ -245,6 +262,8 @@ import type {
245
262
  UpdatePredefinedFilterOptions,
246
263
  UpdateReminderOptions,
247
264
  UpdateSegmentData,
265
+ UpdateUserGroupOptions,
266
+ UpdateUserGroupResponse,
248
267
  UpdateUsersAPIResponse,
249
268
  UpsertPushPreferencesResponse,
250
269
  UserCustomEvent,
@@ -1834,6 +1853,120 @@ export class StreamChat {
1834
1853
  return data;
1835
1854
  }
1836
1855
 
1856
+ /**
1857
+ * queryUserGroups - List user groups with cursor-based pagination.
1858
+ *
1859
+ * @param {QueryUserGroupsOptions} options The query options
1860
+ *
1861
+ * @return {Promise<QueryUserGroupsResponse>} User Group Query Response
1862
+ */
1863
+ async queryUserGroups(options: QueryUserGroupsOptions = {}) {
1864
+ return await this.get<QueryUserGroupsResponse>(this.baseURL + '/usergroups', options);
1865
+ }
1866
+
1867
+ /**
1868
+ * createUserGroup - Create a user group
1869
+ *
1870
+ * @param {CreateUserGroupOptions} options The create options
1871
+ *
1872
+ * @return {Promise<CreateUserGroupResponse>} User Group Create Response
1873
+ */
1874
+ async createUserGroup(options: CreateUserGroupOptions) {
1875
+ return await this.post<CreateUserGroupResponse>(
1876
+ this.baseURL + '/usergroups',
1877
+ options,
1878
+ );
1879
+ }
1880
+
1881
+ /**
1882
+ * getUserGroup - Get a user group by ID
1883
+ *
1884
+ * @param {string} id The user group ID
1885
+ * @param {GetUserGroupOptions} options Optional query options
1886
+ *
1887
+ * @return {Promise<GetUserGroupResponse>} User Group Get Response
1888
+ */
1889
+ async getUserGroup(id: string, options: GetUserGroupOptions = {}) {
1890
+ return await this.get<GetUserGroupResponse>(
1891
+ `${this.baseURL}/usergroups/${encodeURIComponent(id)}`,
1892
+ options,
1893
+ );
1894
+ }
1895
+
1896
+ /**
1897
+ * searchUserGroups - Search user groups by prefix for autocomplete
1898
+ *
1899
+ * @param {SearchUserGroupsOptions} options The search options
1900
+ *
1901
+ * @return {Promise<SearchUserGroupsResponse>} User Group Search Response
1902
+ */
1903
+ async searchUserGroups(options: SearchUserGroupsOptions) {
1904
+ return await this.get<SearchUserGroupsResponse>(
1905
+ this.baseURL + '/usergroups/search',
1906
+ options,
1907
+ );
1908
+ }
1909
+
1910
+ /**
1911
+ * updateUserGroup - Update a user group by ID
1912
+ *
1913
+ * @param {string} id The user group ID
1914
+ * @param {UpdateUserGroupOptions} options The update options
1915
+ *
1916
+ * @return {Promise<UpdateUserGroupResponse>} User Group Update Response
1917
+ */
1918
+ async updateUserGroup(id: string, options: UpdateUserGroupOptions) {
1919
+ return await this.put<UpdateUserGroupResponse>(
1920
+ `${this.baseURL}/usergroups/${encodeURIComponent(id)}`,
1921
+ options,
1922
+ );
1923
+ }
1924
+
1925
+ /**
1926
+ * deleteUserGroup - Delete a user group by ID
1927
+ *
1928
+ * @param {string} id The user group ID
1929
+ * @param {DeleteUserGroupOptions} options Optional query options
1930
+ *
1931
+ * @return {Promise<APIResponse>} User Group Delete Response
1932
+ */
1933
+ async deleteUserGroup(id: string, options: DeleteUserGroupOptions = {}) {
1934
+ return await this.delete<APIResponse>(
1935
+ `${this.baseURL}/usergroups/${encodeURIComponent(id)}`,
1936
+ options,
1937
+ );
1938
+ }
1939
+
1940
+ /**
1941
+ * addUserGroupMembers - Add members to a user group
1942
+ *
1943
+ * @param {string} id The user group ID
1944
+ * @param {AddUserGroupMembersOptions} options The add-members options
1945
+ *
1946
+ * @return {Promise<AddUserGroupMembersResponse>} User Group Add Members Response
1947
+ */
1948
+ async addUserGroupMembers(id: string, options: AddUserGroupMembersOptions) {
1949
+ return await this.post<AddUserGroupMembersResponse>(
1950
+ `${this.baseURL}/usergroups/${encodeURIComponent(id)}/members`,
1951
+ options,
1952
+ );
1953
+ }
1954
+
1955
+ /**
1956
+ * removeUserGroupMembers - Remove members from a user group
1957
+ *
1958
+ * @param {string} id The user group ID
1959
+ * @param {RemoveUserGroupMembersOptions} options The remove-members options
1960
+ *
1961
+ * @return {Promise<RemoveUserGroupMembersResponse>} User Group Remove Members Response
1962
+ */
1963
+ async removeUserGroupMembers(id: string, options: RemoveUserGroupMembersOptions) {
1964
+ return await this.post<RemoveUserGroupMembersResponse>(
1965
+ `${this.baseURL}/usergroups/${encodeURIComponent(id)}/members/delete`,
1966
+ options,
1967
+ );
1968
+ }
1969
+
1837
1970
  /**
1838
1971
  * queryBannedUsers - Query user bans
1839
1972
  *
@@ -3822,7 +3955,7 @@ export class StreamChat {
3822
3955
  * @returns {Promise<APIResponse>}
3823
3956
  */
3824
3957
  createRole(name: string) {
3825
- return this.post<APIResponse>(`${this.baseURL}/roles`, { name });
3958
+ return this.post<CreateRoleAPIResponse>(`${this.baseURL}/roles`, { name });
3826
3959
  }
3827
3960
 
3828
3961
  /** listRoles - returns the list of all roles for this application
@@ -3830,7 +3963,15 @@ export class StreamChat {
3830
3963
  * @returns {Promise<APIResponse>}
3831
3964
  */
3832
3965
  listRoles() {
3833
- return this.get<APIResponse>(`${this.baseURL}/roles`);
3966
+ return this.get<ListRolesAPIResponse>(`${this.baseURL}/roles`);
3967
+ }
3968
+
3969
+ /** listRoles - returns the list of all roles for this application
3970
+ *
3971
+ * @returns {Promise<APIResponse>}
3972
+ */
3973
+ searchRoles(options: SearchRolesOptions) {
3974
+ return this.get<SearchRolesAPIResponse>(`${this.baseURL}/roles/search`, options);
3834
3975
  }
3835
3976
 
3836
3977
  /** deleteRole - deletes a custom role
package/src/constants.ts CHANGED
@@ -15,6 +15,7 @@ export const RESERVED_UPDATED_MESSAGE_FIELDS = Object.freeze({
15
15
  updated_at: true,
16
16
  command: true,
17
17
  // Back-end enriches these fields
18
+ mentioned_groups: true,
18
19
  mentioned_users: true,
19
20
  quoted_message: true,
20
21
  // Client-specific fields
@@ -30,6 +30,7 @@ const applyCommandActivationEffect: MessageComposerEffectHandler<
30
30
  composer.textComposer.state.next({
31
31
  command: effect.command,
32
32
  mentionedUsers: [],
33
+ mentions: [],
33
34
  suggestions: undefined,
34
35
  selection: { start: 0, end: 0 },
35
36
  text: '',
@@ -0,0 +1,55 @@
1
+ import type {
2
+ CommandsConfig,
3
+ CommandSendValidator,
4
+ MessageComposerConfig,
5
+ } from './types';
6
+ import type { DeepPartial } from '../../types.utility';
7
+ import { stripMentionTokens } from '../middleware';
8
+
9
+ export const MENTION_ONLY_COMMANDS = new Set(['mute', 'unmute', 'unban']);
10
+ export const defaultCommandSendabilityValidator: CommandSendValidator = ({
11
+ command,
12
+ commandArgsText,
13
+ mentionedUsersInText,
14
+ }) => {
15
+ if (command.name !== 'ban' && !MENTION_ONLY_COMMANDS.has(command.name ?? '')) return;
16
+
17
+ if (mentionedUsersInText.length === 0) {
18
+ return { command, ready: false, reason: 'missing-mention' };
19
+ }
20
+
21
+ if (command.name !== 'ban') {
22
+ return { command, ready: true };
23
+ }
24
+
25
+ const banReason = stripMentionTokens(commandArgsText, mentionedUsersInText);
26
+
27
+ if (!banReason.length) {
28
+ return { command, ready: false, reason: 'missing-ban-reason' };
29
+ }
30
+
31
+ return { command, ready: true };
32
+ };
33
+ export const DEFAULT_COMMANDS_CONFIG: CommandsConfig = {
34
+ sendValidator: defaultCommandSendabilityValidator,
35
+ };
36
+ export const applyCommandValidatorOverride = (
37
+ targetConfig: MessageComposerConfig,
38
+ sourceConfig?: DeepPartial<MessageComposerConfig>,
39
+ ) => {
40
+ const overrideValidator = sourceConfig?.commands?.sendValidator as
41
+ | CommandSendValidator
42
+ | undefined;
43
+
44
+ if (typeof overrideValidator === 'undefined') {
45
+ return targetConfig;
46
+ }
47
+
48
+ return {
49
+ ...targetConfig,
50
+ commands: {
51
+ ...targetConfig.commands,
52
+ sendValidator: overrideValidator,
53
+ },
54
+ };
55
+ };
@@ -5,9 +5,10 @@ import type {
5
5
  LinkPreviewsManagerConfig,
6
6
  LocationComposerConfig,
7
7
  MessageComposerConfig,
8
+ TextComposerConfig,
8
9
  } from './types';
9
- import type { TextComposerConfig } from './types';
10
10
  import { generateUUIDv4 } from '../../utils';
11
+ import { DEFAULT_COMMANDS_CONFIG } from './commands.configuration';
11
12
 
12
13
  export const DEFAULT_LINK_PREVIEW_MANAGER_CONFIG: LinkPreviewsManagerConfig = {
13
14
  debounceURLEnrichmentMs: 1500,
@@ -46,6 +47,7 @@ export const DEFAULT_LOCATION_COMPOSER_CONFIG: LocationComposerConfig = {
46
47
 
47
48
  export const DEFAULT_COMPOSER_CONFIG: MessageComposerConfig = {
48
49
  attachments: DEFAULT_ATTACHMENT_MANAGER_CONFIG,
50
+ commands: DEFAULT_COMMANDS_CONFIG,
49
51
  drafts: { enabled: false },
50
52
  linkPreviews: DEFAULT_LINK_PREVIEW_MANAGER_CONFIG,
51
53
  location: DEFAULT_LOCATION_COMPOSER_CONFIG,
@@ -1,2 +1,6 @@
1
1
  export * from './configuration';
2
2
  export * from './types';
3
+ export { applyCommandValidatorOverride } from './commands.configuration';
4
+ export { DEFAULT_COMMANDS_CONFIG } from './commands.configuration';
5
+ export { defaultCommandSendabilityValidator } from './commands.configuration';
6
+ export { MENTION_ONLY_COMMANDS } from './commands.configuration';