func FromEventType(pbDocEventType api.DocEventType) (types.DocEventType, error) {
	switch pbDocEventType {
	case api.DocEventType_DOCUMENTS_CHANGED:
		return types.DocumentsChangedEvent, nil
	case api.DocEventType_DOCUMENTS_WATCHED:
		return types.DocumentsWatchedEvent, nil
	case api.DocEventType_DOCUMENTS_UNWATCHED:
		return types.DocumentsUnwatchedEvent, nil
	case api.DocEventType_METADATA_CHANGED:
		return types.MetadataChangedEvent, nil
	}
	return "", fmt.Errorf("%v: %w", pbDocEventType, ErrUnsupportedEventType)
}
FromEventType converts the given Protobuf format to model format.
package converter
import (
	"fmt"
	"github.com/yorkie-team/yorkie/api"
	"github.com/yorkie-team/yorkie/pkg/document/change"
	"github.com/yorkie-team/yorkie/pkg/document/checkpoint"
	"github.com/yorkie-team/yorkie/pkg/document/json"
	"github.com/yorkie-team/yorkie/pkg/document/key"
	"github.com/yorkie-team/yorkie/pkg/document/operation"
	"github.com/yorkie-team/yorkie/pkg/document/time"
	"github.com/yorkie-team/yorkie/pkg/types"
	"github.com/yorkie-team/yorkie/yorkie/backend/sync"
)
func FromClient(pbClient *api.Client) (*types.Client, error) {
	id, err := time.ActorIDFromBytes(pbClient.Id)
	if err != nil {
		return nil, err
	}
	return &types.Client{
		ID:           id,
		MetadataInfo: FromMetadataInfo(pbClient.Metadata),
	}, nil
}
func FromMetadataInfo(pbMetadata *api.Metadata) types.MetadataInfo {
	return types.MetadataInfo{
		Clock: pbMetadata.Clock,
		Data:  pbMetadata.Data,
	}
}
func FromChangePack(pbPack *api.ChangePack) (*change.Pack, error) {
	if pbPack == nil {
		return nil, ErrPackRequired
	}
	if pbPack.Checkpoint == nil {
		return nil, ErrCheckpointRequired
	}
	changes, err := fromChanges(pbPack.Changes)
	if err != nil {
		return nil, err
	}
	minSyncedTicket, err := fromTimeTicket(pbPack.MinSyncedTicket)
	if err != nil {
		return nil, err
	}
	return &change.Pack{
		DocumentKey:     fromDocumentKey(pbPack.DocumentKey),
		Checkpoint:      fromCheckpoint(pbPack.Checkpoint),
		Changes:         changes,
		Snapshot:        pbPack.Snapshot,
		MinSyncedTicket: minSyncedTicket,
	}, nil
}
func fromDocumentKey(pbKey *api.DocumentKey) *key.Key {
	return &key.Key{
		Collection: pbKey.Collection,
		Document:   pbKey.Document,
	}
}
func fromCheckpoint(pbCheckpoint *api.Checkpoint) *checkpoint.Checkpoint {
	return checkpoint.New(
		pbCheckpoint.ServerSeq,
		pbCheckpoint.ClientSeq,
	)
}
func fromChanges(pbChanges []*api.Change) ([]*change.Change, error) {
	var changes []*change.Change
	for _, pbChange := range pbChanges {
		changeID, err := fromChangeID(pbChange.Id)
		if err != nil {
			return nil, err
		}
		operations, err := FromOperations(pbChange.Operations)
		if err != nil {
			return nil, err
		}
		changes = append(changes, change.New(
			changeID,
			pbChange.Message,
			operations,
		))
	}
	return changes, nil
}
func fromChangeID(id *api.ChangeID) (*change.ID, error) {
	actorID, err := time.ActorIDFromBytes(id.ActorId)
	if err != nil {
		return nil, err
	}
	return change.NewID(
		id.ClientSeq,
		id.Lamport,
		actorID,
	), nil
}
func FromDocumentKeys(pbKeys []*api.DocumentKey) []*key.Key {
	var keys []*key.Key
	for _, pbKey := range pbKeys {
		keys = append(keys, fromDocumentKey(pbKey))
	}
	return keys
}