Skip to content

Commit

Permalink
Generate event page
Browse files Browse the repository at this point in the history
  • Loading branch information
szuperaz committed Dec 13, 2023
1 parent 59abf8a commit 47e2eb0
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 43 deletions.
36 changes: 36 additions & 0 deletions docusaurus/video/docusaurus/docs/api/_common_/EventApiModels.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React from 'react';
import OpenApiModels from './OpenApiModels';
import apiJson from '../video-openapi.json';

const filter = (apiJson) =>
Object.keys(apiJson.components.schemas).filter(
(key) =>
apiJson.components.schemas[key]['x-stream-event-call-type'] === true,
);

const events = filter(apiJson).map(key => {
const type = apiJson.components.schemas[key].properties.type.default || '-';
const description = apiJson.components.schemas[key].description || '-';

return {key, type, description}
});

events.sort((e1, e2) => e1.type < e2.type ? -1 : (e1.type > e2.type ? 1 : 0));

const EventApiModels = () => {
return <React.Fragment>
<table>
<thead>
<th>Name</th>
<th>Description</th>
</thead>
{events.map(event => <tr>
<td><a href={'#' + event.key}><code>{event.type}</code></a></td>
<td>{event.description}</td>
</tr>)}
</table>
<OpenApiModels modelFilter={filter} recursive={true}></OpenApiModels>
</React.Fragment>
}

export default EventApiModels;
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import React from 'react';
import apiJson from '../video-openapi.json';

const OpenApiModel = ({ modelName, recursive = true }) => {
const OpenApiModels = ({ modelName, modelFilter, recursive = true }) => {

const models = React.useMemo(() => {
const modelsResult = [{name: modelName, properties: []}];
if (!modelName && !modelFilter) {
return [];
}
const modelsResult = modelName ? [{name: modelName, properties: []}] : modelFilter(apiJson).map(key => ({name: key, properties: []}));

for (let i = 0; i < modelsResult.length; i++) {
const model = modelsResult[i];
Expand All @@ -24,8 +27,13 @@ const OpenApiModel = ({ modelName, recursive = true }) => {
const ref = isArray ? property.items?.$ref : property.$ref;
// Example $ref: #/components/schemas/EdgeResponse
type = ref?.split('/')?.pop() || '';
typeHref = `#${type}`
if (recursive && apiJson.components.schemas[type] && !modelsResult.find(r => r.name === type)) {
// enums are not yet parsed
let isEnum = apiJson.components.schemas[type] && !apiJson.components.schemas[type].properties;
if (recursive && !isEnum) {
typeHref = `#${type}`;
}
// if properties are undefined, it's an enum, we don't yet parse enums
if (recursive && !isEnum && apiJson.components.schemas[type] && !modelsResult.find(r => r.name === type)) {
modelsResult.push({name: type, properties: []});
}
} else {
Expand Down Expand Up @@ -66,7 +74,7 @@ const OpenApiModel = ({ modelName, recursive = true }) => {
}

return modelsResult;
}, [modelName]);
}, [modelName, modelFilter]);

return (
<div>
Expand Down Expand Up @@ -103,4 +111,4 @@ const OpenApiModel = ({ modelName, recursive = true }) => {
);
};

export default OpenApiModel;
export default OpenApiModels;
4 changes: 2 additions & 2 deletions docusaurus/video/docusaurus/docs/api/basics/calls.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import CallFilters from '../../../shared/video/_call-filters.mdx';
import CallMemberFilters from '../../../shared/video/_call-member-filters.mdx';
import CallSort from '../../../shared/video/_call-sort-fields.mdx';
import CallMemberSort from '../../../shared/video/_call-member-sort-fields.mdx';
import OpenApiModel from '../_common_/OpenApiModel';
import OpenApiModels from '../_common_/OpenApiModels';

## Creating calls

Expand Down Expand Up @@ -71,7 +71,7 @@ await client.call('default', 'test-outgoing-call').getOrCreate({

### Model

<OpenApiModel modelName={'GetOrCreateCallRequest'}></OpenApiModel>
<OpenApiModels modelName={'GetOrCreateCallRequest'}></OpenApiModels>

## Updating calls

Expand Down
38 changes: 3 additions & 35 deletions docusaurus/video/docusaurus/docs/api/webhooks/events.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,8 @@ slug: /streaming/events
title: Events
---

Here you can find the list of events are sent to Webhook and SQS.

| Event Type | Description |
|---------------------------------|---------------------------------------------------|
| custom | Sent when a custom event is triggered |
| call.accepted | Sent when a user accepts an incoming call |
| call.blocked_user | Sent when a user is blocked |
| call.broadcasting_started | Sent when HLS broadcasting has started |
| call.broadcasting_failed | Sent when HLS broadcasting has failed |
| call.broadcasting_stopped | Sent when HLS broadcasting is stopped |
| call.created | Sent when a call is created |
| call.ended | Sent when a call is marked as ended |
| call.live_started | Sent when a call goes live |
| call.member_added | Sent when a member is added |
| call.member_removed | Sent when a member is removed |
| call.member_updated | Sent when a member is updated |
| call.member_updated_permission | Sent when permissions are updated for a member |
| call.permission_request | Sent when a user requests access on a call |
| call.permissions_updated | Sent when permissions are updated on a call |
| call.reaction_new | Sent when a reaction is sent on a call |
| call.rejected | Sent when a user rejects an incoming call |
| call.session_ended | Sent when the session has ended |
| call.session_participant_joined | Sent when a user joins a call |
| call.session_participant_left | Sent when a user leaves a call |
| call.session_started | Sent when a call session starts |
| call.unblocked_user | Sent when a user is unblocked |
| call.user_muted | Sent when a call member is muted |
| call.ring | Sent when a user rings others to join a call |
| call.notification | Sent when a user notifies others to join a call |
| call.updated | Sent when a call is updated |
| call.recording_started | Sent when call recording has started |
| call.recording_stopped | Sent when call recording has stopped |
| call.recording_ready | Sent when the recording is available for download |
| call.recording_failed | Sent when recording fails for any reason |
import EventApiModels from '../_common_/EventApiModels';

Here you can find the list of events are sent to Webhook and SQS.

You can find the definition of each events in the OpenAPI spec available [here](https://github.com/GetStream/protocol/blob/main/openapi/video-openapi.yaml)
<EventApiModels />

0 comments on commit 47e2eb0

Please sign in to comment.