diff --git a/CHANGELOG.md b/CHANGELOG.md index 6cc8dd8..2bed435 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Changelog +## [0.1.12](https://github.com/GetStream/stream-node/compare/v0.1.11...v0.1.12) (2024-03-08) + + +### Features + +* update video to api v100.4.3 ([#22](https://github.com/GetStream/stream-node/issues/22)) ([2424b2d](https://github.com/GetStream/stream-node/commit/2424b2db10353dc46cd9c78c543666732228d5c7)) + + +### Bug Fixes + +* basePath not stored properly ([#20](https://github.com/GetStream/stream-node/issues/20)) ([3221ba0](https://github.com/GetStream/stream-node/commit/3221ba0ec1fe0bf002c6cf21794f23f1d6a818fd)) + ## [0.1.11](https://github.com/GetStream/stream-node/compare/v0.1.10...v0.1.11) (2024-02-29) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 18f8ac2..dbfff79 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -30,6 +30,8 @@ If you don't want to squash your commits, make sure that your commits follow the ## Generating code from Open API +### Commands + Checkout the [protocol](https://github.com/GetStream/protocol) or [chat](https://github.com/GetStream/chat) reporisitories and run one of the following commands: ```shell @@ -39,10 +41,19 @@ $ yarn generate:open-api $ yarn generate:open-api:dev ``` -Fix manually the known issues issues in the generated code: +If you want to update only chat or video you need to define the `PRODUCT` env variable like this: + +```shell +$ PRODUCT=video yarn generate:open-api +$ PRODUCT=chat yarn generate:open-api:dev +``` -- Add `/** @ts-expect-error */ ` for imports for `ImageSizeRequest`, `OnlyUserIDRequest` in the `gen/chat/FilesApi.ts` and `gen/chat/MessagesApi.ts` files -- Add `/** @ts-expect-error */ ` for duplicate exports in `gen/chat/index.ts` +### Fix issues in chat code + +If you have updated the generated chat code you'll have to fix the following issues manually in the generated code: + +- Add `/** @ts-expect-error */ ` (make sure to use this exact comment format otherwise they will be missing from `d.ts` files) for imports for `ImageSizeRequest`, `OnlyUserIDRequest` in the `gen/chat/FilesApi.ts` and `gen/chat/MessagesApi.ts` files +- Add `/** @ts-expect-error */ ` (make sure to use this exact comment format otherwise they will be missing from `d.ts` files) for duplicate exports in `gen/chat/index.ts` - Fix the query param serizalization in the `gen/chat/MessagesApi.ts` file's `getManyMessagesRaw` function. This is the correct serialization: ```typescript @@ -51,6 +62,8 @@ if (requestParameters.ids) { } ``` +### Validate that the generated code works + To check your work, run the following commands: ``` diff --git a/generate-openapi.sh b/generate-openapi.sh index 36a6e07..4e03b4b 100755 --- a/generate-openapi.sh +++ b/generate-openapi.sh @@ -2,76 +2,98 @@ set -euo pipefail FROM_REPO=$1; +DEFAULT_PRODUCT="all"; +PRODUCT="${2:-$DEFAULT_PRODUCT}"; -if [ "$FROM_REPO" == 'chat' ]; then - PROTOCOL_REPO_DIR="../chat" -else - PROTOCOL_REPO_DIR="../protocol" -fi -if [ "$FROM_REPO" == 'chat' ]; then - SCHEMA_FILE="$PROTOCOL_REPO_DIR/releases/video-openapi.yaml" -else - SCHEMA_FILE="$PROTOCOL_REPO_DIR/openapi/video-openapi.yaml" -fi +echo $PRODUCT; -if [ "$FROM_REPO" == 'chat' ]; then - # Generate the Coordinator OpenAPI schema - make -C $PROTOCOL_REPO_DIR video-openapi +if [ "$PRODUCT" != 'chat' ] && [ "$PRODUCT" != 'video' ] && [ "$PRODUCT" != 'all' ]; then + echo "Invalid product option $PRODUCT" + exit 1 fi -OUTPUT_DIR="./src/gen" TEMP_OUTPUT_DIR="./openapi-temp" -# Clean previous output -rm -rf $TEMP_OUTPUT_DIR -rm -rf $OUTPUT_DIR - -mkdir $OUTPUT_DIR - -# NOTE: https://openapi-generator.tech/docs/generators/typescript-fetch/ -# Generate the Coordinator API models -yarn openapi-generator-cli generate \ - -i "$SCHEMA_FILE" \ - -g typescript-fetch \ - -o "$TEMP_OUTPUT_DIR" \ - --additional-properties=supportsES6=true \ - --additional-properties=modelPropertyNaming=original \ - --additional-properties=enumPropertyNaming=UPPERCASE \ - --additional-properties=withoutRuntimeChecks=true \ - --model-name-prefix=Video - -# Remove the generated API client, just keep the models -cp -r $TEMP_OUTPUT_DIR $OUTPUT_DIR/video -rm -rf $TEMP_OUTPUT_DIR - - -if [ "$FROM_REPO" == 'chat' ]; then - PROTOCOL_REPO_DIR="../chat" -else - PROTOCOL_REPO_DIR="../protocol" -fi -if [ "$FROM_REPO" == 'chat' ]; then - SCHEMA_FILE="$PROTOCOL_REPO_DIR/releases/chat-openapi.yaml" -else - SCHEMA_FILE="$PROTOCOL_REPO_DIR/openapi/chat-openapi.yaml" -fi +if [ "$PRODUCT" == 'video' ] || [ "$PRODUCT" == 'all' ] ; then + if [ "$FROM_REPO" == 'chat' ]; then + PROTOCOL_REPO_DIR="../chat" + else + PROTOCOL_REPO_DIR="../protocol" + fi + if [ "$FROM_REPO" == 'chat' ]; then + SCHEMA_FILE="$PROTOCOL_REPO_DIR/releases/video-openapi.yaml" + else + SCHEMA_FILE="$PROTOCOL_REPO_DIR/openapi/video-openapi.yaml" + fi + + if [ "$FROM_REPO" == 'chat' ]; then + # Generate the Coordinator OpenAPI schema + make -C $PROTOCOL_REPO_DIR video-openapi + fi + + OUTPUT_DIR="./src/gen/video" + + # Clean previous output + rm -rf $TEMP_OUTPUT_DIR + rm -rf $OUTPUT_DIR + + mkdir $OUTPUT_DIR + + # NOTE: https://openapi-generator.tech/docs/generators/typescript-fetch/ + # Generate the Coordinator API models + yarn openapi-generator-cli generate \ + -i "$SCHEMA_FILE" \ + -g typescript-fetch \ + -o "$TEMP_OUTPUT_DIR" \ + --additional-properties=supportsES6=true \ + --additional-properties=modelPropertyNaming=original \ + --additional-properties=enumPropertyNaming=UPPERCASE \ + --additional-properties=withoutRuntimeChecks=true \ + --model-name-prefix=Video -if [ "$FROM_REPO" == 'chat' ]; then - # Generate the Coordinator OpenAPI schema - make -C $PROTOCOL_REPO_DIR chat-openapi + # Remove the generated API client, just keep the models + cp -r $TEMP_OUTPUT_DIR/ $OUTPUT_DIR + rm -rf $TEMP_OUTPUT_DIR fi -# NOTE: https://openapi-generator.tech/docs/generators/typescript-fetch/ -# Generate the Coordinator API models -yarn openapi-generator-cli generate \ - -i "$SCHEMA_FILE" \ - -g typescript-fetch \ - -o "$TEMP_OUTPUT_DIR" \ - --additional-properties=supportsES6=true \ - --additional-properties=modelPropertyNaming=original \ - --additional-properties=enumPropertyNaming=UPPERCASE \ - --additional-properties=withoutRuntimeChecks=true - -# Remove the generated API client, just keep the models -cp -r $TEMP_OUTPUT_DIR $OUTPUT_DIR/chat -rm -rf $TEMP_OUTPUT_DIR \ No newline at end of file + +if [ "$PRODUCT" == 'chat' ] || [ "$PRODUCT" == 'all' ]; then + if [ "$FROM_REPO" == 'chat' ]; then + PROTOCOL_REPO_DIR="../chat" + else + PROTOCOL_REPO_DIR="../protocol" + fi + if [ "$FROM_REPO" == 'chat' ]; then + SCHEMA_FILE="$PROTOCOL_REPO_DIR/releases/chat-openapi.yaml" + else + SCHEMA_FILE="$PROTOCOL_REPO_DIR/openapi/chat-openapi.yaml" + fi + + if [ "$FROM_REPO" == 'chat' ]; then + # Generate the Coordinator OpenAPI schema + make -C $PROTOCOL_REPO_DIR chat-openapi + fi + + OUTPUT_DIR="./src/gen/chat" + + # Clean previous output + rm -rf $TEMP_OUTPUT_DIR + rm -rf $OUTPUT_DIR + + mkdir $OUTPUT_DIR + + # NOTE: https://openapi-generator.tech/docs/generators/typescript-fetch/ + # Generate the Coordinator API models + yarn openapi-generator-cli generate \ + -i "$SCHEMA_FILE" \ + -g typescript-fetch \ + -o "$TEMP_OUTPUT_DIR" \ + --additional-properties=supportsES6=true \ + --additional-properties=modelPropertyNaming=original \ + --additional-properties=enumPropertyNaming=UPPERCASE \ + --additional-properties=withoutRuntimeChecks=true + + # Remove the generated API client, just keep the models + cp -r $TEMP_OUTPUT_DIR/ $OUTPUT_DIR + rm -rf $TEMP_OUTPUT_DIR +fi diff --git a/package.json b/package.json index 4fa168e..7422506 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@stream-io/node-sdk", - "version": "0.1.11", + "version": "0.1.12", "description": "", "main": "dist/index.cjs.js", "module": "dist/index.es.js", @@ -18,8 +18,8 @@ "test:bun": "bun run vitest", "start": "rollup -w -c", "build": "rm -rf dist && rollup -c", - "generate:open-api": "./generate-openapi.sh protocol", - "generate:open-api:dev": "./generate-openapi.sh chat", + "generate:open-api": "./generate-openapi.sh protocol $PRODUCT", + "generate:open-api:dev": "./generate-openapi.sh chat $PRODUCT", "lint": "eslint **/*.ts", "lint:fix": "eslint --fix **/*.ts", "prettier:fix": "prettier . --write" diff --git a/src/StreamCall.ts b/src/StreamCall.ts index aeb0a6f..53373cd 100644 --- a/src/StreamCall.ts +++ b/src/StreamCall.ts @@ -14,6 +14,7 @@ import { VideoUpdateUserPermissionsRequest, VideoQueryMembersRequest, VideoStartRecordingRequest, + VideoStartTranscriptionRequest, } from './gen/video'; import { OmitTypeId } from './types'; @@ -101,8 +102,13 @@ export class StreamCall { }); }; - startTranscription = () => { - return this.apiClient.startTranscription({ ...this.baseRequest }); + startTranscription = ( + videoStartTranscriptionRequest: VideoStartTranscriptionRequest = {}, + ) => { + return this.apiClient.startTranscription({ + ...this.baseRequest, + videoStartTranscriptionRequest, + }); }; stopHLSBroadcasting = () => { diff --git a/src/StreamClient.ts b/src/StreamClient.ts index fa60ac3..6d4f090 100644 --- a/src/StreamClient.ts +++ b/src/StreamClient.ts @@ -92,16 +92,20 @@ export class StreamClient { readonly config?: string | StreamClientOptions, ) { this.token = JWTServerToken(this.secret); - this.video = new StreamVideoClient(this); - this.chat = new StreamChatClient(this); if (typeof config === 'string') { this.options.basePath = config; this.options.timeout = StreamClient.DEFAULT_TIMEOUT; } else { + if (config) { + this.options = config; + } this.options.timeout = config?.timeout ?? StreamClient.DEFAULT_TIMEOUT; } + this.video = new StreamVideoClient(this); + this.chat = new StreamChatClient(this); + const chatConfiguration = this.getConfiguration(); /** @ts-expect-error */ this.usersApi = new UsersApi(chatConfiguration); diff --git a/src/gen/video/apis/DefaultApi.ts b/src/gen/video/apis/DefaultApi.ts index 8d60890..da4e2ba 100644 --- a/src/gen/video/apis/DefaultApi.ts +++ b/src/gen/video/apis/DefaultApi.ts @@ -4,7 +4,7 @@ * Stream API * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * - * The version of the OpenAPI document: v98.0.2-ingress-test.3 + * The version of the OpenAPI document: v100.4.3 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -30,6 +30,7 @@ import type { VideoGoLiveResponse, VideoListDevicesResponse, VideoListRecordingsResponse, + VideoListTranscriptionsResponse, VideoMuteUsersRequest, VideoMuteUsersResponse, VideoPinRequest, @@ -44,6 +45,7 @@ import type { VideoStartHLSBroadcastingResponse, VideoStartRecordingRequest, VideoStartRecordingResponse, + VideoStartTranscriptionRequest, VideoStartTranscriptionResponse, VideoStopHLSBroadcastingResponse, VideoStopLiveResponse, @@ -117,6 +119,11 @@ export interface ListRecordingsRequest { id: string; } +export interface ListTranscriptionsRequest { + type: string; + id: string; +} + export interface MuteUsersRequest { type: string; id: string; @@ -152,6 +159,7 @@ export interface StartRecordingRequest { export interface StartTranscriptionRequest { type: string; id: string; + videoStartTranscriptionRequest: VideoStartTranscriptionRequest | null; } export interface StopHLSBroadcastingRequest { @@ -774,6 +782,54 @@ export class DefaultApi extends runtime.BaseAPI { return await response.value(); } + /** + * Lists transcriptions Required permissions: - ListTranscriptions + * List transcriptions + */ + async listTranscriptionsRaw(requestParameters: ListTranscriptionsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters.type === null || requestParameters.type === undefined) { + throw new runtime.RequiredError('type','Required parameter requestParameters.type was null or undefined when calling listTranscriptions.'); + } + + if (requestParameters.id === null || requestParameters.id === undefined) { + throw new runtime.RequiredError('id','Required parameter requestParameters.id was null or undefined when calling listTranscriptions.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Stream-Auth-Type"] = this.configuration.apiKey("Stream-Auth-Type"); // stream-auth-type authentication + } + + if (this.configuration && this.configuration.apiKey) { + queryParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication + } + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // JWT authentication + } + + const response = await this.request({ + path: `/video/call/{type}/{id}/transcriptions`.replace(`{${"type"}}`, encodeURIComponent(String(requestParameters.type))).replace(`{${"id"}}`, encodeURIComponent(String(requestParameters.id))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response); + } + + /** + * Lists transcriptions Required permissions: - ListTranscriptions + * List transcriptions + */ + async listTranscriptions(requestParameters: ListTranscriptionsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.listTranscriptionsRaw(requestParameters, initOverrides); + return await response.value(); + } + /** * Mutes users in a call Required permissions: - MuteUsers * Mute users @@ -1031,7 +1087,7 @@ export class DefaultApi extends runtime.BaseAPI { } /** - * Starts recording Sends events: - call.recording_started Required permissions: - StopRecording + * Starts recording Sends events: - call.recording_started Required permissions: - StartRecording * Start recording */ async startRecordingRaw(requestParameters: StartRecordingRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { @@ -1077,7 +1133,7 @@ export class DefaultApi extends runtime.BaseAPI { } /** - * Starts recording Sends events: - call.recording_started Required permissions: - StopRecording + * Starts recording Sends events: - call.recording_started Required permissions: - StartRecording * Start recording */ async startRecording(requestParameters: StartRecordingRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { @@ -1098,10 +1154,16 @@ export class DefaultApi extends runtime.BaseAPI { throw new runtime.RequiredError('id','Required parameter requestParameters.id was null or undefined when calling startTranscription.'); } + if (requestParameters.videoStartTranscriptionRequest === null || requestParameters.videoStartTranscriptionRequest === undefined) { + throw new runtime.RequiredError('videoStartTranscriptionRequest','Required parameter requestParameters.videoStartTranscriptionRequest was null or undefined when calling startTranscription.'); + } + const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; + headerParameters['Content-Type'] = 'application/json'; + if (this.configuration && this.configuration.apiKey) { headerParameters["Stream-Auth-Type"] = this.configuration.apiKey("Stream-Auth-Type"); // stream-auth-type authentication } @@ -1119,6 +1181,7 @@ export class DefaultApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, + body: requestParameters.videoStartTranscriptionRequest, }, initOverrides); return new runtime.JSONApiResponse(response); @@ -1278,7 +1341,7 @@ export class DefaultApi extends runtime.BaseAPI { } /** - * Stops transcription Required permissions: - StopTranscription + * Stops transcription Sends events: - call.transcription_stopped Required permissions: - StopTranscription * Stop transcription */ async stopTranscriptionRaw(requestParameters: StopTranscriptionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { @@ -1317,7 +1380,7 @@ export class DefaultApi extends runtime.BaseAPI { } /** - * Stops transcription Required permissions: - StopTranscription + * Stops transcription Sends events: - call.transcription_stopped Required permissions: - StopTranscription * Stop transcription */ async stopTranscription(requestParameters: StopTranscriptionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { diff --git a/src/gen/video/apis/ServerSideApi.ts b/src/gen/video/apis/ServerSideApi.ts index f4a77e8..d9a71c4 100644 --- a/src/gen/video/apis/ServerSideApi.ts +++ b/src/gen/video/apis/ServerSideApi.ts @@ -4,7 +4,7 @@ * Stream API * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * - * The version of the OpenAPI document: v98.0.2-ingress-test.3 + * The version of the OpenAPI document: v100.4.3 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). diff --git a/src/gen/video/apis/SettingsApi.ts b/src/gen/video/apis/SettingsApi.ts index c0a7905..8d86b25 100644 --- a/src/gen/video/apis/SettingsApi.ts +++ b/src/gen/video/apis/SettingsApi.ts @@ -4,7 +4,7 @@ * Stream API * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * - * The version of the OpenAPI document: v98.0.2-ingress-test.3 + * The version of the OpenAPI document: v100.4.3 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). diff --git a/src/gen/video/models/index.ts b/src/gen/video/models/index.ts index cc0ad5f..46129b5 100644 --- a/src/gen/video/models/index.ts +++ b/src/gen/video/models/index.ts @@ -793,6 +793,37 @@ export interface VideoCallStateResponseFields { */ own_capabilities: Array; } +/** + * CallTranscription represents a transcription of a call. + * @export + * @interface VideoCallTranscription + */ +export interface VideoCallTranscription { + /** + * + * @type {string} + * @memberof VideoCallTranscription + */ + end_time: string; + /** + * + * @type {string} + * @memberof VideoCallTranscription + */ + filename: string; + /** + * + * @type {string} + * @memberof VideoCallTranscription + */ + start_time: string; + /** + * + * @type {string} + * @memberof VideoCallTranscription + */ + url: string; +} /** * * @export @@ -1655,6 +1686,12 @@ export interface VideoGoLiveRequest { * @memberof VideoGoLiveRequest */ start_transcription?: boolean; + /** + * + * @type {string} + * @memberof VideoGoLiveRequest + */ + transcription_storage_name?: string; } /** * @@ -1903,6 +1940,25 @@ export interface VideoListRecordingsResponse { */ recordings: Array; } +/** + * + * @export + * @interface VideoListTranscriptionsResponse + */ +export interface VideoListTranscriptionsResponse { + /** + * + * @type {string} + * @memberof VideoListTranscriptionsResponse + */ + duration: string; + /** + * + * @type {Array} + * @memberof VideoListTranscriptionsResponse + */ + transcriptions: Array; +} /** * * @export @@ -2629,6 +2685,19 @@ export interface VideoStartRecordingResponse { */ duration: string; } +/** + * + * @export + * @interface VideoStartTranscriptionRequest + */ +export interface VideoStartTranscriptionRequest { + /** + * + * @type {string} + * @memberof VideoStartTranscriptionRequest + */ + transcription_external_storage?: string; +} /** * * @export diff --git a/src/gen/video/runtime.ts b/src/gen/video/runtime.ts index 3ba6064..c3c5016 100644 --- a/src/gen/video/runtime.ts +++ b/src/gen/video/runtime.ts @@ -4,7 +4,7 @@ * Stream API * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * - * The version of the OpenAPI document: v98.0.2-ingress-test.3 + * The version of the OpenAPI document: v100.4.3 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).