@stream-io/video-react-sdk 1.21.3 → 1.23.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.
@@ -8,11 +8,26 @@ export type Filter<T> = {
8
8
  type Conditions<T> = {
9
9
  [K in keyof T]?: T[K] extends Array<infer E> ? ArrayOperator<E> : ScalarOperator<T[K]>;
10
10
  };
11
- export type ScalarOperator<T> = EqOperator<T> | NeqOperator<T> | InOperator<T> | T;
11
+ export type ScalarOperator<T> = EqOperator<T> | NeqOperator<T> | InOperator<T> | GtOperator<T> | GteOperator<T> | LtOperator<T> | LteOperator<T> | T;
12
12
  export type ArrayOperator<T> = ContainsOperator<T>;
13
+ export type AutocompleteOperator<T> = {
14
+ $autocomplete: T;
15
+ };
13
16
  export type EqOperator<T> = {
14
17
  $eq: T;
15
18
  };
19
+ export type GtOperator<T> = {
20
+ $gt: T;
21
+ };
22
+ export type GteOperator<T> = {
23
+ $gte: T;
24
+ };
25
+ export type LtOperator<T> = {
26
+ $lt: T;
27
+ };
28
+ export type LteOperator<T> = {
29
+ $lte: T;
30
+ };
16
31
  export type NeqOperator<T> = {
17
32
  $neq: T;
18
33
  };
package/index.ts CHANGED
@@ -15,6 +15,7 @@ export {
15
15
  usePersistedDevicePreferences,
16
16
  useDeviceList,
17
17
  } from './src/hooks';
18
+ export { applyFilter, type Filter } from './src/utilities/filter';
18
19
 
19
20
  const [major, minor, patch] = (
20
21
  process.env.PKG_VERSION || '0.0.0-development'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stream-io/video-react-sdk",
3
- "version": "1.21.3",
3
+ "version": "1.23.0",
4
4
  "main": "./dist/index.cjs.js",
5
5
  "module": "./dist/index.es.js",
6
6
  "types": "./dist/index.d.ts",
@@ -30,9 +30,9 @@
30
30
  ],
31
31
  "dependencies": {
32
32
  "@floating-ui/react": "^0.27.6",
33
- "@stream-io/video-client": "1.31.0",
33
+ "@stream-io/video-client": "1.33.0",
34
34
  "@stream-io/video-filters-web": "0.2.2",
35
- "@stream-io/video-react-bindings": "1.8.3",
35
+ "@stream-io/video-react-bindings": "1.9.0",
36
36
  "chart.js": "^4.4.4",
37
37
  "clsx": "^2.0.0",
38
38
  "react-chartjs-2": "^5.3.0"
@@ -45,7 +45,7 @@
45
45
  "@rollup/plugin-json": "^6.1.0",
46
46
  "@rollup/plugin-replace": "^6.0.2",
47
47
  "@rollup/plugin-typescript": "^12.1.2",
48
- "@stream-io/audio-filters-web": "^0.4.3",
48
+ "@stream-io/audio-filters-web": "^0.5.0",
49
49
  "@stream-io/video-styling": "^1.5.1",
50
50
  "@types/react": "^19.1.3",
51
51
  "@types/react-dom": "^19.1.3",
@@ -9,6 +9,7 @@ import {
9
9
  Restricted,
10
10
  useCall,
11
11
  useCallStateHooks,
12
+ useI18n,
12
13
  } from '@stream-io/video-react-bindings';
13
14
  import {
14
15
  name,
@@ -100,6 +101,7 @@ const CallParticipantListContentHeader = ({
100
101
  setUserListType: Dispatch<SetStateAction<keyof typeof UserListTypes>>;
101
102
  }) => {
102
103
  const call = useCall();
104
+ const { t } = useI18n();
103
105
 
104
106
  const muteAll = useCallback(() => {
105
107
  call?.muteAllUsers('audio');
@@ -113,7 +115,7 @@ const CallParticipantListContentHeader = ({
113
115
  requiredGrants={[OwnCapability.MUTE_USERS]}
114
116
  hasPermissionsOnly
115
117
  >
116
- <TextButton onClick={muteAll}>Mute all</TextButton>
118
+ <TextButton onClick={muteAll}>{t('Mute all')}</TextButton>
117
119
  </Restricted>
118
120
  )}
119
121
  </div>
@@ -17,6 +17,26 @@ test('checks single $neq condition', (t: TestContext) => {
17
17
  t.assert.ok(!applyFilter(obj, { num: { $neq: 42 } }));
18
18
  });
19
19
 
20
+ test('checks single $gt condition', (t: TestContext) => {
21
+ t.assert.ok(applyFilter(obj, { num: { $gt: 41 } }));
22
+ t.assert.ok(!applyFilter(obj, { num: { $gt: 42 } }));
23
+ });
24
+
25
+ test('checks single $gte condition', (t: TestContext) => {
26
+ t.assert.ok(applyFilter(obj, { num: { $gte: 42 } }));
27
+ t.assert.ok(!applyFilter(obj, { num: { $gte: 43 } }));
28
+ });
29
+
30
+ test('checks single $lt condition', (t: TestContext) => {
31
+ t.assert.ok(applyFilter(obj, { num: { $lt: 43 } }));
32
+ t.assert.ok(!applyFilter(obj, { num: { $lt: 42 } }));
33
+ });
34
+
35
+ test('checks single $lte condition', (t: TestContext) => {
36
+ t.assert.ok(applyFilter(obj, { num: { $lte: 42 } }));
37
+ t.assert.ok(!applyFilter(obj, { num: { $lte: 41 } }));
38
+ });
39
+
20
40
  test('checks single $in condition', (t: TestContext) => {
21
41
  t.assert.ok(applyFilter(obj, { num: { $in: [41, 42, 43] } }));
22
42
  t.assert.ok(!applyFilter(obj, { num: { $in: [1, 2, 3] } }));
@@ -14,11 +14,20 @@ export type ScalarOperator<T> =
14
14
  | EqOperator<T>
15
15
  | NeqOperator<T>
16
16
  | InOperator<T>
17
+ | GtOperator<T>
18
+ | GteOperator<T>
19
+ | LtOperator<T>
20
+ | LteOperator<T>
17
21
  | T;
18
22
 
19
23
  export type ArrayOperator<T> = ContainsOperator<T>;
20
24
 
25
+ export type AutocompleteOperator<T> = { $autocomplete: T };
21
26
  export type EqOperator<T> = { $eq: T };
27
+ export type GtOperator<T> = { $gt: T };
28
+ export type GteOperator<T> = { $gte: T };
29
+ export type LtOperator<T> = { $lt: T };
30
+ export type LteOperator<T> = { $lte: T };
22
31
  export type NeqOperator<T> = { $neq: T };
23
32
  export type InOperator<T> = { $in: Array<T> };
24
33
  export type ContainsOperator<T> = { $contains: T };
@@ -39,17 +48,33 @@ export function applyFilter<T>(obj: T, filter: Filter<T>): boolean {
39
48
  return checkConditions(obj, filter);
40
49
  }
41
50
 
51
+ type DateString = string;
52
+ const isDateString = (value: unknown): value is DateString =>
53
+ typeof value === 'string' &&
54
+ /^((?:(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2}(?:\.\d+)?))(Z|[+-]\d{2}:\d{2})?)$/.test(
55
+ value,
56
+ );
57
+
42
58
  function checkConditions<T>(obj: T, conditions: Conditions<T>): boolean {
43
59
  let match = true;
44
60
 
45
61
  for (const key of Object.keys(conditions) as Array<keyof T>) {
46
62
  const operator = conditions[key];
47
63
  const maybeOperator = operator && typeof operator === 'object';
48
- const value = obj[key];
64
+ let value: T[keyof T] | number = obj[key];
65
+
66
+ if (value instanceof Date) {
67
+ value = value.getTime();
68
+ } else if (isDateString(value)) {
69
+ value = new Date(value).getTime();
70
+ }
49
71
 
50
72
  if (maybeOperator && '$eq' in operator) {
51
73
  const eqOperator = operator as EqOperator<typeof value>;
52
- match &&= eqOperator.$eq === value;
74
+ const eqOperatorValue = isDateString(eqOperator.$eq)
75
+ ? new Date(eqOperator.$eq).getTime()
76
+ : eqOperator.$eq;
77
+ match &&= eqOperatorValue === value;
53
78
  } else if (maybeOperator && '$neq' in operator) {
54
79
  const neqOperator = operator as NeqOperator<typeof value>;
55
80
  match &&= neqOperator.$neq !== value;
@@ -65,6 +90,33 @@ function checkConditions<T>(obj: T, conditions: Conditions<T>): boolean {
65
90
  } else {
66
91
  match = false;
67
92
  }
93
+ } else if (maybeOperator && '$gt' in operator) {
94
+ const gtOperator = operator as GtOperator<typeof value>;
95
+ const gtOperatorValue = isDateString(gtOperator.$gt)
96
+ ? new Date(gtOperator.$gt).getTime()
97
+ : gtOperator.$gt;
98
+ match &&= value > gtOperatorValue;
99
+ } else if (maybeOperator && '$gte' in operator) {
100
+ const gteOperator = operator as GteOperator<typeof value>;
101
+ const gteOperatorValue = isDateString(gteOperator.$gte)
102
+ ? new Date(gteOperator.$gte).getTime()
103
+ : gteOperator.$gte;
104
+ match &&= value >= gteOperatorValue;
105
+ } else if (maybeOperator && '$lt' in operator) {
106
+ const ltOperator = operator as LtOperator<typeof value>;
107
+ const ltOperatorValue = isDateString(ltOperator.$lt)
108
+ ? new Date(ltOperator.$lt).getTime()
109
+ : ltOperator.$lt;
110
+ match &&= value < ltOperatorValue;
111
+ } else if (maybeOperator && '$lte' in operator) {
112
+ const lteOperator = operator as LteOperator<typeof value>;
113
+ const lteOperatorValue = isDateString(lteOperator.$lte)
114
+ ? new Date(lteOperator.$lte).getTime()
115
+ : lteOperator.$lte;
116
+ match &&= value <= lteOperatorValue;
117
+ // } else if (maybeOperator && '$autocomplete' in operator) {
118
+ // TODO: regexp solution maybe?
119
+ // match &&= false;
68
120
  } else {
69
121
  const eqValue = operator as typeof value;
70
122
  match &&= eqValue === value;