agora-appbuilder-core 4.1.7-beta.8 → 4.1.8-beta.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.
Files changed (32) hide show
  1. package/package.json +1 -1
  2. package/template/_package-lock.json +30671 -5376
  3. package/template/defaultConfig.js +2 -2
  4. package/template/esbuild.rsdk.go +1 -2
  5. package/template/package.json +0 -1
  6. package/template/src/AppWrapper.tsx +30 -35
  7. package/template/src/auth/AuthProvider.tsx +28 -35
  8. package/template/src/auth/IDPAuth.tsx +1 -14
  9. package/template/src/components/Controls.tsx +45 -15
  10. package/template/src/components/common/GenericModal.tsx +143 -0
  11. package/template/src/components/common/GenericPopup.tsx +152 -0
  12. package/template/src/components/common/data-table.tsx +385 -0
  13. package/template/src/components/controls/useControlPermissionMatrix.tsx +6 -7
  14. package/template/src/components/precall/usePreCall.tsx +1 -2
  15. package/template/src/components/stt-transcript/STTTranscriptTable.tsx +295 -0
  16. package/template/src/components/stt-transcript/ViewSTTTranscriptModal.tsx +44 -0
  17. package/template/src/components/stt-transcript/useFetchSTTTranscript.tsx +193 -0
  18. package/template/src/components/useUserPreference.tsx +0 -11
  19. package/template/src/language/default-labels/videoCallScreenLabels.ts +7 -0
  20. package/template/src/logger/AppBuilderLogger.tsx +1 -0
  21. package/template/src/pages/Create.tsx +2 -2
  22. package/template/src/pages/VideoCall.tsx +0 -5
  23. package/template/src/subComponents/LogoutButton.tsx +1 -11
  24. package/template/src/subComponents/recording/useRecordingLayoutQuery.tsx +83 -78
  25. package/template/src/utils/common.tsx +79 -1
  26. package/template/src/utils/useCreateRoom.ts +94 -112
  27. package/template/src/utils/useEndCall.ts +16 -3
  28. package/template/src/utils/useGetMeetingPhrase.ts +67 -76
  29. package/template/src/utils/useJoinRoom.ts +0 -3
  30. package/template/src/utils/useMutePSTN.ts +47 -45
  31. package/template/webpack.rsdk.config.js +1 -2
  32. package/template/src/components/GraphQLProvider.tsx +0 -122
@@ -1,31 +1,15 @@
1
1
  import {useContext} from 'react';
2
- import {gql} from '@apollo/client';
3
2
  import {RoomInfoContextInterface} from '../components/room-info/useRoomInfo';
4
3
  import {useSetRoomInfo} from '../components/room-info/useSetRoomInfo';
5
- import {GraphQLContext} from '../components/GraphQLProvider';
6
4
  import getUniqueID from './getUniqueID';
7
5
  import {LogSource, logger} from '../logger/AppBuilderLogger';
6
+ import StorageContext from '../components/StorageContext';
8
7
 
9
- const SHARE = gql`
10
- query share($passphrase: String!) {
11
- share(passphrase: $passphrase) {
12
- passphrase {
13
- host
14
- view
15
- }
16
- channel
17
- title
18
- pstn {
19
- number
20
- dtmf
21
- }
22
- }
23
- }
24
- `;
8
+ const SHARE_URL = `${$config.BACKEND_ENDPOINT}/v1/channel/share`;
25
9
 
26
10
  export default function useGetMeetingPhrase() {
27
11
  const {setRoomInfo} = useSetRoomInfo();
28
- const {client} = useContext(GraphQLContext);
12
+ const {store} = useContext(StorageContext);
29
13
  return async (phrase: string) => {
30
14
  const requestId = getUniqueID();
31
15
  const startReqTs = Date.now();
@@ -38,25 +22,77 @@ export default function useGetMeetingPhrase() {
38
22
  startReqTs,
39
23
  },
40
24
  );
41
- const response = await client.query({
42
- context: {
25
+ try {
26
+ const payload = JSON.stringify({
27
+ passphrase: phrase,
28
+ });
29
+ const res = await fetch(`${SHARE_URL}`, {
30
+ method: 'POST',
43
31
  headers: {
32
+ 'Content-Type': 'application/json',
33
+ authorization: store.token ? `Bearer ${store.token}` : '',
44
34
  'X-Request-Id': requestId,
45
35
  'X-Session-Id': logger.getSessionId(),
46
36
  },
47
- },
48
- query: SHARE,
49
- variables: {
50
- passphrase: phrase,
51
- },
52
- });
53
- const endReqTs = Date.now();
54
- if (response.error) {
37
+ body: payload,
38
+ });
39
+ const response = await res.json();
40
+ if (response?.error) {
41
+ throw response.error;
42
+ } else {
43
+ const endReqTs = Date.now();
44
+ logger.log(
45
+ LogSource.Internals,
46
+ 'GET_MEETING_PHRASE',
47
+ 'Query GET_MEETING_PHRASE success',
48
+ {
49
+ responseData: response,
50
+ requestId,
51
+ startReqTs,
52
+ endReqTs,
53
+ latency: endReqTs - startReqTs,
54
+ },
55
+ );
56
+ try {
57
+ if (response) {
58
+ let data = response;
59
+ let roomInfo: Partial<RoomInfoContextInterface['data']> = {
60
+ roomId: {attendee: ''},
61
+ };
62
+ if (data?.passphrases?.attendee) {
63
+ roomInfo.roomId.attendee = data.passphrases.attendee;
64
+ }
65
+ if (data?.passphrases?.host) {
66
+ roomInfo.roomId.host = data.passphrases.host;
67
+ }
68
+ if (data?.pstn) {
69
+ roomInfo.pstn = {
70
+ number: data.pstn.number,
71
+ pin: data.pstn.dtmf,
72
+ };
73
+ }
74
+ setRoomInfo(prevState => {
75
+ return {
76
+ ...prevState,
77
+ data: {
78
+ ...prevState.data,
79
+ roomId: roomInfo.roomId,
80
+ pstn: roomInfo?.pstn,
81
+ },
82
+ };
83
+ });
84
+ }
85
+ } catch (error) {
86
+ throw new Error('An error occurred in parsing the channel data.');
87
+ }
88
+ }
89
+ } catch (error) {
90
+ const endReqTs = Date.now();
55
91
  logger.error(
56
92
  LogSource.Internals,
57
93
  'GET_MEETING_PHRASE',
58
94
  'Query GET_MEETING_PHRASE failed',
59
- JSON.stringify(response?.error || {}),
95
+ JSON.stringify(error || {}),
60
96
  {
61
97
  requestId,
62
98
  startReqTs,
@@ -64,52 +100,7 @@ export default function useGetMeetingPhrase() {
64
100
  latency: endReqTs - startReqTs,
65
101
  },
66
102
  );
67
- throw response.error;
68
- } else {
69
- logger.log(
70
- LogSource.Internals,
71
- 'GET_MEETING_PHRASE',
72
- 'Query GET_MEETING_PHRASE success',
73
- {
74
- responseData: response,
75
- requestId,
76
- startReqTs,
77
- endReqTs,
78
- latency: endReqTs - startReqTs,
79
- },
80
- );
81
- try {
82
- if (response && response.data) {
83
- let data = response.data;
84
- let roomInfo: Partial<RoomInfoContextInterface['data']> = {
85
- roomId: {attendee: ''},
86
- };
87
- if (data?.share?.passphrase?.view) {
88
- roomInfo.roomId.attendee = data.share.passphrase.view;
89
- }
90
- if (data?.share?.passphrase?.host) {
91
- roomInfo.roomId.host = data.share.passphrase.host;
92
- }
93
- if (data?.share?.pstn) {
94
- roomInfo.pstn = {
95
- number: data.share.pstn.number,
96
- pin: data.share.pstn.dtmf,
97
- };
98
- }
99
- setRoomInfo(prevState => {
100
- return {
101
- ...prevState,
102
- data: {
103
- ...prevState.data,
104
- roomId: roomInfo.roomId,
105
- pstn: roomInfo?.pstn,
106
- },
107
- };
108
- });
109
- }
110
- } catch (error) {
111
- throw new Error('An error occurred in parsing the channel data.');
112
- }
103
+ throw error;
113
104
  }
114
105
  };
115
106
  }
@@ -1,10 +1,7 @@
1
1
  import {useContext} from 'react';
2
- import {gql} from '@apollo/client';
3
2
  import StorageContext from '../components/StorageContext';
4
3
  import {RoomInfoContextInterface} from '../components/room-info/useRoomInfo';
5
4
  import {useSetRoomInfo} from '../components/room-info/useSetRoomInfo';
6
- import {GraphQLContext} from '../components/GraphQLProvider';
7
- import useGetName from './useGetName';
8
5
  import useWaitingRoomAPI from '../subComponents/waiting-rooms/useWaitingRoomAPI';
9
6
  import {base64ToUint8Array} from '../utils';
10
7
  import {LogSource, logger} from '../logger/AppBuilderLogger';
@@ -1,23 +1,18 @@
1
- import {gql, useMutation} from '@apollo/client';
2
1
  import {UidType} from '../../agora-rn-uikit';
3
2
  import {useRoomInfo} from '../components/room-info/useRoomInfo';
4
3
  import useIsPSTN from './useIsPSTN';
5
4
  import getUniqueID from './getUniqueID';
6
5
  import {LogSource, logger} from '../logger/AppBuilderLogger';
7
- const MUTE_PSTN = gql`
8
- mutation mutePSTN($uid: Int!, $passphrase: String!, $mute: Boolean!) {
9
- mutePSTN(uid: $uid, passphrase: $passphrase, mute: $mute) {
10
- uid
11
- mute
12
- }
13
- }
14
- `;
6
+ import {useContext} from 'react';
7
+ import StorageContext from '../components/StorageContext';
8
+
9
+ const MUTE_PSTN_URL = `${$config.BACKEND_ENDPOINT}/v1/channel/pstn/mute`;
15
10
 
16
11
  const useMutePSTN = () => {
17
- const [mutePSTN, {data, loading, error}] = useMutation(MUTE_PSTN);
18
12
  const {
19
13
  data: {isHost, roomId},
20
14
  } = useRoomInfo();
15
+ const {store} = useContext(StorageContext);
21
16
  const isPSTN = useIsPSTN();
22
17
  return async (uid: UidType) => {
23
18
  const startReqTs = Date.now();
@@ -30,48 +25,55 @@ const useMutePSTN = () => {
30
25
  'Mutation try to call MUTE_PSTN ',
31
26
  {startReqTs, requestId},
32
27
  );
33
- await mutePSTN({
34
- context: {
28
+ const payload = JSON.stringify({
29
+ uid: uid?.toString(),
30
+ passphrase: roomId?.host,
31
+ mute: true,
32
+ });
33
+ try {
34
+ const res = await fetch(`${MUTE_PSTN_URL}`, {
35
+ method: 'POST',
35
36
  headers: {
37
+ 'Content-Type': 'application/json',
38
+ authorization: store.token ? `Bearer ${store.token}` : '',
36
39
  'X-Request-Id': requestId,
37
40
  'X-Session-Id': logger.getSessionId(),
38
41
  },
39
- },
40
- variables: {
41
- uid: uid,
42
- passphrase: roomId?.host,
43
- //todo: hari need to test mute flag for PSTN
44
- mute: 1,
45
- },
46
- });
42
+ body: payload,
43
+ });
44
+ const response = await res.json();
45
+
46
+ if (response?.error) {
47
+ throw response?.error;
48
+ } else {
49
+ const endReqTs = Date.now();
50
+ logger.log(
51
+ LogSource.Internals,
52
+ 'MUTE_PSTN',
53
+ 'Mutation MUTE_PSTN success',
54
+ {startReqTs, endReqTs, latency: endReqTs - startReqTs, requestId},
55
+ );
56
+ return response;
57
+ }
58
+ } catch (error) {
59
+ const endReqTs = Date.now();
60
+ logger.error(
61
+ LogSource.Internals,
62
+ 'MUTE_PSTN',
63
+ 'Mutation MUTE_PSTN success',
64
+ JSON.stringify(error || {}),
65
+ {
66
+ startReqTs,
67
+ endReqTs,
68
+ latency: endReqTs - startReqTs,
69
+ requestId,
70
+ },
71
+ );
72
+ throw error;
73
+ }
47
74
  } else {
48
75
  console.error('UID does not belong to the PSTN user.');
49
76
  }
50
- if (!loading && error) {
51
- const endReqTs = Date.now();
52
- logger.error(
53
- LogSource.Internals,
54
- 'MUTE_PSTN',
55
- 'Mutation MUTE_PSTN success',
56
- JSON.stringify(error || {}),
57
- {
58
- startReqTs,
59
- endReqTs,
60
- latency: endReqTs - startReqTs,
61
- requestId,
62
- },
63
- );
64
- throw error;
65
- } else {
66
- const endReqTs = Date.now();
67
- logger.log(
68
- LogSource.Internals,
69
- 'MUTE_PSTN',
70
- 'Mutation MUTE_PSTN success',
71
- {startReqTs, endReqTs, latency: endReqTs - startReqTs, requestId},
72
- );
73
- return data;
74
- }
75
77
  } else {
76
78
  console.error('A host can only mute audience audio or video.');
77
79
  }
@@ -1,6 +1,6 @@
1
1
  const commons = require('./webpack.commons');
2
2
  const path = require('path');
3
- const { merge } = require('webpack-merge');
3
+ const {merge} = require('webpack-merge');
4
4
 
5
5
  const isDevelopment = process.env.NODE_ENV === 'development';
6
6
 
@@ -16,7 +16,6 @@ module.exports = merge(commons, {
16
16
  'react-dom': 'react-dom',
17
17
  'react-router': 'react-router',
18
18
  'react-router-dom': 'react-router-dom',
19
- '@apollo/client': '@apollo/client',
20
19
  },
21
20
  // Main entry point for the web application
22
21
  entry: {
@@ -1,122 +0,0 @@
1
- /*
2
- ********************************************
3
- Copyright © 2021 Agora Lab, Inc., all rights reserved.
4
- AppBuilder and all associated components, source code, APIs, services, and documentation
5
- (the “Materials”) are owned by Agora Lab, Inc. and its licensors. The Materials may not be
6
- accessed, used, modified, or distributed for any purpose without a license from Agora Lab, Inc.
7
- Use without a license or in violation of any license terms and conditions (including use for
8
- any purpose competitive to Agora Lab, Inc.’s business) is strictly prohibited. For more
9
- information visit https://appbuilder.agora.io.
10
- *********************************************
11
- */
12
- import {
13
- ApolloClient,
14
- createHttpLink,
15
- InMemoryCache,
16
- ApolloProvider,
17
- NormalizedCacheObject,
18
- ApolloLink,
19
- // from,
20
- } from '@apollo/client';
21
- import React, {createContext, useContext, useEffect, useState} from 'react';
22
- import getUniqueID from '../../src/utils/getUniqueID';
23
- import StorageContext from './StorageContext';
24
-
25
- export const GraphQLContext = createContext<{
26
- client: ApolloClient<NormalizedCacheObject>;
27
- }>({
28
- //@ts-ignore
29
- client: {},
30
- });
31
-
32
- const httpLink = createHttpLink({
33
- uri: `${$config.BACKEND_ENDPOINT}/v1/query`,
34
- credentials: 'include',
35
- });
36
-
37
- const cache = new InMemoryCache();
38
-
39
- const DEFAULT_CLIENT = new ApolloClient({
40
- link: httpLink,
41
- cache: cache,
42
- });
43
-
44
- const authLink = (token: string) => {
45
- /**
46
- * Below we create a new link, whenever a token changes, set
47
- * context with headers and forward the link so as to
48
- * execute the next link in the chain
49
- */
50
- return new ApolloLink((operation, forward) => {
51
- if (token) {
52
- operation.setContext(({headers = {}}) => ({
53
- headers: {
54
- ...headers,
55
- 'X-Project-ID': $config.PROJECT_ID,
56
- 'X-Platform-ID': 'turnkey_web',
57
- ...(token && {
58
- authorization: token ? `Bearer ${token}` : '',
59
- }),
60
- },
61
- }));
62
- }
63
- return forward(operation);
64
- });
65
- };
66
-
67
- const GraphQLProvider = (props: {children: React.ReactNode}) => {
68
- const {store} = useContext(StorageContext);
69
- const [client, setClient] = useState(DEFAULT_CLIENT);
70
-
71
- // useEffect(() => {
72
- // setClient(
73
- // new ApolloClient({
74
- // link: authLink(store?.token).concat(httpLink),
75
- // cache: new InMemoryCache(),
76
- // }),
77
- // );
78
- // }, [store?.token]);
79
-
80
- useEffect(() => {
81
- if (!store?.token) {
82
- return;
83
- }
84
- (async () => {
85
- const link = authLink(store?.token).concat(httpLink);
86
- setClient(new ApolloClient({link, cache}));
87
- })();
88
- }, [store?.token]);
89
-
90
- // const errorLink = onError(
91
- // ({graphQLErrors, networkError, operation, forward}) => {
92
- // // To retry on network errors, we recommend the RetryLink
93
- // // instead of the onError link. This just logs the error.
94
- // if (networkError) {
95
-
96
- // // switch (err.extensions.code) {
97
- // // // Apollo Server sets code to UNAUTHENTICATED
98
- // // // when an AuthenticationError is thrown in a resolver
99
- // // case 'UNAUTHENTICATED':
100
- // // // Modify the operation context with a new token
101
- // // const oldHeaders = operation.getContext().headers;
102
- // // operation.setContext({
103
- // // headers: {
104
- // // ...oldHeaders,
105
- // // authorization: getNewToken(),
106
- // // },
107
- // // });
108
- // // // Retry the request, returning the new observable
109
- // // return forward(operation);
110
- // // }
111
- // }
112
- // },
113
- // );
114
-
115
- return (
116
- <GraphQLContext.Provider value={{client: client}}>
117
- <ApolloProvider client={client}>{props.children}</ApolloProvider>
118
- </GraphQLContext.Provider>
119
- );
120
- };
121
-
122
- export default GraphQLProvider;