Skip to content

Commit

Permalink
Apply updates from yorkie-js-sdk v0.4.27 (#192)
Browse files Browse the repository at this point in the history
* Added the generated ErrorInfo model from googleapis/google/rpc/error_details.proto

* Add YorkieService wrapper for YorkieServiceClient with API mocking support

* Handle retry for syncLoop and watchLoop / Handle ErrClientNotActivated and ErrClientNotFound

* Fix watch loop reconnect timer issue in manual syncMode

* Fix ensure onlineClients are reset on document detach

* Handle local changes correctly when receiving snapshot

* Fix Xcode warnings

* Apply SwiftFormat

* Fix 1 failing test in ClientIntegrationTests

* Apply review comments by coderabbitai
  • Loading branch information
hiddenviewer authored Jan 24, 2025
1 parent 095ad46 commit 1aa3dd8
Show file tree
Hide file tree
Showing 16 changed files with 832 additions and 101 deletions.
1 change: 1 addition & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ let package = Package(
exclude: ["Info.plist",
"API/V1/yorkie/v1/resources.proto",
"API/V1/yorkie/v1/yorkie.proto",
"API/V1/googleapis/google/rpc/error_details.proto",
"API/V1/buf.gen.yaml",
"API/V1/buf.yaml",
"API/V1/run_protoc.sh"]
Expand Down
1 change: 1 addition & 0 deletions Sources/API/GRPCTypeAlias.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,4 @@ typealias PbTreeNodes = Yorkie_V1_TreeNodes
typealias PbSnapshot = Yorkie_V1_Snapshot
typealias PbTreeNodeID = Yorkie_V1_TreeNodeID

typealias ErrorInfo = Google_Rpc_ErrorInfo
119 changes: 119 additions & 0 deletions Sources/API/V1/Generated/googleapis/google/rpc/error_details.pb.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
// DO NOT EDIT.
// swift-format-ignore-file
// swiftlint:disable all
//
// Generated by the Swift generator plugin for the protocol buffer compiler.
// Source: googleapis/google/rpc/error_details.proto
//
// For information on using the generated types, please see the documentation:
// https://github.com/apple/swift-protobuf/

// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

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
}

public struct Google_Rpc_ErrorInfo: @unchecked Sendable {
// 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.

/// The reason of the error. This is a constant value that identifies the
/// proximate cause of the error. Error reasons are unique within a particular
/// domain of errors. This should be at most 63 characters and match a
/// regular expression of `[A-Z][A-Z0-9_]+[A-Z0-9]`, which represents
/// UPPER_SNAKE_CASE.
public var reason: String = String()

/// The logical grouping to which the "reason" belongs. The error domain
/// is typically the registered service name of the tool or product that
/// generates the error. Example: "pubsub.googleapis.com". If the error is
/// generated by some common infrastructure, the error domain must be a
/// globally unique value that identifies the infrastructure. For Google API
/// infrastructure, the error domain is "googleapis.com".
public var domain: String = String()

/// Additional structured details about this error.
///
/// Keys must match a regular expression of `[a-z][a-zA-Z0-9-_]+` but should
/// ideally be lowerCamelCase. Also, they must be limited to 64 characters in
/// length. When identifying the current value of an exceeded limit, the units
/// should be contained in the key, not the value. For example, rather than
/// `{"instanceLimit": "100/request"}`, should be returned as,
/// `{"instanceLimitPerRequest": "100"}`, if the client exceeds the number of
/// instances that can be created in a single (batch) request.
public var metadata: Dictionary<String,String> = [:]

public var unknownFields = SwiftProtobuf.UnknownStorage()

public init() {}
}

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

fileprivate let _protobuf_package = "google.rpc"

extension Google_Rpc_ErrorInfo: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
public static let protoMessageName: String = _protobuf_package + ".ErrorInfo"
public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .same(proto: "reason"),
2: .same(proto: "domain"),
3: .same(proto: "metadata"),
]

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 { try decoder.decodeSingularStringField(value: &self.reason) }()
case 2: try { try decoder.decodeSingularStringField(value: &self.domain) }()
case 3: try { try decoder.decodeMapField(fieldType: SwiftProtobuf._ProtobufMap<SwiftProtobuf.ProtobufString,SwiftProtobuf.ProtobufString>.self, value: &self.metadata) }()
default: break
}
}
}

public func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
if !self.reason.isEmpty {
try visitor.visitSingularStringField(value: self.reason, fieldNumber: 1)
}
if !self.domain.isEmpty {
try visitor.visitSingularStringField(value: self.domain, fieldNumber: 2)
}
if !self.metadata.isEmpty {
try visitor.visitMapField(fieldType: SwiftProtobuf._ProtobufMap<SwiftProtobuf.ProtobufString,SwiftProtobuf.ProtobufString>.self, value: self.metadata, fieldNumber: 3)
}
try unknownFields.traverse(visitor: &visitor)
}

public static func ==(lhs: Google_Rpc_ErrorInfo, rhs: Google_Rpc_ErrorInfo) -> Bool {
if lhs.reason != rhs.reason {return false}
if lhs.domain != rhs.domain {return false}
if lhs.metadata != rhs.metadata {return false}
if lhs.unknownFields != rhs.unknownFields {return false}
return true
}
}
51 changes: 51 additions & 0 deletions Sources/API/V1/googleapis/google/rpc/error_details.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package google.rpc;

option go_package = "google.golang.org/genproto/googleapis/rpc/errdetails;errdetails";
option java_multiple_files = true;
option java_outer_classname = "ErrorDetailsProto";
option java_package = "com.google.rpc";
option objc_class_prefix = "RPC";

message ErrorInfo {
// The reason of the error. This is a constant value that identifies the
// proximate cause of the error. Error reasons are unique within a particular
// domain of errors. This should be at most 63 characters and match a
// regular expression of `[A-Z][A-Z0-9_]+[A-Z0-9]`, which represents
// UPPER_SNAKE_CASE.
string reason = 1;

// The logical grouping to which the "reason" belongs. The error domain
// is typically the registered service name of the tool or product that
// generates the error. Example: "pubsub.googleapis.com". If the error is
// generated by some common infrastructure, the error domain must be a
// globally unique value that identifies the infrastructure. For Google API
// infrastructure, the error domain is "googleapis.com".
string domain = 2;

// Additional structured details about this error.
//
// Keys must match a regular expression of `[a-z][a-zA-Z0-9-_]+` but should
// ideally be lowerCamelCase. Also, they must be limited to 64 characters in
// length. When identifying the current value of an exceeded limit, the units
// should be contained in the key, not the value. For example, rather than
// `{"instanceLimit": "100/request"}`, should be returned as,
// `{"instanceLimitPerRequest": "100"}`, if the client exceeds the number of
// instances that can be created in a single (batch) request.
map<string, string> metadata = 3;
}
2 changes: 1 addition & 1 deletion Sources/Core/Attachment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import Connect
import Foundation

class Attachment {
final class Attachment: @unchecked Sendable {
var doc: Document
var docID: String
var syncMode: SyncMode
Expand Down
Loading

0 comments on commit 1aa3dd8

Please sign in to comment.