Skip to content

Commit

Permalink
feat!: upgrade to API v113.0.0 (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
szuperaz authored May 14, 2024
1 parent cf29cfe commit cc0d00d
Show file tree
Hide file tree
Showing 12 changed files with 2,335 additions and 1,100 deletions.
16 changes: 8 additions & 8 deletions __tests__/call-types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { v4 as uuidv4 } from 'uuid';
import { createTestClient } from './create-test-client';
import { StreamClient } from '../src/StreamClient';
import {
VideoLayoutSettingsRequestNameEnum,
VideoOwnCapability,
VideoRecordSettingsRequestModeEnum,
VideoRecordSettingsRequestQualityEnum,
VideoLayoutSettingsNameEnum,
} from '../src/gen/video';

describe('call types CRUD API', () => {
Expand Down Expand Up @@ -64,14 +64,14 @@ describe('call types CRUD API', () => {
);
expect(createResponse.settings.screensharing.enabled).toBe(true);
expect(createResponse.notification_settings.enabled).toBe(true);
expect(createResponse.notification_settings.session_started.enabled).toBe(
expect(createResponse.notification_settings.session_started?.enabled).toBe(
false,
);
expect(createResponse.notification_settings.call_notification.enabled).toBe(
true,
);
expect(
createResponse.notification_settings.call_notification.apns.title,
createResponse.notification_settings.call_notification?.enabled,
).toBe(true);
expect(
createResponse.notification_settings.call_notification?.apns?.title,
).toBe('{{ user.display_name }} invites you to a call');
});

Expand Down Expand Up @@ -151,15 +151,15 @@ describe('call types CRUD API', () => {
audio_only: false,
quality: VideoRecordSettingsRequestQualityEnum._1080P,
layout: {
name: VideoLayoutSettingsNameEnum.SPOTLIGHT,
name: VideoLayoutSettingsRequestNameEnum.SPOTLIGHT,
options: layoutOptions,
},
},
},
});

expect(response.settings.recording.layout.name).toBe(
VideoLayoutSettingsNameEnum.SPOTLIGHT,
VideoLayoutSettingsRequestNameEnum.SPOTLIGHT,
);
Object.keys(layoutOptions).forEach((key) => {
expect(response.settings.recording.layout.options![key]).toEqual(
Expand Down
1 change: 1 addition & 0 deletions __tests__/teams.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe('teams', () => {
[user.id]: { ...user },
},
});
await client.updateAppSettings({ multi_tenant_enabled: true });
call = client.video.call('default', callId);
});

Expand Down
4 changes: 4 additions & 0 deletions __tests__/users.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ describe('user API', () => {
});

it('create guest', async () => {
await client.updateAppSettings({ multi_tenant_enabled: false });

const guest: UserObjectRequest = {
id: uuidv4(),
custom: {
Expand All @@ -89,6 +91,8 @@ describe('user API', () => {

expect(response.user?.role).toBe('guest');
expect(response.user?.custom.color).toBe('red');

await client.updateAppSettings({ multi_tenant_enabled: true });
});

it('ban and unban', async () => {
Expand Down
16 changes: 8 additions & 8 deletions src/StreamCall.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { StreamClient } from './StreamClient';
import {
DefaultApi,
GetCallRequest,
ProductvideoApi,
VideoBlockUserRequest,
VideoGetOrCreateCallRequest,
VideoGoLiveRequest,
VideoMuteUsersRequest,
VideoPinRequest,
VideoQueryMembersRequest,
VideoQueryCallMembersRequest,
VideoStartRecordingRequest,
VideoStartTranscriptionRequest,
VideoUnblockUserRequest,
Expand All @@ -20,7 +20,7 @@ import { OmitTypeId } from './types';

export class StreamCall {
private readonly baseRequest: { type: string; id: string };
private readonly apiClient: DefaultApi;
private readonly apiClient: ProductvideoApi;

constructor(
private readonly streamClient: StreamClient,
Expand All @@ -29,7 +29,7 @@ export class StreamCall {
) {
this.baseRequest = { id: this.id, type: this.type };
const configuration = this.streamClient.getConfiguration('video');
this.apiClient = new DefaultApi(configuration);
this.apiClient = new ProductvideoApi(configuration);
}

blockUser = (videoBlockUserRequest: VideoBlockUserRequest) => {
Expand Down Expand Up @@ -84,14 +84,14 @@ export class StreamCall {
});
};

queryMembers = (request?: OmitTypeId<VideoQueryMembersRequest>) => {
return this.apiClient.queryMembers({
videoQueryMembersRequest: { ...(request ?? {}), ...this.baseRequest },
queryMembers = (request?: OmitTypeId<VideoQueryCallMembersRequest>) => {
return this.apiClient.queryCallMembers({
videoQueryCallMembersRequest: { ...(request ?? {}), ...this.baseRequest },
});
};

sendCustomEvent = (event: Record<string, any>) => {
return this.apiClient.sendEvent({
return this.apiClient.sendCallEvent({
videoSendEventRequest: { custom: event },
...this.baseRequest,
});
Expand Down
32 changes: 13 additions & 19 deletions src/StreamVideoClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ import { StreamCall } from './StreamCall';
import { StreamClient } from './StreamClient';
import {
CheckExternalStorageRequest,
DefaultApi,
DeleteCallTypeRequest,
DeleteExternalStorageRequest,
GetCallTypeRequest,
ServerSideApi,
SettingsApi,
ProductvideoApi,
VideoCreateCallTypeRequest,
VideoCreateExternalStorageRequest,
VideoQueryCallsRequest,
Expand All @@ -16,15 +14,11 @@ import {
} from './gen/video';

export class StreamVideoClient {
private readonly apiClient: DefaultApi;
private readonly videoServerSideApiClient: ServerSideApi;
private readonly settingsApi: SettingsApi;
private readonly apiClient: ProductvideoApi;

constructor(private readonly streamClient: StreamClient) {
const configuration = this.streamClient.getConfiguration('video');
this.apiClient = new DefaultApi(configuration);
this.settingsApi = new SettingsApi(configuration);
this.videoServerSideApiClient = new ServerSideApi(configuration);
this.apiClient = new ProductvideoApi(configuration);
}

call = (type: string, id: string) => {
Expand All @@ -38,60 +32,60 @@ export class StreamVideoClient {
};

createCallType = (videoCreateCallTypeRequest: VideoCreateCallTypeRequest) => {
return this.videoServerSideApiClient.createCallType({
return this.apiClient.createCallType({
videoCreateCallTypeRequest,
});
};

deleteCallType = (request: DeleteCallTypeRequest) => {
return this.videoServerSideApiClient.deleteCallType(request);
return this.apiClient.deleteCallType(request);
};

getCallType = (request: GetCallTypeRequest) => {
return this.videoServerSideApiClient.getCallType(request);
return this.apiClient.getCallType(request);
};

listCallTypes = () => {
return this.videoServerSideApiClient.listCallTypes();
return this.apiClient.listCallTypes();
};

updateCallType = (
name: string,
videoUpdateCallTypeRequest: VideoUpdateCallTypeRequest,
) => {
return this.videoServerSideApiClient.updateCallType({
return this.apiClient.updateCallType({
name,
videoUpdateCallTypeRequest,
});
};

listExternalStorages = () => {
return this.settingsApi.listExternalStorage();
return this.apiClient.listExternalStorage();
};

createExternalStorage = (
videoCreateExternalStorageRequest: VideoCreateExternalStorageRequest,
) => {
return this.settingsApi.createExternalStorage({
return this.apiClient.createExternalStorage({
videoCreateExternalStorageRequest,
});
};

deleteExternalStorage = (request: DeleteExternalStorageRequest) => {
return this.settingsApi.deleteExternalStorage(request);
return this.apiClient.deleteExternalStorage(request);
};

updateExternalStorage = (
name: string,
videoUpdateExternalStorageRequest: VideoUpdateExternalStorageRequest,
) => {
return this.videoServerSideApiClient.updateExternalStorage({
return this.apiClient.updateExternalStorage({
name,
videoUpdateExternalStorageRequest,
});
};

checkExternalStorage = (request: CheckExternalStorageRequest) => {
return this.videoServerSideApiClient.checkExternalStorage(request);
return this.apiClient.checkExternalStorage(request);
};
}
4 changes: 1 addition & 3 deletions src/gen/video/.openapi-generator/FILES
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
.openapi-generator-ignore
apis/DefaultApi.ts
apis/ServerSideApi.ts
apis/SettingsApi.ts
apis/ProductvideoApi.ts
apis/index.ts
index.ts
models/index.ts
Expand Down
Loading

0 comments on commit cc0d00d

Please sign in to comment.