From ced372ca068086375024d59a977014efcadefef2 Mon Sep 17 00:00:00 2001 From: Federico Guerinoni <41150432+guerinoni@users.noreply.github.com> Date: Tue, 19 Sep 2023 18:10:30 +0200 Subject: [PATCH] feat: Update with new API spec (#1098) Signed-off-by: Federico Guerinoni --------- Signed-off-by: Federico Guerinoni Co-authored-by: Oliver Lazoroski --- .../src/__tests__/server-side/call.test.ts | 1 + packages/client/src/gen/coordinator/index.ts | 90 ++++++++++++------- packages/client/src/store/CallState.ts | 2 + .../components/CallRecordings.tsx | 3 +- .../src/components/Recordings/Recordings.tsx | 3 +- 5 files changed, 64 insertions(+), 35 deletions(-) diff --git a/packages/client/src/__tests__/server-side/call.test.ts b/packages/client/src/__tests__/server-side/call.test.ts index 7965dc9c84..f86db5b61e 100644 --- a/packages/client/src/__tests__/server-side/call.test.ts +++ b/packages/client/src/__tests__/server-side/call.test.ts @@ -120,6 +120,7 @@ describe('call API', () => { response = await call.update({ settings_override: { recording: { + mode: RecordSettingsRequestModeEnum.AVAILABLE, audio_only: false, quality: RecordSettingsRequestQualityEnum._1080P, }, diff --git a/packages/client/src/gen/coordinator/index.ts b/packages/client/src/gen/coordinator/index.ts index d173cf4a76..c9afafb5ae 100644 --- a/packages/client/src/gen/coordinator/index.ts +++ b/packages/client/src/gen/coordinator/index.ts @@ -814,7 +814,7 @@ export interface CallReactionEvent { type: string; } /** - * + * CallRecording represents a recording of a call. * @export * @interface CallRecording */ @@ -844,6 +844,62 @@ export interface CallRecording { */ url: string; } +/** + * This event is sent when call recording has failed + * @export + * @interface CallRecordingFailedEvent + */ +export interface CallRecordingFailedEvent { + /** + * + * @type {string} + * @memberof CallRecordingFailedEvent + */ + call_cid: string; + /** + * + * @type {string} + * @memberof CallRecordingFailedEvent + */ + created_at: string; + /** + * The type of event: "call.recording_failed" in this case + * @type {string} + * @memberof CallRecordingFailedEvent + */ + type: string; +} +/** + * This event is sent when call recording is ready + * @export + * @interface CallRecordingReadyEvent + */ +export interface CallRecordingReadyEvent { + /** + * + * @type {string} + * @memberof CallRecordingReadyEvent + */ + call_cid: string; + /** + * + * @type {CallRecording} + * @memberof CallRecordingReadyEvent + */ + call_recording: CallRecording; + /** + * + * @type {string} + * @memberof CallRecordingReadyEvent + */ + created_at: string; + /** + * The type of event: "call.recording_ready" in this case + * @type {string} + * @memberof CallRecordingReadyEvent + */ + type: string; +} /** * This event is sent when call recording has started * @export @@ -1487,12 +1543,6 @@ export interface CallSettingsResponse { * @interface CallStateResponseFields */ export interface CallStateResponseFields { - /** - * - * @type {Array} - * @memberof CallStateResponseFields - */ - blocked_users: Array; /** * * @type {CallResponse} @@ -2227,12 +2277,6 @@ export interface GeofenceSettingsRequest { * @interface GetCallResponse */ export interface GetCallResponse { - /** - * - * @type {Array} - * @memberof GetCallResponse - */ - blocked_users: Array; /** * * @type {CallResponse} @@ -2369,12 +2413,6 @@ export interface GetOrCreateCallRequest { * @interface GetOrCreateCallResponse */ export interface GetOrCreateCallResponse { - /** - * - * @type {Array} - * @memberof GetOrCreateCallResponse - */ - blocked_users: Array; /** * * @type {CallResponse} @@ -2611,12 +2649,6 @@ export interface JoinCallRequest { * @interface JoinCallResponse */ export interface JoinCallResponse { - /** - * - * @type {Array} - * @memberof JoinCallResponse - */ - blocked_users: Array; /** * * @type {CallResponse} @@ -4001,12 +4033,6 @@ export interface UpdateCallRequest { * @interface UpdateCallResponse */ export interface UpdateCallResponse { - /** - * - * @type {Array} - * @memberof UpdateCallResponse - */ - blocked_users: Array; /** * * @type {CallResponse} @@ -4314,6 +4340,8 @@ export type VideoEvent = | ({ type: 'call.permission_request' } & PermissionRequestEvent) | ({ type: 'call.permissions_updated' } & UpdatedCallPermissionsEvent) | ({ type: 'call.reaction_new' } & CallReactionEvent) + | ({ type: 'call.recording_failed' } & CallRecordingFailedEvent) + | ({ type: 'call.recording_ready' } & CallRecordingReadyEvent) | ({ type: 'call.recording_started' } & CallRecordingStartedEvent) | ({ type: 'call.recording_stopped' } & CallRecordingStoppedEvent) | ({ type: 'call.rejected' } & CallRejectedEvent) diff --git a/packages/client/src/store/CallState.ts b/packages/client/src/store/CallState.ts index 906db98253..956aac21d0 100644 --- a/packages/client/src/store/CallState.ts +++ b/packages/client/src/store/CallState.ts @@ -382,6 +382,8 @@ export class CallState { 'connection.error': undefined, 'connection.ok': undefined, 'health.check': undefined, + 'call.recording_failed': undefined, + 'call.recording_ready': undefined, custom: undefined, // events that update call state: diff --git a/sample-apps/react/react-dogfood/components/CallRecordings.tsx b/sample-apps/react/react-dogfood/components/CallRecordings.tsx index 525b592254..9d02837fc8 100644 --- a/sample-apps/react/react-dogfood/components/CallRecordings.tsx +++ b/sample-apps/react/react-dogfood/components/CallRecordings.tsx @@ -32,9 +32,8 @@ export const CallRecordings = () => { setLoadingCallRecordings(true), ); - // @ts-expect-error const unsubscribeRecordingReady = call.on('call.recording_ready', (e) => { - // FIXME OL this event isn't yet available in the OpenAPI schema + if (e.type !== 'call.recording_ready') return; const { call_recording: recording } = e; setCallRecordings((prev) => [...prev, recording]); setLoadingCallRecordings(false); diff --git a/sample-apps/react/react-video-demo/src/components/Recordings/Recordings.tsx b/sample-apps/react/react-video-demo/src/components/Recordings/Recordings.tsx index 5f8520cceb..3332cebf05 100644 --- a/sample-apps/react/react-video-demo/src/components/Recordings/Recordings.tsx +++ b/sample-apps/react/react-video-demo/src/components/Recordings/Recordings.tsx @@ -51,10 +51,9 @@ export const Recordings = () => { }, ); - // @ts-expect-error const unsubscribeRecordingReady = call.on('call.recording_ready', (e) => { + if (e.type !== 'call.recording_ready') return; try { - // FIXME OL this event isn't yet available in the OpenAPI schema const { call_recording: recording } = e; setCallRecordings((prev) => [...prev, recording]); } catch (error) {