Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update open api #63

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions __tests__/call.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,35 @@
});
});

it('closed caption settings', async () => {
const response = await call.update({
settings_override: {
transcription: {
mode: 'available',
closed_caption_mode: 'disabled',
},
},
});

expect(response.call.settings.transcription.mode).toBe('available');
expect(response.call.settings.transcription.closed_caption_mode).toBe(
'disabled',
);
expect(response.call.captioning).toBe(false);
});

it('should start-stop closed captions', async () => {
// somewhat dummy test, we should do a proper test in the future where we join a call and start recording
await expect(() => call.startClosedCaptions()).rejects.toThrowError(

Check failure on line 275 in __tests__/call.test.ts

View workflow job for this annotation

GitHub Actions / test-bun

__tests__/call.test.ts > call API > should start-stop closed captions

AssertionError: expected [Function] to throw error including 'Stream error code 4: StartClosedCapti…' but got 'Stream error code 16: Request failed …' - Expected + Received - Stream error code 4: StartClosedCaptions failed with error: "there is no active session" + Stream error code 16: Request failed with error: "Not Found" ❯ __tests__/call.test.ts:275:5

Check failure on line 275 in __tests__/call.test.ts

View workflow job for this annotation

GitHub Actions / test-bun

__tests__/call.test.ts > call API > should start-stop closed captions

AssertionError: expected [Function] to throw error including 'Stream error code 4: StartClosedCapti…' but got 'Stream error code 16: Request failed …' - Expected + Received - Stream error code 4: StartClosedCaptions failed with error: "there is no active session" + Stream error code 16: Request failed with error: "Not Found" ❯ __tests__/call.test.ts:275:5

Check failure on line 275 in __tests__/call.test.ts

View workflow job for this annotation

GitHub Actions / test-bun

__tests__/call.test.ts > call API > should start-stop closed captions

AssertionError: expected [Function] to throw error including 'Stream error code 4: StartClosedCapti…' but got 'Stream error code 16: Request failed …' - Expected + Received - Stream error code 4: StartClosedCaptions failed with error: "there is no active session" + Stream error code 16: Request failed with error: "Not Found" ❯ __tests__/call.test.ts:275:5

Check failure on line 275 in __tests__/call.test.ts

View workflow job for this annotation

GitHub Actions / test-bun

__tests__/call.test.ts > call API > should start-stop closed captions

AssertionError: expected [Function] to throw error including 'Stream error code 4: StartClosedCapti…' but got 'Stream error code 16: Request failed …' - Expected + Received - Stream error code 4: StartClosedCaptions failed with error: "there is no active session" + Stream error code 16: Request failed with error: "Not Found" ❯ __tests__/call.test.ts:275:5

Check failure on line 275 in __tests__/call.test.ts

View workflow job for this annotation

GitHub Actions / test-node (18)

__tests__/call.test.ts > call API > should start-stop closed captions

AssertionError: expected [Function] to throw error including 'Stream error code 4: StartClosedCapti…' but got 'Stream error code 16: Request failed …' - Expected + Received - Stream error code 4: StartClosedCaptions failed with error: "there is no active session" + Stream error code 16: Request failed with error: "Not Found" ❯ __tests__/call.test.ts:275:5

Check failure on line 275 in __tests__/call.test.ts

View workflow job for this annotation

GitHub Actions / test-node (18)

__tests__/call.test.ts > call API > should start-stop closed captions

AssertionError: expected [Function] to throw error including 'Stream error code 4: StartClosedCapti…' but got 'Stream error code 16: Request failed …' - Expected + Received - Stream error code 4: StartClosedCaptions failed with error: "there is no active session" + Stream error code 16: Request failed with error: "Not Found" ❯ __tests__/call.test.ts:275:5

Check failure on line 275 in __tests__/call.test.ts

View workflow job for this annotation

GitHub Actions / test-node (18)

__tests__/call.test.ts > call API > should start-stop closed captions

AssertionError: expected [Function] to throw error including 'Stream error code 4: StartClosedCapti…' but got 'Stream error code 16: Request failed …' - Expected + Received - Stream error code 4: StartClosedCaptions failed with error: "there is no active session" + Stream error code 16: Request failed with error: "Not Found" ❯ __tests__/call.test.ts:275:5

Check failure on line 275 in __tests__/call.test.ts

View workflow job for this annotation

GitHub Actions / test-node (18)

__tests__/call.test.ts > call API > should start-stop closed captions

AssertionError: expected [Function] to throw error including 'Stream error code 4: StartClosedCapti…' but got 'Stream error code 16: Request failed …' - Expected + Received - Stream error code 4: StartClosedCaptions failed with error: "there is no active session" + Stream error code 16: Request failed with error: "Not Found" ❯ __tests__/call.test.ts:275:5

Check failure on line 275 in __tests__/call.test.ts

View workflow job for this annotation

GitHub Actions / test-node (20)

__tests__/call.test.ts > call API > should start-stop closed captions

AssertionError: expected [Function] to throw error including 'Stream error code 4: StartClosedCapti…' but got 'Stream error code 16: Request failed …' - Expected + Received - Stream error code 4: StartClosedCaptions failed with error: "there is no active session" + Stream error code 16: Request failed with error: "Not Found" ❯ __tests__/call.test.ts:275:5

Check failure on line 275 in __tests__/call.test.ts

View workflow job for this annotation

GitHub Actions / test-node (20)

__tests__/call.test.ts > call API > should start-stop closed captions

AssertionError: expected [Function] to throw error including 'Stream error code 4: StartClosedCapti…' but got 'Stream error code 16: Request failed …' - Expected + Received - Stream error code 4: StartClosedCaptions failed with error: "there is no active session" + Stream error code 16: Request failed with error: "Not Found" ❯ __tests__/call.test.ts:275:5

Check failure on line 275 in __tests__/call.test.ts

View workflow job for this annotation

GitHub Actions / test-node (20)

__tests__/call.test.ts > call API > should start-stop closed captions

AssertionError: expected [Function] to throw error including 'Stream error code 4: StartClosedCapti…' but got 'Stream error code 16: Request failed …' - Expected + Received - Stream error code 4: StartClosedCaptions failed with error: "there is no active session" + Stream error code 16: Request failed with error: "Not Found" ❯ __tests__/call.test.ts:275:5

Check failure on line 275 in __tests__/call.test.ts

View workflow job for this annotation

GitHub Actions / test-node (20)

__tests__/call.test.ts > call API > should start-stop closed captions

AssertionError: expected [Function] to throw error including 'Stream error code 4: StartClosedCapti…' but got 'Stream error code 16: Request failed …' - Expected + Received - Stream error code 4: StartClosedCaptions failed with error: "there is no active session" + Stream error code 16: Request failed with error: "Not Found" ❯ __tests__/call.test.ts:275:5

Check failure on line 275 in __tests__/call.test.ts

View workflow job for this annotation

GitHub Actions / test-node (22)

__tests__/call.test.ts > call API > should start-stop closed captions

AssertionError: expected [Function] to throw error including 'Stream error code 4: StartClosedCapti…' but got 'Stream error code 16: Request failed …' - Expected + Received - Stream error code 4: StartClosedCaptions failed with error: "there is no active session" + Stream error code 16: Request failed with error: "Not Found" ❯ __tests__/call.test.ts:275:5

Check failure on line 275 in __tests__/call.test.ts

View workflow job for this annotation

GitHub Actions / test-node (22)

__tests__/call.test.ts > call API > should start-stop closed captions

AssertionError: expected [Function] to throw error including 'Stream error code 4: StartClosedCapti…' but got 'Stream error code 16: Request failed …' - Expected + Received - Stream error code 4: StartClosedCaptions failed with error: "there is no active session" + Stream error code 16: Request failed with error: "Not Found" ❯ __tests__/call.test.ts:275:5

Check failure on line 275 in __tests__/call.test.ts

View workflow job for this annotation

GitHub Actions / test-node (22)

__tests__/call.test.ts > call API > should start-stop closed captions

AssertionError: expected [Function] to throw error including 'Stream error code 4: StartClosedCapti…' but got 'Stream error code 16: Request failed …' - Expected + Received - Stream error code 4: StartClosedCaptions failed with error: "there is no active session" + Stream error code 16: Request failed with error: "Not Found" ❯ __tests__/call.test.ts:275:5

Check failure on line 275 in __tests__/call.test.ts

View workflow job for this annotation

GitHub Actions / test-node (22)

__tests__/call.test.ts > call API > should start-stop closed captions

AssertionError: expected [Function] to throw error including 'Stream error code 4: StartClosedCapti…' but got 'Stream error code 16: Request failed …' - Expected + Received - Stream error code 4: StartClosedCaptions failed with error: "there is no active session" + Stream error code 16: Request failed with error: "Not Found" ❯ __tests__/call.test.ts:275:5
'Stream error code 4: StartClosedCaptions failed with error: "there is no active session"',
);

// somewhat dummy test, we should do a proper test in the future where we join a call and start recording
await expect(() => call.stopClosedCaptions()).rejects.toThrowError(
'Stream error code 4: StopClosedCaptions failed with error: "call is not being transcribed"',
);
});

it('delete call', async () => {
try {
await call.delete({ hard: true });
Expand Down
4 changes: 3 additions & 1 deletion __tests__/create-test-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ const apiKey = process.env.STREAM_API_KEY!;
const secret = process.env.STREAM_SECRET!;

export const createTestClient = () => {
return new StreamClient(apiKey, secret, { timeout: 10000 });
return new StreamClient(apiKey, secret, {
timeout: 10000,
});
};
227 changes: 225 additions & 2 deletions src/gen/chat/ChatApi.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { BaseApi } from '../../BaseApi';
import { StreamResponse } from '../../types';
import {
CampaignResponse,
CastPollVoteRequest,
ChannelGetOrCreateRequest,
ChannelStateResponse,
Expand All @@ -16,18 +17,21 @@ import {
DeleteChannelsResponse,
DeleteCommandResponse,
DeleteMessageResponse,
DeleteSegmentTargetsRequest,
EventResponse,
ExportChannelsRequest,
ExportChannelsResponse,
FileUploadRequest,
FileUploadResponse,
GetCampaignResponse,
GetChannelTypeResponse,
GetCommandResponse,
GetExportChannelsStatusResponse,
GetManyMessagesResponse,
GetMessageResponse,
GetReactionsResponse,
GetRepliesResponse,
GetSegmentResponse,
GetThreadResponse,
HideChannelRequest,
HideChannelResponse,
Expand All @@ -50,6 +54,8 @@ import {
PollVotesResponse,
QueryBannedUsersPayload,
QueryBannedUsersResponse,
QueryCampaignsRequest,
QueryCampaignsResponse,
QueryChannelsRequest,
QueryChannelsResponse,
QueryMembersPayload,
Expand All @@ -62,6 +68,10 @@ import {
QueryPollsResponse,
QueryReactionsRequest,
QueryReactionsResponse,
QuerySegmentTargetsRequest,
QuerySegmentTargetsResponse,
QuerySegmentsRequest,
QuerySegmentsResponse,
QueryThreadsRequest,
QueryThreadsResponse,
ReactionRemovalResponse,
Expand All @@ -77,6 +87,9 @@ import {
ShowChannelRequest,
ShowChannelResponse,
SortParamRequest,
StartCampaignRequest,
StartCampaignResponse,
StopCampaignRequest,
TranslateMessageRequest,
TruncateChannelRequest,
TruncateChannelResponse,
Expand Down Expand Up @@ -108,6 +121,83 @@ import {
import { decoders } from '../model-decoders';

export class ChatApi extends BaseApi {
queryCampaigns = async (
request?: QueryCampaignsRequest,
): Promise<StreamResponse<QueryCampaignsResponse>> => {
const body = {
limit: request?.limit,
next: request?.next,
prev: request?.prev,
sort: request?.sort,
filter: request?.filter,
};

const response = await this.sendRequest<
StreamResponse<QueryCampaignsResponse>
>('POST', '/api/v2/chat/campaigns/query', undefined, undefined, body);

decoders.QueryCampaignsResponse?.(response.body);

return { ...response.body, metadata: response.metadata };
};

getCampaign = async (request: {
id: string;
}): Promise<StreamResponse<GetCampaignResponse>> => {
const pathParams = {
id: request?.id,
};

const response = await this.sendRequest<
StreamResponse<GetCampaignResponse>
>('GET', '/api/v2/chat/campaigns/{id}', pathParams, undefined);

decoders.GetCampaignResponse?.(response.body);

return { ...response.body, metadata: response.metadata };
};

startCampaign = async (
request: StartCampaignRequest & { id: string },
): Promise<StreamResponse<StartCampaignResponse>> => {
const pathParams = {
id: request?.id,
};
const body = {
scheduled_for: request?.scheduled_for,
stop_at: request?.stop_at,
};

const response = await this.sendRequest<
StreamResponse<StartCampaignResponse>
>('POST', '/api/v2/chat/campaigns/{id}/start', pathParams, undefined, body);

decoders.StartCampaignResponse?.(response.body);

return { ...response.body, metadata: response.metadata };
};

scheduleCampaign = async (
request: StopCampaignRequest & { id: string },
): Promise<StreamResponse<CampaignResponse>> => {
const pathParams = {
id: request?.id,
};
const body = {};

const response = await this.sendRequest<StreamResponse<CampaignResponse>>(
'POST',
'/api/v2/chat/campaigns/{id}/stop',
pathParams,
undefined,
body,
);

decoders.CampaignResponse?.(response.body);

return { ...response.body, metadata: response.metadata };
};

queryChannels = async (
request?: QueryChannelsRequest,
): Promise<StreamResponse<QueryChannelsResponse>> => {
Expand Down Expand Up @@ -712,6 +802,8 @@ export class ChatApi extends BaseApi {
read_events: request?.read_events,
replies: request?.replies,
search: request?.search,
skip_last_msg_update_for_system_msgs:
request?.skip_last_msg_update_for_system_msgs,
typing_events: request?.typing_events,
uploads: request?.uploads,
url_enrichment: request?.url_enrichment,
Expand Down Expand Up @@ -791,6 +883,8 @@ export class ChatApi extends BaseApi {
reminders: request?.reminders,
replies: request?.replies,
search: request?.search,
skip_last_msg_update_for_system_msgs:
request?.skip_last_msg_update_for_system_msgs,
typing_events: request?.typing_events,
uploads: request?.uploads,
url_enrichment: request?.url_enrichment,
Expand Down Expand Up @@ -1758,6 +1852,137 @@ export class ChatApi extends BaseApi {
return { ...response.body, metadata: response.metadata };
};

querySegments = async (
request: QuerySegmentsRequest,
): Promise<StreamResponse<QuerySegmentsResponse>> => {
const body = {
filter: request?.filter,
limit: request?.limit,
next: request?.next,
prev: request?.prev,
sort: request?.sort,
};

const response = await this.sendRequest<
StreamResponse<QuerySegmentsResponse>
>('POST', '/api/v2/chat/segments/query', undefined, undefined, body);

decoders.QuerySegmentsResponse?.(response.body);

return { ...response.body, metadata: response.metadata };
};

deleteSegment = async (request: {
id: string;
}): Promise<StreamResponse<Response>> => {
const pathParams = {
id: request?.id,
};

const response = await this.sendRequest<StreamResponse<Response>>(
'DELETE',
'/api/v2/chat/segments/{id}',
pathParams,
undefined,
);

decoders.Response?.(response.body);

return { ...response.body, metadata: response.metadata };
};

getSegment = async (request: {
id: string;
}): Promise<StreamResponse<GetSegmentResponse>> => {
const pathParams = {
id: request?.id,
};

const response = await this.sendRequest<StreamResponse<GetSegmentResponse>>(
'GET',
'/api/v2/chat/segments/{id}',
pathParams,
undefined,
);

decoders.GetSegmentResponse?.(response.body);

return { ...response.body, metadata: response.metadata };
};

deleteSegmentTargets = async (
request: DeleteSegmentTargetsRequest & { id: string },
): Promise<StreamResponse<Response>> => {
const pathParams = {
id: request?.id,
};
const body = {
target_ids: request?.target_ids,
};

const response = await this.sendRequest<StreamResponse<Response>>(
'POST',
'/api/v2/chat/segments/{id}/deletetargets',
pathParams,
undefined,
body,
);

decoders.Response?.(response.body);

return { ...response.body, metadata: response.metadata };
};

segmentTargetExists = async (request: {
id: string;
target_id: string;
}): Promise<StreamResponse<Response>> => {
const pathParams = {
id: request?.id,
target_id: request?.target_id,
};

const response = await this.sendRequest<StreamResponse<Response>>(
'GET',
'/api/v2/chat/segments/{id}/target/{target_id}',
pathParams,
undefined,
);

decoders.Response?.(response.body);

return { ...response.body, metadata: response.metadata };
};

controllerNameQuerySegmentTargets = async (
request: QuerySegmentTargetsRequest & { id: string },
): Promise<StreamResponse<QuerySegmentTargetsResponse>> => {
const pathParams = {
id: request?.id,
};
const body = {
limit: request?.limit,
next: request?.next,
prev: request?.prev,
sort: request?.sort,
filter: request?.filter,
};

const response = await this.sendRequest<
StreamResponse<QuerySegmentTargetsResponse>
>(
'POST',
'/api/v2/chat/segments/{id}/targets/query',
pathParams,
undefined,
body,
);

decoders.QuerySegmentTargetsResponse?.(response.body);

return { ...response.body, metadata: response.metadata };
};

queryThreads = async (
request?: QueryThreadsRequest,
): Promise<StreamResponse<QueryThreadsResponse>> => {
Expand All @@ -1783,13 +2008,11 @@ export class ChatApi extends BaseApi {

getThread = async (request: {
message_id: string;
connection_id?: string;
reply_limit?: number;
participant_limit?: number;
member_limit?: number;
}): Promise<StreamResponse<GetThreadResponse>> => {
const queryParams = {
connection_id: request?.connection_id,
reply_limit: request?.reply_limit,
participant_limit: request?.participant_limit,
member_limit: request?.member_limit,
Expand Down
Loading
Loading