stream-chat 9.46.0 → 9.47.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.
@@ -11,7 +11,6 @@ export declare const accentsMap: {
11
11
  export declare const removeDiacritics: (text?: string) => string;
12
12
  export declare const calculateLevenshtein: (query: string, name: string) => number;
13
13
  export type MentionsSearchSourceOptions = SearchSourceOptions & {
14
- allowedMentionTypes?: Partial<Record<MentionType, boolean>>;
15
14
  mentionAllAppUsers?: boolean;
16
15
  suggestionFactoryMappers?: MentionSuggestionFactoryMapperOverrides;
17
16
  textComposerText?: string;
@@ -41,6 +40,7 @@ export type MentionSuggestionFactoryMapper<TMentionType extends MentionType = Me
41
40
  export type MentionSuggestionFactoryMapperOverrides = {
42
41
  [TMentionType in MentionType]?: MentionSuggestionFactoryMapper<TMentionType>;
43
42
  };
43
+ export declare const getAllowedMentionTypesFromCapabilities: (ownCapabilities?: string[]) => Record<MentionType, boolean>;
44
44
  type UserPaginationState = {
45
45
  itemCount: number;
46
46
  nextOffset?: number;
@@ -49,6 +49,8 @@ export type AppSettingsAPIResponse = APIResponse & {
49
49
  app?: {
50
50
  id?: string | number;
51
51
  allow_multi_user_devices?: boolean;
52
+ feed_audit_logs_enabled?: boolean;
53
+ moderation_onboarding_complete?: boolean | null;
52
54
  call_types: any;
53
55
  channel_configs: Record<string, {
54
56
  reminders: boolean;
@@ -1990,6 +1992,7 @@ export type BlockList = {
1990
1992
  team?: string;
1991
1993
  type?: string;
1992
1994
  validate?: boolean;
1995
+ is_confusable_folding_enabled?: boolean;
1993
1996
  is_leet_check_enabled?: boolean;
1994
1997
  is_plural_check_enabled?: boolean;
1995
1998
  };
@@ -2111,6 +2114,7 @@ export type ConnectionOpen = {
2111
2114
  connection_id: string;
2112
2115
  cid?: string;
2113
2116
  created_at?: string;
2117
+ received_at?: string;
2114
2118
  me?: OwnUserResponse;
2115
2119
  type?: string;
2116
2120
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stream-chat",
3
- "version": "9.46.0",
3
+ "version": "9.47.1",
4
4
  "description": "JS SDK for the Stream Chat API",
5
5
  "homepage": "https://getstream.io/chat/",
6
6
  "author": {
@@ -98,7 +98,7 @@
98
98
  "test": "yarn test-unit",
99
99
  "test-types": "yarn run-test-types && yarn run-types-gen",
100
100
  "run-test-types": "node test/typescript/index.js",
101
- "run-types-gen": "tsc --esModuleInterop true --noEmit true --strictNullChecks true --noImplicitAny true --strict true test/typescript/*.ts",
101
+ "run-types-gen": "tsc -p test/typescript/tsconfig.json",
102
102
  "test-unit": "vitest",
103
103
  "test-coverage": "vitest run --coverage",
104
104
  "fix-staged": "lint-staged --config .lintstagedrc.fix.json --concurrent 1",
@@ -48,28 +48,30 @@ export class CommandSearchSource extends BaseSearchSourceSync<CommandSuggestion>
48
48
  ),
49
49
  );
50
50
 
51
- // sort alphabetically unless you're matching the first char
52
- selectedCommands.sort((a, b) => {
53
- let nameA = a.name?.toLowerCase();
54
- let nameB = b.name?.toLowerCase();
55
- if (nameA?.indexOf(searchQuery) === 0) {
56
- nameA = `0${nameA}`;
57
- }
58
- if (nameB?.indexOf(searchQuery) === 0) {
59
- nameB = `0${nameB}`;
60
- }
61
- // Should confirm possible null / undefined when TS is fully implemented
62
- if (nameA != null && nameB != null) {
63
- if (nameA < nameB) {
64
- return -1;
51
+ if (searchQuery) {
52
+ // sort alphabetically unless you're matching the first char
53
+ selectedCommands.sort((a, b) => {
54
+ let nameA = a.name?.toLowerCase();
55
+ let nameB = b.name?.toLowerCase();
56
+ if (nameA?.indexOf(searchQuery) === 0) {
57
+ nameA = `0${nameA}`;
65
58
  }
66
- if (nameA > nameB) {
67
- return 1;
59
+ if (nameB?.indexOf(searchQuery) === 0) {
60
+ nameB = `0${nameB}`;
61
+ }
62
+ // Should confirm possible null / undefined when TS is fully implemented
63
+ if (nameA != null && nameB != null) {
64
+ if (nameA < nameB) {
65
+ return -1;
66
+ }
67
+ if (nameA > nameB) {
68
+ return 1;
69
+ }
68
70
  }
69
- }
70
71
 
71
- return 0;
72
- });
72
+ return 0;
73
+ });
74
+ }
73
75
 
74
76
  return {
75
77
  items: selectedCommands.map((command) => ({
@@ -92,7 +92,6 @@ export const calculateLevenshtein = (query: string, name: string) => {
92
92
  };
93
93
 
94
94
  export type MentionsSearchSourceOptions = SearchSourceOptions & {
95
- allowedMentionTypes?: Partial<Record<MentionType, boolean>>;
96
95
  mentionAllAppUsers?: boolean;
97
96
  suggestionFactoryMappers?: MentionSuggestionFactoryMapperOverrides;
98
97
  textComposerText?: string;
@@ -134,13 +133,18 @@ export type MentionSuggestionFactoryMapperOverrides = {
134
133
  [TMentionType in MentionType]?: MentionSuggestionFactoryMapper<TMentionType>;
135
134
  };
136
135
 
137
- const DEFAULT_ALLOWED_MENTION_TYPES: Record<MentionType, boolean> = {
138
- channel: true,
139
- here: true,
140
- role: true,
136
+ const hasOwnCapability = (ownCapabilities: string[] | undefined, capability: string) =>
137
+ ownCapabilities?.includes(capability) ?? false;
138
+
139
+ export const getAllowedMentionTypesFromCapabilities = (
140
+ ownCapabilities?: string[],
141
+ ): Record<MentionType, boolean> => ({
142
+ channel: hasOwnCapability(ownCapabilities, 'notify-channel'),
143
+ here: hasOwnCapability(ownCapabilities, 'notify-here'),
144
+ role: hasOwnCapability(ownCapabilities, 'notify-role'),
141
145
  user: true,
142
- user_group: true,
143
- };
146
+ user_group: hasOwnCapability(ownCapabilities, 'notify-group'),
147
+ });
144
148
 
145
149
  type UserGroupSearchCursor = Pick<SearchUserGroupsOptions, 'id_gt' | 'name_gt'>;
146
150
  type UserPaginationState = {
@@ -299,7 +303,6 @@ export class MentionsSearchSource extends BaseSearchSource<MentionSuggestion> {
299
303
 
300
304
  constructor(channel: Channel, options?: MentionsSearchSourceOptions) {
301
305
  const {
302
- allowedMentionTypes,
303
306
  mentionAllAppUsers,
304
307
  suggestionFactoryMappers,
305
308
  textComposerText,
@@ -311,10 +314,6 @@ export class MentionsSearchSource extends BaseSearchSource<MentionSuggestion> {
311
314
  this.client = channel.getClient();
312
315
  this.channel = channel;
313
316
  this.config = {
314
- allowedMentionTypes: {
315
- ...DEFAULT_ALLOWED_MENTION_TYPES,
316
- ...allowedMentionTypes,
317
- },
318
317
  mentionAllAppUsers,
319
318
  suggestionFactoryMappers,
320
319
  textComposerText,
@@ -371,7 +370,9 @@ export class MentionsSearchSource extends BaseSearchSource<MentionSuggestion> {
371
370
  };
372
371
 
373
372
  isMentionTypeAllowed = (mentionType: MentionType) =>
374
- this.config.allowedMentionTypes?.[mentionType] ?? true;
373
+ getAllowedMentionTypesFromCapabilities(this.channel.data?.own_capabilities)[
374
+ mentionType
375
+ ];
375
376
 
376
377
  protected mapMentionSuggestion = <TMentionType extends MentionType>(
377
378
  mentionType: TMentionType,
package/src/types.ts CHANGED
@@ -83,6 +83,8 @@ export type AppSettingsAPIResponse = APIResponse & {
83
83
  app?: {
84
84
  id?: string | number;
85
85
  allow_multi_user_devices?: boolean;
86
+ feed_audit_logs_enabled?: boolean;
87
+ moderation_onboarding_complete?: boolean | null;
86
88
  // TODO
87
89
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
88
90
  call_types: any;
@@ -2533,6 +2535,7 @@ export type BlockList = {
2533
2535
  team?: string;
2534
2536
  type?: string;
2535
2537
  validate?: boolean;
2538
+ is_confusable_folding_enabled?: boolean;
2536
2539
  is_leet_check_enabled?: boolean;
2537
2540
  is_plural_check_enabled?: boolean;
2538
2541
  };
@@ -2692,6 +2695,7 @@ export type ConnectionOpen = {
2692
2695
  connection_id: string;
2693
2696
  cid?: string;
2694
2697
  created_at?: string;
2698
+ received_at?: string;
2695
2699
  me?: OwnUserResponse;
2696
2700
  type?: string;
2697
2701
  };