Skip to content

Commit

Permalink
update the swift generated stuff for spm
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Oct 24, 2023
1 parent 7a4c246 commit d8e4d26
Show file tree
Hide file tree
Showing 10 changed files with 1,241 additions and 6 deletions.
653 changes: 652 additions & 1 deletion swift/keystore_api/v1/keystore.pb.swift

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion swift/message_api/v1/authn.pb.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public struct Xmtp_MessageApi_V1_AuthData {
/// address of the wallet
public var walletAddr: String = String()

/// time when the token was generated/signed
/// time when the token was generated/signed
public var createdNs: UInt64 = 0

public var unknownFields = SwiftProtobuf.UnknownStorage()
Expand Down
119 changes: 119 additions & 0 deletions swift/message_api/v1/message_api.grpc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ public protocol Xmtp_MessageApi_V1_MessageApiClientProtocol: GRPCClient {
handler: @escaping (Xmtp_MessageApi_V1_Envelope) -> Void
) -> ServerStreamingCall<Xmtp_MessageApi_V1_SubscribeRequest, Xmtp_MessageApi_V1_Envelope>

func subscribe2(
callOptions: CallOptions?,
handler: @escaping (Xmtp_MessageApi_V1_Envelope) -> Void
) -> BidirectionalStreamingCall<Xmtp_MessageApi_V1_SubscribeRequest, Xmtp_MessageApi_V1_Envelope>

func subscribeAll(
_ request: Xmtp_MessageApi_V1_SubscribeAllRequest,
callOptions: CallOptions?,
Expand Down Expand Up @@ -105,6 +110,29 @@ extension Xmtp_MessageApi_V1_MessageApiClientProtocol {
)
}

/// Subscribe to a stream of new envelopes and your subscription using
/// bidirectional streaming
/// protolint:disable:next RPC_REQUEST_STANDARD_NAME
///
/// Callers should use the `send` method on the returned object to send messages
/// to the server. The caller should send an `.end` after the final message has been sent.
///
/// - Parameters:
/// - callOptions: Call options.
/// - handler: A closure called when each response is received from the server.
/// - Returns: A `ClientStreamingCall` with futures for the metadata and status.
public func subscribe2(
callOptions: CallOptions? = nil,
handler: @escaping (Xmtp_MessageApi_V1_Envelope) -> Void
) -> BidirectionalStreamingCall<Xmtp_MessageApi_V1_SubscribeRequest, Xmtp_MessageApi_V1_Envelope> {
return self.makeBidirectionalStreamingCall(
path: Xmtp_MessageApi_V1_MessageApiClientMetadata.Methods.subscribe2.path,
callOptions: callOptions ?? self.defaultCallOptions,
interceptors: self.interceptors?.makeSubscribe2Interceptors() ?? [],
handler: handler
)
}

/// Subscribe to a stream of all messages
///
/// - Parameters:
Expand Down Expand Up @@ -239,6 +267,10 @@ public protocol Xmtp_MessageApi_V1_MessageApiAsyncClientProtocol: GRPCClient {
callOptions: CallOptions?
) -> GRPCAsyncServerStreamingCall<Xmtp_MessageApi_V1_SubscribeRequest, Xmtp_MessageApi_V1_Envelope>

func makeSubscribe2Call(
callOptions: CallOptions?
) -> GRPCAsyncBidirectionalStreamingCall<Xmtp_MessageApi_V1_SubscribeRequest, Xmtp_MessageApi_V1_Envelope>

func makeSubscribeAllCall(
_ request: Xmtp_MessageApi_V1_SubscribeAllRequest,
callOptions: CallOptions?
Expand Down Expand Up @@ -289,6 +321,16 @@ extension Xmtp_MessageApi_V1_MessageApiAsyncClientProtocol {
)
}

public func makeSubscribe2Call(
callOptions: CallOptions? = nil
) -> GRPCAsyncBidirectionalStreamingCall<Xmtp_MessageApi_V1_SubscribeRequest, Xmtp_MessageApi_V1_Envelope> {
return self.makeAsyncBidirectionalStreamingCall(
path: Xmtp_MessageApi_V1_MessageApiClientMetadata.Methods.subscribe2.path,
callOptions: callOptions ?? self.defaultCallOptions,
interceptors: self.interceptors?.makeSubscribe2Interceptors() ?? []
)
}

public func makeSubscribeAllCall(
_ request: Xmtp_MessageApi_V1_SubscribeAllRequest,
callOptions: CallOptions? = nil
Expand Down Expand Up @@ -352,6 +394,30 @@ extension Xmtp_MessageApi_V1_MessageApiAsyncClientProtocol {
)
}

public func subscribe2<RequestStream>(
_ requests: RequestStream,
callOptions: CallOptions? = nil
) -> GRPCAsyncResponseStream<Xmtp_MessageApi_V1_Envelope> where RequestStream: Sequence, RequestStream.Element == Xmtp_MessageApi_V1_SubscribeRequest {
return self.performAsyncBidirectionalStreamingCall(
path: Xmtp_MessageApi_V1_MessageApiClientMetadata.Methods.subscribe2.path,
requests: requests,
callOptions: callOptions ?? self.defaultCallOptions,
interceptors: self.interceptors?.makeSubscribe2Interceptors() ?? []
)
}

public func subscribe2<RequestStream>(
_ requests: RequestStream,
callOptions: CallOptions? = nil
) -> GRPCAsyncResponseStream<Xmtp_MessageApi_V1_Envelope> where RequestStream: AsyncSequence & Sendable, RequestStream.Element == Xmtp_MessageApi_V1_SubscribeRequest {
return self.performAsyncBidirectionalStreamingCall(
path: Xmtp_MessageApi_V1_MessageApiClientMetadata.Methods.subscribe2.path,
requests: requests,
callOptions: callOptions ?? self.defaultCallOptions,
interceptors: self.interceptors?.makeSubscribe2Interceptors() ?? []
)
}

public func subscribeAll(
_ request: Xmtp_MessageApi_V1_SubscribeAllRequest,
callOptions: CallOptions? = nil
Expand Down Expand Up @@ -416,6 +482,9 @@ public protocol Xmtp_MessageApi_V1_MessageApiClientInterceptorFactoryProtocol: G
/// - Returns: Interceptors to use when invoking 'subscribe'.
func makeSubscribeInterceptors() -> [ClientInterceptor<Xmtp_MessageApi_V1_SubscribeRequest, Xmtp_MessageApi_V1_Envelope>]

/// - Returns: Interceptors to use when invoking 'subscribe2'.
func makeSubscribe2Interceptors() -> [ClientInterceptor<Xmtp_MessageApi_V1_SubscribeRequest, Xmtp_MessageApi_V1_Envelope>]

/// - Returns: Interceptors to use when invoking 'subscribeAll'.
func makeSubscribeAllInterceptors() -> [ClientInterceptor<Xmtp_MessageApi_V1_SubscribeAllRequest, Xmtp_MessageApi_V1_Envelope>]

Expand All @@ -433,6 +502,7 @@ public enum Xmtp_MessageApi_V1_MessageApiClientMetadata {
methods: [
Xmtp_MessageApi_V1_MessageApiClientMetadata.Methods.publish,
Xmtp_MessageApi_V1_MessageApiClientMetadata.Methods.subscribe,
Xmtp_MessageApi_V1_MessageApiClientMetadata.Methods.subscribe2,
Xmtp_MessageApi_V1_MessageApiClientMetadata.Methods.subscribeAll,
Xmtp_MessageApi_V1_MessageApiClientMetadata.Methods.query,
Xmtp_MessageApi_V1_MessageApiClientMetadata.Methods.batchQuery,
Expand All @@ -452,6 +522,12 @@ public enum Xmtp_MessageApi_V1_MessageApiClientMetadata {
type: GRPCCallType.serverStreaming
)

public static let subscribe2 = GRPCMethodDescriptor(
name: "Subscribe2",
path: "/xmtp.message_api.v1.MessageApi/Subscribe2",
type: GRPCCallType.bidirectionalStreaming
)

public static let subscribeAll = GRPCMethodDescriptor(
name: "SubscribeAll",
path: "/xmtp.message_api.v1.MessageApi/SubscribeAll",
Expand Down Expand Up @@ -484,6 +560,11 @@ public protocol Xmtp_MessageApi_V1_MessageApiProvider: CallHandlerProvider {
/// Subscribe to a stream of new envelopes matching a predicate
func subscribe(request: Xmtp_MessageApi_V1_SubscribeRequest, context: StreamingResponseCallContext<Xmtp_MessageApi_V1_Envelope>) -> EventLoopFuture<GRPCStatus>

/// Subscribe to a stream of new envelopes and your subscription using
/// bidirectional streaming
/// protolint:disable:next RPC_REQUEST_STANDARD_NAME
func subscribe2(context: StreamingResponseCallContext<Xmtp_MessageApi_V1_Envelope>) -> EventLoopFuture<(StreamEvent<Xmtp_MessageApi_V1_SubscribeRequest>) -> Void>

/// Subscribe to a stream of all messages
func subscribeAll(request: Xmtp_MessageApi_V1_SubscribeAllRequest, context: StreamingResponseCallContext<Xmtp_MessageApi_V1_Envelope>) -> EventLoopFuture<GRPCStatus>

Expand Down Expand Up @@ -524,6 +605,15 @@ extension Xmtp_MessageApi_V1_MessageApiProvider {
userFunction: self.subscribe(request:context:)
)

case "Subscribe2":
return BidirectionalStreamingServerHandler(
context: context,
requestDeserializer: ProtobufDeserializer<Xmtp_MessageApi_V1_SubscribeRequest>(),
responseSerializer: ProtobufSerializer<Xmtp_MessageApi_V1_Envelope>(),
interceptors: self.interceptors?.makeSubscribe2Interceptors() ?? [],
observerFactory: self.subscribe2(context:)
)

case "SubscribeAll":
return ServerStreamingServerHandler(
context: context,
Expand Down Expand Up @@ -580,6 +670,15 @@ public protocol Xmtp_MessageApi_V1_MessageApiAsyncProvider: CallHandlerProvider
context: GRPCAsyncServerCallContext
) async throws

/// Subscribe to a stream of new envelopes and your subscription using
/// bidirectional streaming
/// protolint:disable:next RPC_REQUEST_STANDARD_NAME
@Sendable func subscribe2(
requestStream: GRPCAsyncRequestStream<Xmtp_MessageApi_V1_SubscribeRequest>,
responseStream: GRPCAsyncResponseStreamWriter<Xmtp_MessageApi_V1_Envelope>,
context: GRPCAsyncServerCallContext
) async throws

/// Subscribe to a stream of all messages
@Sendable func subscribeAll(
request: Xmtp_MessageApi_V1_SubscribeAllRequest,
Expand Down Expand Up @@ -637,6 +736,15 @@ extension Xmtp_MessageApi_V1_MessageApiAsyncProvider {
wrapping: self.subscribe(request:responseStream:context:)
)

case "Subscribe2":
return GRPCAsyncServerHandler(
context: context,
requestDeserializer: ProtobufDeserializer<Xmtp_MessageApi_V1_SubscribeRequest>(),
responseSerializer: ProtobufSerializer<Xmtp_MessageApi_V1_Envelope>(),
interceptors: self.interceptors?.makeSubscribe2Interceptors() ?? [],
wrapping: self.subscribe2(requestStream:responseStream:context:)
)

case "SubscribeAll":
return GRPCAsyncServerHandler(
context: context,
Expand Down Expand Up @@ -682,6 +790,10 @@ public protocol Xmtp_MessageApi_V1_MessageApiServerInterceptorFactoryProtocol {
/// Defaults to calling `self.makeInterceptors()`.
func makeSubscribeInterceptors() -> [ServerInterceptor<Xmtp_MessageApi_V1_SubscribeRequest, Xmtp_MessageApi_V1_Envelope>]

/// - Returns: Interceptors to use when handling 'subscribe2'.
/// Defaults to calling `self.makeInterceptors()`.
func makeSubscribe2Interceptors() -> [ServerInterceptor<Xmtp_MessageApi_V1_SubscribeRequest, Xmtp_MessageApi_V1_Envelope>]

/// - Returns: Interceptors to use when handling 'subscribeAll'.
/// Defaults to calling `self.makeInterceptors()`.
func makeSubscribeAllInterceptors() -> [ServerInterceptor<Xmtp_MessageApi_V1_SubscribeAllRequest, Xmtp_MessageApi_V1_Envelope>]
Expand All @@ -702,6 +814,7 @@ public enum Xmtp_MessageApi_V1_MessageApiServerMetadata {
methods: [
Xmtp_MessageApi_V1_MessageApiServerMetadata.Methods.publish,
Xmtp_MessageApi_V1_MessageApiServerMetadata.Methods.subscribe,
Xmtp_MessageApi_V1_MessageApiServerMetadata.Methods.subscribe2,
Xmtp_MessageApi_V1_MessageApiServerMetadata.Methods.subscribeAll,
Xmtp_MessageApi_V1_MessageApiServerMetadata.Methods.query,
Xmtp_MessageApi_V1_MessageApiServerMetadata.Methods.batchQuery,
Expand All @@ -721,6 +834,12 @@ public enum Xmtp_MessageApi_V1_MessageApiServerMetadata {
type: GRPCCallType.serverStreaming
)

public static let subscribe2 = GRPCMethodDescriptor(
name: "Subscribe2",
path: "/xmtp.message_api.v1.MessageApi/Subscribe2",
type: GRPCCallType.bidirectionalStreaming
)

public static let subscribeAll = GRPCMethodDescriptor(
name: "SubscribeAll",
path: "/xmtp.message_api.v1.MessageApi/SubscribeAll",
Expand Down
2 changes: 1 addition & 1 deletion swift/message_api/v1/message_api.pb.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public enum Xmtp_MessageApi_V1_SortDirection: SwiftProtobuf.Enum {

extension Xmtp_MessageApi_V1_SortDirection: CaseIterable {
// The compiler won't synthesize support with the UNRECOGNIZED case.
public static var allCases: [Xmtp_MessageApi_V1_SortDirection] = [
public static let allCases: [Xmtp_MessageApi_V1_SortDirection] = [
.unspecified,
.ascending,
.descending,
Expand Down
2 changes: 1 addition & 1 deletion swift/message_contents/content.pb.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public enum Xmtp_MessageContents_Compression: SwiftProtobuf.Enum {

extension Xmtp_MessageContents_Compression: CaseIterable {
// The compiler won't synthesize support with the UNRECOGNIZED case.
public static var allCases: [Xmtp_MessageContents_Compression] = [
public static let allCases: [Xmtp_MessageContents_Compression] = [
.deflate,
.gzip,
]
Expand Down
116 changes: 116 additions & 0 deletions swift/message_contents/ecies.pb.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
// DO NOT EDIT.
// swift-format-ignore-file
//
// Generated by the Swift generator plugin for the protocol buffer compiler.
// Source: message_contents/ecies.proto
//
// For information on using the generated types, please see the documentation:
// https://github.com/apple/swift-protobuf/

/// ECIES is a wrapper for ECIES payloads

import Foundation
import SwiftProtobuf

// If the compiler emits an error on this type, it is because this file
// was generated by a version of the `protoc` Swift plug-in that is
// incompatible with the version of SwiftProtobuf to which you are linking.
// Please ensure that you are building against the same version of the API
// that was used to generate this file.
fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck {
struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {}
typealias Version = _2
}

/// EciesMessage is a wrapper for ECIES encrypted payloads
public struct Xmtp_MessageContents_EciesMessage {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
// methods supported on all messages.

public var version: Xmtp_MessageContents_EciesMessage.OneOf_Version? = nil

/// Expected to be an ECIES encrypted SignedPayload
public var v1: Data {
get {
if case .v1(let v)? = version {return v}
return Data()
}
set {version = .v1(newValue)}
}

public var unknownFields = SwiftProtobuf.UnknownStorage()

public enum OneOf_Version: Equatable {
/// Expected to be an ECIES encrypted SignedPayload
case v1(Data)

#if !swift(>=4.1)
public static func ==(lhs: Xmtp_MessageContents_EciesMessage.OneOf_Version, rhs: Xmtp_MessageContents_EciesMessage.OneOf_Version) -> Bool {
// The use of inline closures is to circumvent an issue where the compiler
// allocates stack space for every case branch when no optimizations are
// enabled. https://github.com/apple/swift-protobuf/issues/1034
switch (lhs, rhs) {
case (.v1, .v1): return {
guard case .v1(let l) = lhs, case .v1(let r) = rhs else { preconditionFailure() }
return l == r
}()
}
}
#endif
}

public init() {}
}

#if swift(>=5.5) && canImport(_Concurrency)
extension Xmtp_MessageContents_EciesMessage: @unchecked Sendable {}
extension Xmtp_MessageContents_EciesMessage.OneOf_Version: @unchecked Sendable {}
#endif // swift(>=5.5) && canImport(_Concurrency)

// MARK: - Code below here is support for the SwiftProtobuf runtime.

fileprivate let _protobuf_package = "xmtp.message_contents"

extension Xmtp_MessageContents_EciesMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
public static let protoMessageName: String = _protobuf_package + ".EciesMessage"
public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .same(proto: "v1"),
]

public mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
while let fieldNumber = try decoder.nextFieldNumber() {
// The use of inline closures is to circumvent an issue where the compiler
// allocates stack space for every case branch when no optimizations are
// enabled. https://github.com/apple/swift-protobuf/issues/1034
switch fieldNumber {
case 1: try {
var v: Data?
try decoder.decodeSingularBytesField(value: &v)
if let v = v {
if self.version != nil {try decoder.handleConflictingOneOf()}
self.version = .v1(v)
}
}()
default: break
}
}
}

public func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
// The use of inline closures is to circumvent an issue where the compiler
// allocates stack space for every if/case branch local when no optimizations
// are enabled. https://github.com/apple/swift-protobuf/issues/1034 and
// https://github.com/apple/swift-protobuf/issues/1182
try { if case .v1(let v)? = self.version {
try visitor.visitSingularBytesField(value: v, fieldNumber: 1)
} }()
try unknownFields.traverse(visitor: &visitor)
}

public static func ==(lhs: Xmtp_MessageContents_EciesMessage, rhs: Xmtp_MessageContents_EciesMessage) -> Bool {
if lhs.version != rhs.version {return false}
if lhs.unknownFields != rhs.unknownFields {return false}
return true
}
}
2 changes: 1 addition & 1 deletion swift/message_contents/private_key.pb.swift
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ public struct Xmtp_MessageContents_EncryptedPrivateKeyBundleV1 {
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
// methods supported on all messages.

/// randomly generated pre-key
/// randomly generated pre-key
public var walletPreKey: Data = Data()

/// MUST contain encrypted PrivateKeyBundle
Expand Down
Loading

0 comments on commit d8e4d26

Please sign in to comment.