Skip to content

Commit

Permalink
Generated using our own generator (#504)
Browse files Browse the repository at this point in the history
  • Loading branch information
shaljam authored Oct 16, 2024
1 parent 5c3bc9a commit 4118081
Show file tree
Hide file tree
Showing 249 changed files with 5,651 additions and 5,316 deletions.
24 changes: 24 additions & 0 deletions Scripts/generate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

SOURCE_PATH=../chat

if [ ! -d $SOURCE_PATH ]
then
echo "cannot find chat path on the parent folder (${SOURCE_PATH}), do you have a copy of the API source?";
exit 1;
fi

set -ex

# remove old generated code
rm -rf ./Sources/StreamVideo/OpenApi/generated/Models/*

# cd in API repo, generate new spec and then generate code from it
(
cd $SOURCE_PATH &&
go run ./cmd/chat-manager openapi generate-spec -products video -version v1 -clientside -output releases/video-openapi-clientside &&
go run ./cmd/chat-manager openapi generate-client --language swift --spec ./releases/video-openapi-clientside.yaml --output ../stream-video-swift/Sources/StreamVideo/OpenApi/generated/
)

# format the generated code
mint run swiftformat Sources/StreamVideo/OpenApi/generated
9 changes: 5 additions & 4 deletions Sources/StreamVideo/Call.swift
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ public class Call: @unchecked Sendable, WSEventsSubscriber {
id: callId,
membersLimit: membersLimit,
ring: ring,
notify: notify
notify: notify,
video: nil
)
await state.update(from: response)
if ring {
Expand Down Expand Up @@ -819,7 +820,7 @@ public class Call: @unchecked Sendable, WSEventsSubscriber {
sort: sort,
type: callType
)
let response = try await coordinatorClient.queryMembers(queryMembersRequest: request)
let response = try await coordinatorClient.queryCallMembers(queryMembersRequest: request)
await state.mergeMembers(response.members)
return response
}
Expand Down Expand Up @@ -1108,7 +1109,7 @@ public class Call: @unchecked Sendable, WSEventsSubscriber {
@discardableResult
@MainActor
public func collectUserFeedback(
rating: Int? = nil,
rating: Int,
reason: String? = nil,
custom: [String: RawJSON]? = nil
) async throws -> CollectUserFeedbackResponse {
Expand Down Expand Up @@ -1331,7 +1332,7 @@ public class Call: @unchecked Sendable, WSEventsSubscriber {

/// Handles updates to noise cancellation settings.
/// - Parameter value: The updated `NoiseCancellationSettings` value.
private func didUpdate(_ value: NoiseCancellationSettings?) {
private func didUpdate(_ value: NoiseCancellationSettingsRequest?) {
guard let noiseCancellationFilter = streamVideo.videoConfig.noiseCancellationFilter else {
log
.warning(
Expand Down
6 changes: 4 additions & 2 deletions Sources/StreamVideo/CallState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ public class CallState: ObservableObject {
case .typeHealthCheckEvent:
// note: health checks are not relevant for call state sync'ing
break
case .typeCallUserMutedEvent:
break
case .typeCallDeletedEvent:
break
case .typeCallHLSBroadcastingFailedEvent:
Expand All @@ -237,12 +239,12 @@ public class CallState: ObservableObject {
break
case .typeCallRtmpBroadcastStoppedEvent:
break
case .typeCallUserMutedEvent:
break
case .typeCallRtmpBroadcastFailedEvent:
break
case .typeCallSessionParticipantCountsUpdatedEvent:
break
case .typeUserUpdatedEvent:
break
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/StreamVideo/Controllers/CallController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ class CallController: @unchecked Sendable {
func collectUserFeedback(
sessionID: String,
custom: [String: RawJSON]? = nil,
rating: Int? = nil,
rating: Int,
reason: String? = nil
) async throws -> CollectUserFeedbackResponse {
try await defaultAPI.collectUserFeedback(
Expand Down
25 changes: 0 additions & 25 deletions Sources/StreamVideo/Models/CoordinatorModels.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,6 @@

import Foundation

extension CallSettingsResponse: @unchecked Sendable {}
extension ModelResponse: @unchecked Sendable {}
extension AcceptCallResponse: @unchecked Sendable {}
extension RejectCallResponse: @unchecked Sendable {}
extension CallResponse: @unchecked Sendable {}
extension OwnCapability: @unchecked Sendable {}
extension MemberRequest: @unchecked Sendable {}
extension MemberResponse: @unchecked Sendable {}
extension UpdateCallMembersResponse: @unchecked Sendable {}
extension CallSettingsRequest: @unchecked Sendable {}
extension JoinCallResponse: @unchecked Sendable {}
extension GetOrCreateCallResponse: @unchecked Sendable {}
extension GetCallResponse: @unchecked Sendable {}
extension UpdateCallResponse: @unchecked Sendable {}
extension BlockUserResponse: @unchecked Sendable {}
extension UnblockUserResponse: @unchecked Sendable {}
extension MuteUsersResponse: @unchecked Sendable {}
extension MuteUsersRequest: @unchecked Sendable {}
extension PinRequest: @unchecked Sendable {}
extension UnpinRequest: @unchecked Sendable {}
extension PinResponse: @unchecked Sendable {}
extension UnpinResponse: @unchecked Sendable {}
extension GoLiveResponse: @unchecked Sendable {}
extension SendReactionResponse: @unchecked Sendable {}

public struct FetchingLocationError: Error {}

public enum RecordingState {
Expand Down
1 change: 1 addition & 0 deletions Sources/StreamVideo/Models/User.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public extension User {
public extension UserResponse {
static func make(from id: String) -> UserResponse {
UserResponse(
blockedUserIds: [],
createdAt: Date(),
custom: [:],
id: id,
Expand Down
10 changes: 7 additions & 3 deletions Sources/StreamVideo/Models/VideoOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct VideoOptions: Sendable {
preferredFormat: preferredFormat,
preferredDimensions: preferredDimensions,
preferredFps: preferredFps,
preferredBitrate: targetResolution.bitrate
preferredBitrate: targetResolution.bitrate ?? .maxBitrate
)
} catch {
supportedCodecs = VideoCodec.defaultCodecs
Expand Down Expand Up @@ -67,7 +67,7 @@ extension VideoCodec {
static let full = VideoCodec(
dimensions: .full,
quality: "f",
maxBitrate: 1_000_000,
maxBitrate: .maxBitrate,
sfuQuality: .high
)

Expand All @@ -90,7 +90,11 @@ extension VideoCodec {
static let screenshare = VideoCodec(
dimensions: .full,
quality: "q",
maxBitrate: 1_000_000,
maxBitrate: .maxBitrate,
sfuQuality: .high
)
}

extension Int {
static let maxBitrate = 1_000_000
}
2 changes: 0 additions & 2 deletions Sources/StreamVideo/OpenApi/AuthMiddlewares.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ struct AnonymousAuth: DefaultAPIClientMiddleware {
modifiedRequest.headers["stream-auth-type"] = "anonymous"
return try await next(modifiedRequest)
}

}

struct DefaultParams: DefaultAPIClientMiddleware {
Expand All @@ -58,5 +57,4 @@ struct DefaultParams: DefaultAPIClientMiddleware {
modifiedRequest.headers["x-client-request-id"] = UUID().uuidString
return try await next(modifiedRequest)
}

}
5 changes: 4 additions & 1 deletion Sources/StreamVideo/OpenApi/OwnCapability+Identifiable.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
//
// Copyright © 2024 Stream.io Inc. All rights reserved.
//

import Foundation

extension OwnCapability: Identifiable {
public var id: String {
rawValue
}
}

5 changes: 3 additions & 2 deletions Sources/StreamVideo/OpenApi/URLSessionTransport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,13 @@ final class URLSessionTransport: DefaultAPITransport, @unchecked Sendable {
do {
return try await execute(request: clone.urlRequest())
} catch {
// Log error and rethrow
// Log error and rethrow
log.error(
"URLSessionTransport: \(String(describing: request.url.absoluteString))\n"
+ "Headers:\n\(String(describing: request.headers))\n"
+ "Query items:\n\(request.queryParams)",
subsystems: .httpRequests, error: error)
subsystems: .httpRequests, error: error
)
throw error
}
}
Expand Down
8 changes: 3 additions & 5 deletions Sources/StreamVideo/OpenApi/generated/APIHelper.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
// APIHelper.swift
//
// Generated by openapi-generator
// https://openapi-generator.tech
// Copyright © 2024 Stream.io Inc. All rights reserved.
//

import Foundation

public struct APIHelper {
public enum APIHelper {
public static func rejectNil(_ source: [String: Any?]) -> [String: Any]? {
let destination = source.reduce(into: [String: Any]()) { result, item in
if let value = item.value {
Expand All @@ -21,7 +19,7 @@ public struct APIHelper {
}

public static func rejectNilHeaders(_ source: [String: Any?]) -> [String: String] {
return source.reduce(into: [String: String]()) { result, item in
source.reduce(into: [String: String]()) { result, item in
if let collection = item.value as? [Any?] {
result[item.key] = collection
.compactMap { value in convertAnyToString(value) }
Expand Down
Loading

0 comments on commit 4118081

Please sign in to comment.