Skip to content

Commit

Permalink
feat: update open api
Browse files Browse the repository at this point in the history
  • Loading branch information
szuperaz committed Oct 10, 2024
1 parent c63222d commit ffeca67
Show file tree
Hide file tree
Showing 7 changed files with 304 additions and 138 deletions.
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 @@ describe('call API', () => {
});
});

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-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-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 (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,
});
};
77 changes: 35 additions & 42 deletions src/gen/model-decoders/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ decoders.ChannelStateResponse = (input?: Record<string, any>) => {

pinned_messages: { type: 'MessageResponse', isSingle: false },

threads: { type: 'ThreadState', isSingle: false },
threads: { type: 'ThreadStateResponse', isSingle: false },

hide_messages_before: { type: 'DatetimeType', isSingle: true },

Expand All @@ -396,7 +396,7 @@ decoders.ChannelStateResponseFields = (input?: Record<string, any>) => {

pinned_messages: { type: 'MessageResponse', isSingle: false },

threads: { type: 'ThreadState', isSingle: false },
threads: { type: 'ThreadStateResponse', isSingle: false },

hide_messages_before: { type: 'DatetimeType', isSingle: true },

Expand Down Expand Up @@ -1013,7 +1013,7 @@ decoders.MessageResponse = (input?: Record<string, any>) => {

poll: { type: 'Poll', isSingle: true },

quoted_message: { type: 'Message', isSingle: true },
quoted_message: { type: 'MessageResponse', isSingle: true },

reaction_groups: { type: 'ReactionGroupResponse', isSingle: false },
};
Expand Down Expand Up @@ -1050,13 +1050,24 @@ decoders.MessageWithChannelResponse = (input?: Record<string, any>) => {

poll: { type: 'Poll', isSingle: true },

quoted_message: { type: 'Message', isSingle: true },
quoted_message: { type: 'MessageResponse', isSingle: true },

reaction_groups: { type: 'ReactionGroupResponse', isSingle: false },
};
return decode(typeMappings, input);
};

decoders.ModerationConfig = (input?: Record<string, any>) => {
const typeMappings: TypeMapping = {
created_at: { type: 'DatetimeType', isSingle: true },

updated_at: { type: 'DatetimeType', isSingle: true },

velocity_filter_config: { type: 'VelocityFilterConfig', isSingle: true },
};
return decode(typeMappings, input);
};

decoders.ModerationUsageStats = (input?: Record<string, any>) => {
const typeMappings: TypeMapping = {
updated_at: { type: 'DatetimeType', isSingle: true },
Expand Down Expand Up @@ -1306,6 +1317,13 @@ decoders.QueryMessageHistoryResponse = (input?: Record<string, any>) => {
return decode(typeMappings, input);
};

decoders.QueryModerationConfigsResponse = (input?: Record<string, any>) => {
const typeMappings: TypeMapping = {
configs: { type: 'ModerationConfig', isSingle: false },
};
return decode(typeMappings, input);
};

decoders.QueryModerationLogsResponse = (input?: Record<string, any>) => {
const typeMappings: TypeMapping = {
l_og_s: { type: 'ActionLogResponse', isSingle: false },
Expand Down Expand Up @@ -1469,13 +1487,13 @@ decoders.SearchResultMessage = (input?: Record<string, any>) => {

updated_at: { type: 'DatetimeType', isSingle: true },

latest_reactions: { type: 'Reaction', isSingle: false },
latest_reactions: { type: 'ReactionResponse', isSingle: false },

mentioned_users: { type: 'UserObject', isSingle: false },
mentioned_users: { type: 'UserResponse', isSingle: false },

own_reactions: { type: 'Reaction', isSingle: false },
own_reactions: { type: 'ReactionResponse', isSingle: false },

reaction_groups: { type: 'ReactionGroupResponse', isSingle: false },
user: { type: 'UserResponse', isSingle: true },

deleted_at: { type: 'DatetimeType', isSingle: true },

Expand All @@ -1485,17 +1503,17 @@ decoders.SearchResultMessage = (input?: Record<string, any>) => {

pinned_at: { type: 'DatetimeType', isSingle: true },

thread_participants: { type: 'UserObject', isSingle: false },
thread_participants: { type: 'UserResponse', isSingle: false },

channel: { type: 'ChannelResponse', isSingle: true },

pinned_by: { type: 'UserObject', isSingle: true },
pinned_by: { type: 'UserResponse', isSingle: true },

poll: { type: 'Poll', isSingle: true },

quoted_message: { type: 'Message', isSingle: true },
quoted_message: { type: 'MessageResponse', isSingle: true },

user: { type: 'UserObject', isSingle: true },
reaction_groups: { type: 'ReactionGroupResponse', isSingle: false },
};
return decode(typeMappings, input);
};
Expand Down Expand Up @@ -1566,31 +1584,6 @@ decoders.ThreadResponse = (input?: Record<string, any>) => {
return decode(typeMappings, input);
};

decoders.ThreadState = (input?: Record<string, any>) => {
const typeMappings: TypeMapping = {
created_at: { type: 'DatetimeType', isSingle: true },

updated_at: { type: 'DatetimeType', isSingle: true },

latest_replies: { type: 'Message', isSingle: false },

deleted_at: { type: 'DatetimeType', isSingle: true },

last_message_at: { type: 'DatetimeType', isSingle: true },

read: { type: 'Read', isSingle: false },

thread_participants: { type: 'ThreadParticipant', isSingle: false },

channel: { type: 'Channel', isSingle: true },

created_by: { type: 'UserObject', isSingle: true },

parent_message: { type: 'Message', isSingle: true },
};
return decode(typeMappings, input);
};

decoders.ThreadStateResponse = (input?: Record<string, any>) => {
const typeMappings: TypeMapping = {
created_at: { type: 'DatetimeType', isSingle: true },
Expand All @@ -1611,7 +1604,7 @@ decoders.ThreadStateResponse = (input?: Record<string, any>) => {

created_by: { type: 'UserResponse', isSingle: true },

parent_message: { type: 'Message', isSingle: true },
parent_message: { type: 'MessageResponse', isSingle: true },
};
return decode(typeMappings, input);
};
Expand Down Expand Up @@ -1695,7 +1688,7 @@ decoders.UpdateChannelResponse = (input?: Record<string, any>) => {

channel: { type: 'ChannelResponse', isSingle: true },

message: { type: 'Message', isSingle: true },
message: { type: 'MessageResponse', isSingle: true },
};
return decode(typeMappings, input);
};
Expand Down Expand Up @@ -1725,14 +1718,14 @@ decoders.UpdateMemberPartialResponse = (input?: Record<string, any>) => {

decoders.UpdateMessagePartialResponse = (input?: Record<string, any>) => {
const typeMappings: TypeMapping = {
message: { type: 'Message', isSingle: true },
message: { type: 'MessageResponse', isSingle: true },
};
return decode(typeMappings, input);
};

decoders.UpdateMessageResponse = (input?: Record<string, any>) => {
const typeMappings: TypeMapping = {
message: { type: 'Message', isSingle: true },
message: { type: 'MessageResponse', isSingle: true },
};
return decode(typeMappings, input);
};
Expand Down Expand Up @@ -1860,7 +1853,7 @@ decoders.UserResponse = (input?: Record<string, any>) => {

decoders.VelocityFilterConfig = (input?: Record<string, any>) => {
const typeMappings: TypeMapping = {
rule: { type: 'VelocityFilterConfigRule', isSingle: false },
rules: { type: 'VelocityFilterConfigRule', isSingle: false },
};
return decode(typeMappings, input);
};
Expand Down
Loading

0 comments on commit ffeca67

Please sign in to comment.