mirror of https://github.com/usememos/memos
refactor: update workspace store definition
parent
6d842711e2
commit
3e6e56b008
@ -0,0 +1,465 @@
|
|||||||
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
|
// versions:
|
||||||
|
// protoc-gen-go v1.31.0
|
||||||
|
// protoc (unknown)
|
||||||
|
// source: store/storage.proto
|
||||||
|
|
||||||
|
package store
|
||||||
|
|
||||||
|
import (
|
||||||
|
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||||
|
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||||
|
reflect "reflect"
|
||||||
|
sync "sync"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// Verify that this generated code is sufficiently up-to-date.
|
||||||
|
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||||
|
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||||
|
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||||
|
)
|
||||||
|
|
||||||
|
type Storage_Type int32
|
||||||
|
|
||||||
|
const (
|
||||||
|
Storage_TYPE_UNSPECIFIED Storage_Type = 0
|
||||||
|
Storage_S3 Storage_Type = 1
|
||||||
|
)
|
||||||
|
|
||||||
|
// Enum value maps for Storage_Type.
|
||||||
|
var (
|
||||||
|
Storage_Type_name = map[int32]string{
|
||||||
|
0: "TYPE_UNSPECIFIED",
|
||||||
|
1: "S3",
|
||||||
|
}
|
||||||
|
Storage_Type_value = map[string]int32{
|
||||||
|
"TYPE_UNSPECIFIED": 0,
|
||||||
|
"S3": 1,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func (x Storage_Type) Enum() *Storage_Type {
|
||||||
|
p := new(Storage_Type)
|
||||||
|
*p = x
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x Storage_Type) String() string {
|
||||||
|
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (Storage_Type) Descriptor() protoreflect.EnumDescriptor {
|
||||||
|
return file_store_storage_proto_enumTypes[0].Descriptor()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (Storage_Type) Type() protoreflect.EnumType {
|
||||||
|
return &file_store_storage_proto_enumTypes[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x Storage_Type) Number() protoreflect.EnumNumber {
|
||||||
|
return protoreflect.EnumNumber(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use Storage_Type.Descriptor instead.
|
||||||
|
func (Storage_Type) EnumDescriptor() ([]byte, []int) {
|
||||||
|
return file_store_storage_proto_rawDescGZIP(), []int{0, 0}
|
||||||
|
}
|
||||||
|
|
||||||
|
type Storage struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||||
|
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
|
||||||
|
Type Storage_Type `protobuf:"varint,3,opt,name=type,proto3,enum=memos.store.Storage_Type" json:"type,omitempty"`
|
||||||
|
Config *StorageConfig `protobuf:"bytes,4,opt,name=config,proto3" json:"config,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *Storage) Reset() {
|
||||||
|
*x = Storage{}
|
||||||
|
if protoimpl.UnsafeEnabled {
|
||||||
|
mi := &file_store_storage_proto_msgTypes[0]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *Storage) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Storage) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *Storage) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_store_storage_proto_msgTypes[0]
|
||||||
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use Storage.ProtoReflect.Descriptor instead.
|
||||||
|
func (*Storage) Descriptor() ([]byte, []int) {
|
||||||
|
return file_store_storage_proto_rawDescGZIP(), []int{0}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *Storage) GetId() int32 {
|
||||||
|
if x != nil {
|
||||||
|
return x.Id
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *Storage) GetName() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.Name
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *Storage) GetType() Storage_Type {
|
||||||
|
if x != nil {
|
||||||
|
return x.Type
|
||||||
|
}
|
||||||
|
return Storage_TYPE_UNSPECIFIED
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *Storage) GetConfig() *StorageConfig {
|
||||||
|
if x != nil {
|
||||||
|
return x.Config
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type StorageConfig struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
// Types that are assignable to StorageConfig:
|
||||||
|
//
|
||||||
|
// *StorageConfig_S3Config
|
||||||
|
StorageConfig isStorageConfig_StorageConfig `protobuf_oneof:"storage_config"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *StorageConfig) Reset() {
|
||||||
|
*x = StorageConfig{}
|
||||||
|
if protoimpl.UnsafeEnabled {
|
||||||
|
mi := &file_store_storage_proto_msgTypes[1]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *StorageConfig) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*StorageConfig) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *StorageConfig) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_store_storage_proto_msgTypes[1]
|
||||||
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use StorageConfig.ProtoReflect.Descriptor instead.
|
||||||
|
func (*StorageConfig) Descriptor() ([]byte, []int) {
|
||||||
|
return file_store_storage_proto_rawDescGZIP(), []int{1}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *StorageConfig) GetStorageConfig() isStorageConfig_StorageConfig {
|
||||||
|
if m != nil {
|
||||||
|
return m.StorageConfig
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *StorageConfig) GetS3Config() *S3Config {
|
||||||
|
if x, ok := x.GetStorageConfig().(*StorageConfig_S3Config); ok {
|
||||||
|
return x.S3Config
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type isStorageConfig_StorageConfig interface {
|
||||||
|
isStorageConfig_StorageConfig()
|
||||||
|
}
|
||||||
|
|
||||||
|
type StorageConfig_S3Config struct {
|
||||||
|
S3Config *S3Config `protobuf:"bytes,1,opt,name=s3_config,json=s3Config,proto3,oneof"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*StorageConfig_S3Config) isStorageConfig_StorageConfig() {}
|
||||||
|
|
||||||
|
type S3Config struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
EndPoint string `protobuf:"bytes,1,opt,name=end_point,json=endPoint,proto3" json:"end_point,omitempty"`
|
||||||
|
Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"`
|
||||||
|
Region string `protobuf:"bytes,3,opt,name=region,proto3" json:"region,omitempty"`
|
||||||
|
AccessKey string `protobuf:"bytes,4,opt,name=access_key,json=accessKey,proto3" json:"access_key,omitempty"`
|
||||||
|
SecretKey string `protobuf:"bytes,5,opt,name=secret_key,json=secretKey,proto3" json:"secret_key,omitempty"`
|
||||||
|
Bucket string `protobuf:"bytes,6,opt,name=bucket,proto3" json:"bucket,omitempty"`
|
||||||
|
UrlPrefix string `protobuf:"bytes,7,opt,name=url_prefix,json=urlPrefix,proto3" json:"url_prefix,omitempty"`
|
||||||
|
UrlSuffix string `protobuf:"bytes,8,opt,name=url_suffix,json=urlSuffix,proto3" json:"url_suffix,omitempty"`
|
||||||
|
PreSign bool `protobuf:"varint,9,opt,name=pre_sign,json=preSign,proto3" json:"pre_sign,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *S3Config) Reset() {
|
||||||
|
*x = S3Config{}
|
||||||
|
if protoimpl.UnsafeEnabled {
|
||||||
|
mi := &file_store_storage_proto_msgTypes[2]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *S3Config) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*S3Config) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *S3Config) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_store_storage_proto_msgTypes[2]
|
||||||
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use S3Config.ProtoReflect.Descriptor instead.
|
||||||
|
func (*S3Config) Descriptor() ([]byte, []int) {
|
||||||
|
return file_store_storage_proto_rawDescGZIP(), []int{2}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *S3Config) GetEndPoint() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.EndPoint
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *S3Config) GetPath() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.Path
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *S3Config) GetRegion() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.Region
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *S3Config) GetAccessKey() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.AccessKey
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *S3Config) GetSecretKey() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.SecretKey
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *S3Config) GetBucket() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.Bucket
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *S3Config) GetUrlPrefix() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.UrlPrefix
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *S3Config) GetUrlSuffix() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.UrlSuffix
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *S3Config) GetPreSign() bool {
|
||||||
|
if x != nil {
|
||||||
|
return x.PreSign
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
var File_store_storage_proto protoreflect.FileDescriptor
|
||||||
|
|
||||||
|
var file_store_storage_proto_rawDesc = []byte{
|
||||||
|
0x0a, 0x13, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e,
|
||||||
|
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0b, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x73, 0x74, 0x6f,
|
||||||
|
0x72, 0x65, 0x22, 0xb6, 0x01, 0x0a, 0x07, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x12, 0x0e,
|
||||||
|
0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12,
|
||||||
|
0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61,
|
||||||
|
0x6d, 0x65, 0x12, 0x2d, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e,
|
||||||
|
0x32, 0x19, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x53,
|
||||||
|
0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70,
|
||||||
|
0x65, 0x12, 0x32, 0x0a, 0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x04, 0x20, 0x01, 0x28,
|
||||||
|
0x0b, 0x32, 0x1a, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e,
|
||||||
|
0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x06, 0x63,
|
||||||
|
0x6f, 0x6e, 0x66, 0x69, 0x67, 0x22, 0x24, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a,
|
||||||
|
0x10, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45,
|
||||||
|
0x44, 0x10, 0x00, 0x12, 0x06, 0x0a, 0x02, 0x53, 0x33, 0x10, 0x01, 0x22, 0x57, 0x0a, 0x0d, 0x53,
|
||||||
|
0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x34, 0x0a, 0x09,
|
||||||
|
0x73, 0x33, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32,
|
||||||
|
0x15, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x53, 0x33,
|
||||||
|
0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x48, 0x00, 0x52, 0x08, 0x73, 0x33, 0x43, 0x6f, 0x6e, 0x66,
|
||||||
|
0x69, 0x67, 0x42, 0x10, 0x0a, 0x0e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x6f,
|
||||||
|
0x6e, 0x66, 0x69, 0x67, 0x22, 0x82, 0x02, 0x0a, 0x08, 0x53, 0x33, 0x43, 0x6f, 0x6e, 0x66, 0x69,
|
||||||
|
0x67, 0x12, 0x1b, 0x0a, 0x09, 0x65, 0x6e, 0x64, 0x5f, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x01,
|
||||||
|
0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x6e, 0x64, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x12,
|
||||||
|
0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61,
|
||||||
|
0x74, 0x68, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01,
|
||||||
|
0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x61, 0x63,
|
||||||
|
0x63, 0x65, 0x73, 0x73, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09,
|
||||||
|
0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4b, 0x65, 0x79, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x65, 0x63,
|
||||||
|
0x72, 0x65, 0x74, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73,
|
||||||
|
0x65, 0x63, 0x72, 0x65, 0x74, 0x4b, 0x65, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x62, 0x75, 0x63, 0x6b,
|
||||||
|
0x65, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x62, 0x75, 0x63, 0x6b, 0x65, 0x74,
|
||||||
|
0x12, 0x1d, 0x0a, 0x0a, 0x75, 0x72, 0x6c, 0x5f, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x18, 0x07,
|
||||||
|
0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x75, 0x72, 0x6c, 0x50, 0x72, 0x65, 0x66, 0x69, 0x78, 0x12,
|
||||||
|
0x1d, 0x0a, 0x0a, 0x75, 0x72, 0x6c, 0x5f, 0x73, 0x75, 0x66, 0x66, 0x69, 0x78, 0x18, 0x08, 0x20,
|
||||||
|
0x01, 0x28, 0x09, 0x52, 0x09, 0x75, 0x72, 0x6c, 0x53, 0x75, 0x66, 0x66, 0x69, 0x78, 0x12, 0x19,
|
||||||
|
0x0a, 0x08, 0x70, 0x72, 0x65, 0x5f, 0x73, 0x69, 0x67, 0x6e, 0x18, 0x09, 0x20, 0x01, 0x28, 0x08,
|
||||||
|
0x52, 0x07, 0x70, 0x72, 0x65, 0x53, 0x69, 0x67, 0x6e, 0x42, 0x97, 0x01, 0x0a, 0x0f, 0x63, 0x6f,
|
||||||
|
0x6d, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x42, 0x0c, 0x53,
|
||||||
|
0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x29, 0x67,
|
||||||
|
0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x75, 0x73, 0x65, 0x6d, 0x65, 0x6d,
|
||||||
|
0x6f, 0x73, 0x2f, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67,
|
||||||
|
0x65, 0x6e, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0xa2, 0x02, 0x03, 0x4d, 0x53, 0x58, 0xaa, 0x02,
|
||||||
|
0x0b, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x65, 0xca, 0x02, 0x0b, 0x4d,
|
||||||
|
0x65, 0x6d, 0x6f, 0x73, 0x5c, 0x53, 0x74, 0x6f, 0x72, 0x65, 0xe2, 0x02, 0x17, 0x4d, 0x65, 0x6d,
|
||||||
|
0x6f, 0x73, 0x5c, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61,
|
||||||
|
0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0c, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x53, 0x74,
|
||||||
|
0x6f, 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
file_store_storage_proto_rawDescOnce sync.Once
|
||||||
|
file_store_storage_proto_rawDescData = file_store_storage_proto_rawDesc
|
||||||
|
)
|
||||||
|
|
||||||
|
func file_store_storage_proto_rawDescGZIP() []byte {
|
||||||
|
file_store_storage_proto_rawDescOnce.Do(func() {
|
||||||
|
file_store_storage_proto_rawDescData = protoimpl.X.CompressGZIP(file_store_storage_proto_rawDescData)
|
||||||
|
})
|
||||||
|
return file_store_storage_proto_rawDescData
|
||||||
|
}
|
||||||
|
|
||||||
|
var file_store_storage_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
||||||
|
var file_store_storage_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
|
||||||
|
var file_store_storage_proto_goTypes = []interface{}{
|
||||||
|
(Storage_Type)(0), // 0: memos.store.Storage.Type
|
||||||
|
(*Storage)(nil), // 1: memos.store.Storage
|
||||||
|
(*StorageConfig)(nil), // 2: memos.store.StorageConfig
|
||||||
|
(*S3Config)(nil), // 3: memos.store.S3Config
|
||||||
|
}
|
||||||
|
var file_store_storage_proto_depIdxs = []int32{
|
||||||
|
0, // 0: memos.store.Storage.type:type_name -> memos.store.Storage.Type
|
||||||
|
2, // 1: memos.store.Storage.config:type_name -> memos.store.StorageConfig
|
||||||
|
3, // 2: memos.store.StorageConfig.s3_config:type_name -> memos.store.S3Config
|
||||||
|
3, // [3:3] is the sub-list for method output_type
|
||||||
|
3, // [3:3] is the sub-list for method input_type
|
||||||
|
3, // [3:3] is the sub-list for extension type_name
|
||||||
|
3, // [3:3] is the sub-list for extension extendee
|
||||||
|
0, // [0:3] is the sub-list for field type_name
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() { file_store_storage_proto_init() }
|
||||||
|
func file_store_storage_proto_init() {
|
||||||
|
if File_store_storage_proto != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !protoimpl.UnsafeEnabled {
|
||||||
|
file_store_storage_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||||
|
switch v := v.(*Storage); i {
|
||||||
|
case 0:
|
||||||
|
return &v.state
|
||||||
|
case 1:
|
||||||
|
return &v.sizeCache
|
||||||
|
case 2:
|
||||||
|
return &v.unknownFields
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
file_store_storage_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||||
|
switch v := v.(*StorageConfig); i {
|
||||||
|
case 0:
|
||||||
|
return &v.state
|
||||||
|
case 1:
|
||||||
|
return &v.sizeCache
|
||||||
|
case 2:
|
||||||
|
return &v.unknownFields
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
file_store_storage_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||||
|
switch v := v.(*S3Config); i {
|
||||||
|
case 0:
|
||||||
|
return &v.state
|
||||||
|
case 1:
|
||||||
|
return &v.sizeCache
|
||||||
|
case 2:
|
||||||
|
return &v.unknownFields
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
file_store_storage_proto_msgTypes[1].OneofWrappers = []interface{}{
|
||||||
|
(*StorageConfig_S3Config)(nil),
|
||||||
|
}
|
||||||
|
type x struct{}
|
||||||
|
out := protoimpl.TypeBuilder{
|
||||||
|
File: protoimpl.DescBuilder{
|
||||||
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||||
|
RawDescriptor: file_store_storage_proto_rawDesc,
|
||||||
|
NumEnums: 1,
|
||||||
|
NumMessages: 3,
|
||||||
|
NumExtensions: 0,
|
||||||
|
NumServices: 0,
|
||||||
|
},
|
||||||
|
GoTypes: file_store_storage_proto_goTypes,
|
||||||
|
DependencyIndexes: file_store_storage_proto_depIdxs,
|
||||||
|
EnumInfos: file_store_storage_proto_enumTypes,
|
||||||
|
MessageInfos: file_store_storage_proto_msgTypes,
|
||||||
|
}.Build()
|
||||||
|
File_store_storage_proto = out.File
|
||||||
|
file_store_storage_proto_rawDesc = nil
|
||||||
|
file_store_storage_proto_goTypes = nil
|
||||||
|
file_store_storage_proto_depIdxs = nil
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
package memos.store;
|
||||||
|
|
||||||
|
option go_package = "gen/store";
|
||||||
|
|
||||||
|
message Storage {
|
||||||
|
int32 id = 1;
|
||||||
|
string name = 2;
|
||||||
|
|
||||||
|
enum Type {
|
||||||
|
TYPE_UNSPECIFIED = 0;
|
||||||
|
S3 = 1;
|
||||||
|
}
|
||||||
|
Type type = 3;
|
||||||
|
StorageConfig config = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
message StorageConfig {
|
||||||
|
oneof storage_config {
|
||||||
|
S3Config s3_config = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
message S3Config {
|
||||||
|
string end_point = 1;
|
||||||
|
string path = 2;
|
||||||
|
string region = 3;
|
||||||
|
string access_key = 4;
|
||||||
|
string secret_key = 5;
|
||||||
|
string bucket = 6;
|
||||||
|
string url_prefix = 7;
|
||||||
|
string url_suffix = 8;
|
||||||
|
bool pre_sign = 9;
|
||||||
|
}
|
@ -1,5 +1,4 @@
|
|||||||
export * from "./global";
|
export * from "./global";
|
||||||
export * from "./filter";
|
export * from "./filter";
|
||||||
export * from "./tag";
|
export * from "./tag";
|
||||||
export * from "./resource";
|
|
||||||
export * from "./dialog";
|
export * from "./dialog";
|
||||||
|
@ -1,51 +0,0 @@
|
|||||||
import { resourceServiceClient } from "@/grpcweb";
|
|
||||||
import * as api from "@/helpers/api";
|
|
||||||
import { CreateResourceRequest, Resource, UpdateResourceRequest } from "@/types/proto/api/v2/resource_service";
|
|
||||||
import { useTranslate } from "@/utils/i18n";
|
|
||||||
import store, { useAppSelector } from "../";
|
|
||||||
import { patchResource, setResources } from "../reducer/resource";
|
|
||||||
import { useGlobalStore } from "./global";
|
|
||||||
|
|
||||||
export const useResourceStore = () => {
|
|
||||||
const state = useAppSelector((state) => state.resource);
|
|
||||||
const t = useTranslate();
|
|
||||||
const globalStore = useGlobalStore();
|
|
||||||
const maxUploadSizeMiB = globalStore.state.systemStatus.maxUploadSizeMiB;
|
|
||||||
|
|
||||||
return {
|
|
||||||
state,
|
|
||||||
getState: () => {
|
|
||||||
return store.getState().resource;
|
|
||||||
},
|
|
||||||
async createResource(create: CreateResourceRequest): Promise<Resource> {
|
|
||||||
const { resource } = await resourceServiceClient.createResource(create);
|
|
||||||
if (!resource) {
|
|
||||||
throw new Error("resource is null");
|
|
||||||
}
|
|
||||||
const resourceList = state.resources;
|
|
||||||
store.dispatch(setResources([resource, ...resourceList]));
|
|
||||||
return resource;
|
|
||||||
},
|
|
||||||
async createResourceWithBlob(file: File): Promise<Resource> {
|
|
||||||
const { name: filename, size } = file;
|
|
||||||
if (size > maxUploadSizeMiB * 1024 * 1024) {
|
|
||||||
return Promise.reject(t("message.maximum-upload-size-is", { size: maxUploadSizeMiB }));
|
|
||||||
}
|
|
||||||
|
|
||||||
const formData = new FormData();
|
|
||||||
formData.append("file", file, filename);
|
|
||||||
const { data: resource } = await api.createResourceWithBlob(formData);
|
|
||||||
const resourceList = state.resources;
|
|
||||||
store.dispatch(setResources([resource, ...resourceList]));
|
|
||||||
return resource;
|
|
||||||
},
|
|
||||||
async updateResource(update: UpdateResourceRequest): Promise<Resource> {
|
|
||||||
const { resource } = await resourceServiceClient.updateResource(update);
|
|
||||||
if (!resource) {
|
|
||||||
throw new Error("resource is null");
|
|
||||||
}
|
|
||||||
store.dispatch(patchResource(resource));
|
|
||||||
return resource;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
};
|
|
Loading…
Reference in New Issue