diff --git a/app/store/calendar.ts b/app/store/calendar.ts index 4d1c6b05e..1381a70a7 100644 --- a/app/store/calendar.ts +++ b/app/store/calendar.ts @@ -3,7 +3,6 @@ import Dexie, { type Table } from 'dexie'; import 'dexie-observable'; import 'dexie-syncable'; import { defineStore } from 'pinia'; -import '~/utils/dexie.ts'; import type { Calendar, CalendarEntry } from '~~/gen/ts/resources/calendar/calendar'; import { RsvpResponses } from '~~/gen/ts/resources/calendar/calendar'; import { NotificationCategory, NotificationType } from '~~/gen/ts/resources/notifications/notifications'; diff --git a/gen/go/proto/resources/common/cron/cron.pb.go b/gen/go/proto/resources/common/cron/cron.pb.go index 46934b8f0..048209c8e 100644 --- a/gen/go/proto/resources/common/cron/cron.pb.go +++ b/gen/go/proto/resources/common/cron/cron.pb.go @@ -7,8 +7,10 @@ package cron import ( + timestamp "github.com/fivenet-app/fivenet/gen/go/proto/resources/timestamp" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + anypb "google.golang.org/protobuf/types/known/anypb" reflect "reflect" sync "sync" ) @@ -20,10 +22,68 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +type CronjobState int32 + +const ( + CronjobState_CRONJOB_STATE_UNSPECIFIED CronjobState = 0 + CronjobState_CRONJOB_STATE_WAITING CronjobState = 1 + CronjobState_CRONJOB_STATE_PENDING CronjobState = 2 + CronjobState_CRONJOB_STATE_RUNNING CronjobState = 3 +) + +// Enum value maps for CronjobState. +var ( + CronjobState_name = map[int32]string{ + 0: "CRONJOB_STATE_UNSPECIFIED", + 1: "CRONJOB_STATE_WAITING", + 2: "CRONJOB_STATE_PENDING", + 3: "CRONJOB_STATE_RUNNING", + } + CronjobState_value = map[string]int32{ + "CRONJOB_STATE_UNSPECIFIED": 0, + "CRONJOB_STATE_WAITING": 1, + "CRONJOB_STATE_PENDING": 2, + "CRONJOB_STATE_RUNNING": 3, + } +) + +func (x CronjobState) Enum() *CronjobState { + p := new(CronjobState) + *p = x + return p +} + +func (x CronjobState) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (CronjobState) Descriptor() protoreflect.EnumDescriptor { + return file_resources_common_cron_cron_proto_enumTypes[0].Descriptor() +} + +func (CronjobState) Type() protoreflect.EnumType { + return &file_resources_common_cron_cron_proto_enumTypes[0] +} + +func (x CronjobState) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use CronjobState.Descriptor instead. +func (CronjobState) EnumDescriptor() ([]byte, []int) { + return file_resources_common_cron_cron_proto_rawDescGZIP(), []int{0} +} + type Cronjob struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Schedule string `protobuf:"bytes,2,opt,name=schedule,proto3" json:"schedule,omitempty"` + State CronjobState `protobuf:"varint,3,opt,name=state,proto3,enum=resources.common.cron.CronjobState" json:"state,omitempty"` + NextScheduleTime *timestamp.Timestamp `protobuf:"bytes,4,opt,name=next_schedule_time,json=nextScheduleTime,proto3" json:"next_schedule_time,omitempty"` + LastAttemptTime *timestamp.Timestamp `protobuf:"bytes,5,opt,name=last_attempt_time,json=lastAttemptTime,proto3" json:"last_attempt_time,omitempty"` } func (x *Cronjob) Reset() { @@ -58,19 +118,146 @@ func (*Cronjob) Descriptor() ([]byte, []int) { return file_resources_common_cron_cron_proto_rawDescGZIP(), []int{0} } +func (x *Cronjob) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Cronjob) GetSchedule() string { + if x != nil { + return x.Schedule + } + return "" +} + +func (x *Cronjob) GetState() CronjobState { + if x != nil { + return x.State + } + return CronjobState_CRONJOB_STATE_UNSPECIFIED +} + +func (x *Cronjob) GetNextScheduleTime() *timestamp.Timestamp { + if x != nil { + return x.NextScheduleTime + } + return nil +} + +func (x *Cronjob) GetLastAttemptTime() *timestamp.Timestamp { + if x != nil { + return x.LastAttemptTime + } + return nil +} + +type CronjobData struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + UpdatedAt *timestamp.Timestamp `protobuf:"bytes,1,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"` + Data *anypb.Any `protobuf:"bytes,2,opt,name=data,proto3,oneof" json:"data,omitempty"` +} + +func (x *CronjobData) Reset() { + *x = CronjobData{} + if protoimpl.UnsafeEnabled { + mi := &file_resources_common_cron_cron_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CronjobData) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CronjobData) ProtoMessage() {} + +func (x *CronjobData) ProtoReflect() protoreflect.Message { + mi := &file_resources_common_cron_cron_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 CronjobData.ProtoReflect.Descriptor instead. +func (*CronjobData) Descriptor() ([]byte, []int) { + return file_resources_common_cron_cron_proto_rawDescGZIP(), []int{1} +} + +func (x *CronjobData) GetUpdatedAt() *timestamp.Timestamp { + if x != nil { + return x.UpdatedAt + } + return nil +} + +func (x *CronjobData) GetData() *anypb.Any { + if x != nil { + return x.Data + } + return nil +} + var File_resources_common_cron_cron_proto protoreflect.FileDescriptor var file_resources_common_cron_cron_proto_rawDesc = []byte{ 0x0a, 0x20, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x63, 0x72, 0x6f, 0x6e, 0x2f, 0x63, 0x72, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x15, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x63, 0x6f, - 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x63, 0x72, 0x6f, 0x6e, 0x22, 0x09, 0x0a, 0x07, 0x43, 0x72, 0x6f, - 0x6e, 0x6a, 0x6f, 0x62, 0x42, 0x48, 0x5a, 0x46, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x66, 0x69, 0x76, 0x65, 0x6e, 0x65, 0x74, 0x2d, 0x61, 0x70, 0x70, 0x2f, 0x66, - 0x69, 0x76, 0x65, 0x6e, 0x65, 0x74, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x67, 0x6f, 0x2f, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x63, 0x6f, - 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x63, 0x72, 0x6f, 0x6e, 0x3b, 0x63, 0x72, 0x6f, 0x6e, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x63, 0x72, 0x6f, 0x6e, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x23, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, + 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, + 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x8e, 0x02, 0x0a, 0x07, 0x43, 0x72, + 0x6f, 0x6e, 0x6a, 0x6f, 0x62, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x63, 0x68, + 0x65, 0x64, 0x75, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x63, 0x68, + 0x65, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x39, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x0e, 0x32, 0x23, 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, + 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x63, 0x72, 0x6f, 0x6e, 0x2e, 0x43, 0x72, 0x6f, + 0x6e, 0x6a, 0x6f, 0x62, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, + 0x12, 0x4c, 0x0a, 0x12, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, + 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x72, + 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, + 0x6d, 0x70, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x10, 0x6e, 0x65, + 0x78, 0x74, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x4a, + 0x0a, 0x11, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x61, 0x74, 0x74, 0x65, 0x6d, 0x70, 0x74, 0x5f, 0x74, + 0x69, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x72, 0x65, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, + 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0f, 0x6c, 0x61, 0x73, 0x74, 0x41, + 0x74, 0x74, 0x65, 0x6d, 0x70, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x22, 0x84, 0x01, 0x0a, 0x0b, 0x43, + 0x72, 0x6f, 0x6e, 0x6a, 0x6f, 0x62, 0x44, 0x61, 0x74, 0x61, 0x12, 0x3d, 0x0a, 0x0a, 0x75, 0x70, + 0x64, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, + 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x74, 0x69, 0x6d, 0x65, 0x73, + 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, + 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x2d, 0x0a, 0x04, 0x64, 0x61, 0x74, + 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x48, 0x00, 0x52, + 0x04, 0x64, 0x61, 0x74, 0x61, 0x88, 0x01, 0x01, 0x42, 0x07, 0x0a, 0x05, 0x5f, 0x64, 0x61, 0x74, + 0x61, 0x2a, 0x7e, 0x0a, 0x0c, 0x43, 0x72, 0x6f, 0x6e, 0x6a, 0x6f, 0x62, 0x53, 0x74, 0x61, 0x74, + 0x65, 0x12, 0x1d, 0x0a, 0x19, 0x43, 0x52, 0x4f, 0x4e, 0x4a, 0x4f, 0x42, 0x5f, 0x53, 0x54, 0x41, + 0x54, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, + 0x12, 0x19, 0x0a, 0x15, 0x43, 0x52, 0x4f, 0x4e, 0x4a, 0x4f, 0x42, 0x5f, 0x53, 0x54, 0x41, 0x54, + 0x45, 0x5f, 0x57, 0x41, 0x49, 0x54, 0x49, 0x4e, 0x47, 0x10, 0x01, 0x12, 0x19, 0x0a, 0x15, 0x43, + 0x52, 0x4f, 0x4e, 0x4a, 0x4f, 0x42, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x50, 0x45, 0x4e, + 0x44, 0x49, 0x4e, 0x47, 0x10, 0x02, 0x12, 0x19, 0x0a, 0x15, 0x43, 0x52, 0x4f, 0x4e, 0x4a, 0x4f, + 0x42, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x52, 0x55, 0x4e, 0x4e, 0x49, 0x4e, 0x47, 0x10, + 0x03, 0x42, 0x48, 0x5a, 0x46, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x66, 0x69, 0x76, 0x65, 0x6e, 0x65, 0x74, 0x2d, 0x61, 0x70, 0x70, 0x2f, 0x66, 0x69, 0x76, 0x65, + 0x6e, 0x65, 0x74, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x67, 0x6f, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, + 0x6e, 0x2f, 0x63, 0x72, 0x6f, 0x6e, 0x3b, 0x63, 0x72, 0x6f, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( @@ -85,16 +272,26 @@ func file_resources_common_cron_cron_proto_rawDescGZIP() []byte { return file_resources_common_cron_cron_proto_rawDescData } -var file_resources_common_cron_cron_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_resources_common_cron_cron_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_resources_common_cron_cron_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_resources_common_cron_cron_proto_goTypes = []any{ - (*Cronjob)(nil), // 0: resources.common.cron.Cronjob + (CronjobState)(0), // 0: resources.common.cron.CronjobState + (*Cronjob)(nil), // 1: resources.common.cron.Cronjob + (*CronjobData)(nil), // 2: resources.common.cron.CronjobData + (*timestamp.Timestamp)(nil), // 3: resources.timestamp.Timestamp + (*anypb.Any)(nil), // 4: google.protobuf.Any } var file_resources_common_cron_cron_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name + 0, // 0: resources.common.cron.Cronjob.state:type_name -> resources.common.cron.CronjobState + 3, // 1: resources.common.cron.Cronjob.next_schedule_time:type_name -> resources.timestamp.Timestamp + 3, // 2: resources.common.cron.Cronjob.last_attempt_time:type_name -> resources.timestamp.Timestamp + 3, // 3: resources.common.cron.CronjobData.updated_at:type_name -> resources.timestamp.Timestamp + 4, // 4: resources.common.cron.CronjobData.data:type_name -> google.protobuf.Any + 5, // [5:5] is the sub-list for method output_type + 5, // [5:5] is the sub-list for method input_type + 5, // [5:5] is the sub-list for extension type_name + 5, // [5:5] is the sub-list for extension extendee + 0, // [0:5] is the sub-list for field type_name } func init() { file_resources_common_cron_cron_proto_init() } @@ -115,19 +312,33 @@ func file_resources_common_cron_cron_proto_init() { return nil } } + file_resources_common_cron_cron_proto_msgTypes[1].Exporter = func(v any, i int) any { + switch v := v.(*CronjobData); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } + file_resources_common_cron_cron_proto_msgTypes[1].OneofWrappers = []any{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_resources_common_cron_cron_proto_rawDesc, - NumEnums: 0, - NumMessages: 1, + NumEnums: 1, + NumMessages: 2, NumExtensions: 0, NumServices: 0, }, GoTypes: file_resources_common_cron_cron_proto_goTypes, DependencyIndexes: file_resources_common_cron_cron_proto_depIdxs, + EnumInfos: file_resources_common_cron_cron_proto_enumTypes, MessageInfos: file_resources_common_cron_cron_proto_msgTypes, }.Build() File_resources_common_cron_cron_proto = out.File diff --git a/gen/go/proto/resources/common/cron/cron.pb.validate.go b/gen/go/proto/resources/common/cron/cron.pb.validate.go index 4bbe7ae5a..b6a9d977f 100644 --- a/gen/go/proto/resources/common/cron/cron.pb.validate.go +++ b/gen/go/proto/resources/common/cron/cron.pb.validate.go @@ -56,6 +56,70 @@ func (m *Cronjob) validate(all bool) error { var errors []error + // no validation rules for Name + + // no validation rules for Schedule + + // no validation rules for State + + if all { + switch v := interface{}(m.GetNextScheduleTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CronjobValidationError{ + field: "NextScheduleTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CronjobValidationError{ + field: "NextScheduleTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetNextScheduleTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CronjobValidationError{ + field: "NextScheduleTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetLastAttemptTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CronjobValidationError{ + field: "LastAttemptTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CronjobValidationError{ + field: "LastAttemptTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetLastAttemptTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CronjobValidationError{ + field: "LastAttemptTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + if len(errors) > 0 { return CronjobMultiError(errors) } @@ -132,3 +196,164 @@ var _ interface { Cause() error ErrorName() string } = CronjobValidationError{} + +// Validate checks the field values on CronjobData with the rules defined in +// the proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *CronjobData) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CronjobData with the rules defined in +// the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in CronjobDataMultiError, or +// nil if none found. +func (m *CronjobData) ValidateAll() error { + return m.validate(true) +} + +func (m *CronjobData) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetUpdatedAt()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CronjobDataValidationError{ + field: "UpdatedAt", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CronjobDataValidationError{ + field: "UpdatedAt", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUpdatedAt()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CronjobDataValidationError{ + field: "UpdatedAt", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if m.Data != nil { + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CronjobDataValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CronjobDataValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CronjobDataValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return CronjobDataMultiError(errors) + } + + return nil +} + +// CronjobDataMultiError is an error wrapping multiple validation errors +// returned by CronjobData.ValidateAll() if the designated constraints aren't met. +type CronjobDataMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CronjobDataMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m CronjobDataMultiError) AllErrors() []error { return m } + +// CronjobDataValidationError is the validation error returned by +// CronjobData.Validate if the designated constraints aren't met. +type CronjobDataValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CronjobDataValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CronjobDataValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CronjobDataValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CronjobDataValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CronjobDataValidationError) ErrorName() string { return "CronjobDataValidationError" } + +// Error satisfies the builtin error interface +func (e CronjobDataValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sCronjobData.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CronjobDataValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CronjobDataValidationError{} diff --git a/gen/go/proto/resources/common/uuid.go b/gen/go/proto/resources/common/uuid.go new file mode 100644 index 000000000..dd747a611 --- /dev/null +++ b/gen/go/proto/resources/common/uuid.go @@ -0,0 +1,31 @@ +package common + +import ( + "database/sql/driver" + + "github.com/google/uuid" +) + +// Scan implements driver.Valuer for protobuf UUID. +func (x *UUID) Scan(value any) error { + switch t := value.(type) { + case string: + uid, err := uuid.FromBytes([]byte(t)) + x.Uuid = uid.String() + return err + case []byte: + uid, err := uuid.FromBytes(t) + x.Uuid = uid.String() + return err + } + return nil +} + +// Value marshals the value into driver.Valuer. +func (x *UUID) Value() (driver.Value, error) { + if x == nil { + return nil, nil + } + + return x.Uuid, nil +} diff --git a/gen/go/proto/resources/common/uuid.pb.go b/gen/go/proto/resources/common/uuid.pb.go new file mode 100644 index 000000000..fba3b14f0 --- /dev/null +++ b/gen/go/proto/resources/common/uuid.pb.go @@ -0,0 +1,149 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.34.2 +// protoc v3.20.3 +// source: resources/common/uuid.proto + +package common + +import ( + _ "github.com/envoyproxy/protoc-gen-validate/validate" + 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 UUID struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Uuid string `protobuf:"bytes,1,opt,name=uuid,proto3" json:"uuid,omitempty"` +} + +func (x *UUID) Reset() { + *x = UUID{} + if protoimpl.UnsafeEnabled { + mi := &file_resources_common_uuid_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UUID) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UUID) ProtoMessage() {} + +func (x *UUID) ProtoReflect() protoreflect.Message { + mi := &file_resources_common_uuid_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 UUID.ProtoReflect.Descriptor instead. +func (*UUID) Descriptor() ([]byte, []int) { + return file_resources_common_uuid_proto_rawDescGZIP(), []int{0} +} + +func (x *UUID) GetUuid() string { + if x != nil { + return x.Uuid + } + return "" +} + +var File_resources_common_uuid_proto protoreflect.FileDescriptor + +var file_resources_common_uuid_proto_rawDesc = []byte{ + 0x0a, 0x1b, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, + 0x6f, 0x6e, 0x2f, 0x75, 0x75, 0x69, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x10, 0x72, + 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x1a, + 0x17, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, + 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x24, 0x0a, 0x04, 0x55, 0x55, 0x49, 0x44, + 0x12, 0x1c, 0x0a, 0x04, 0x75, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x08, + 0xfa, 0x42, 0x05, 0x72, 0x03, 0xb0, 0x01, 0x01, 0x52, 0x04, 0x75, 0x75, 0x69, 0x64, 0x42, 0x45, + 0x5a, 0x43, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x66, 0x69, 0x76, + 0x65, 0x6e, 0x65, 0x74, 0x2d, 0x61, 0x70, 0x70, 0x2f, 0x66, 0x69, 0x76, 0x65, 0x6e, 0x65, 0x74, + 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x67, 0x6f, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x72, 0x65, + 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x3b, 0x63, + 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_resources_common_uuid_proto_rawDescOnce sync.Once + file_resources_common_uuid_proto_rawDescData = file_resources_common_uuid_proto_rawDesc +) + +func file_resources_common_uuid_proto_rawDescGZIP() []byte { + file_resources_common_uuid_proto_rawDescOnce.Do(func() { + file_resources_common_uuid_proto_rawDescData = protoimpl.X.CompressGZIP(file_resources_common_uuid_proto_rawDescData) + }) + return file_resources_common_uuid_proto_rawDescData +} + +var file_resources_common_uuid_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_resources_common_uuid_proto_goTypes = []any{ + (*UUID)(nil), // 0: resources.common.UUID +} +var file_resources_common_uuid_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_resources_common_uuid_proto_init() } +func file_resources_common_uuid_proto_init() { + if File_resources_common_uuid_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_resources_common_uuid_proto_msgTypes[0].Exporter = func(v any, i int) any { + switch v := v.(*UUID); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_resources_common_uuid_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_resources_common_uuid_proto_goTypes, + DependencyIndexes: file_resources_common_uuid_proto_depIdxs, + MessageInfos: file_resources_common_uuid_proto_msgTypes, + }.Build() + File_resources_common_uuid_proto = out.File + file_resources_common_uuid_proto_rawDesc = nil + file_resources_common_uuid_proto_goTypes = nil + file_resources_common_uuid_proto_depIdxs = nil +} diff --git a/gen/go/proto/resources/common/uuid.pb.validate.go b/gen/go/proto/resources/common/uuid.pb.validate.go new file mode 100644 index 000000000..94759337f --- /dev/null +++ b/gen/go/proto/resources/common/uuid.pb.validate.go @@ -0,0 +1,157 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: resources/common/uuid.proto + +package common + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) + +// define the regex for a UUID once up-front +var _uuid_uuidPattern = regexp.MustCompile("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$") + +// Validate checks the field values on UUID with the rules defined in the proto +// definition for this message. If any rules are violated, the first error +// encountered is returned, or nil if there are no violations. +func (m *UUID) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UUID with the rules defined in the +// proto definition for this message. If any rules are violated, the result is +// a list of violation errors wrapped in UUIDMultiError, or nil if none found. +func (m *UUID) ValidateAll() error { + return m.validate(true) +} + +func (m *UUID) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if err := m._validateUuid(m.GetUuid()); err != nil { + err = UUIDValidationError{ + field: "Uuid", + reason: "value must be a valid UUID", + cause: err, + } + if !all { + return err + } + errors = append(errors, err) + } + + if len(errors) > 0 { + return UUIDMultiError(errors) + } + + return nil +} + +func (m *UUID) _validateUuid(uuid string) error { + if matched := _uuid_uuidPattern.MatchString(uuid); !matched { + return errors.New("invalid uuid format") + } + + return nil +} + +// UUIDMultiError is an error wrapping multiple validation errors returned by +// UUID.ValidateAll() if the designated constraints aren't met. +type UUIDMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UUIDMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m UUIDMultiError) AllErrors() []error { return m } + +// UUIDValidationError is the validation error returned by UUID.Validate if the +// designated constraints aren't met. +type UUIDValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UUIDValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UUIDValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UUIDValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UUIDValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UUIDValidationError) ErrorName() string { return "UUIDValidationError" } + +// Error satisfies the builtin error interface +func (e UUIDValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sUUID.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UUIDValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UUIDValidationError{} diff --git a/gen/grpc-api.md b/gen/grpc-api.md index 82fb1522f..03ca4de0f 100644 --- a/gen/grpc-api.md +++ b/gen/grpc-api.md @@ -67,6 +67,12 @@ - [resources/common/cron/cron.proto](#resources_common_cron_cron-proto) - [Cronjob](#resources-common-cron-Cronjob) + - [CronjobData](#resources-common-cron-CronjobData) + + - [CronjobState](#resources-common-cron-CronjobState) + +- [resources/common/uuid.proto](#resources_common_uuid-proto) + - [UUID](#resources-common-UUID) - [resources/documents/access.proto](#resources_documents_access-proto) - [DocumentAccess](#resources-documents-DocumentAccess) @@ -1612,6 +1618,76 @@ +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| name | [string](#string) | | | +| schedule | [string](#string) | | | +| state | [CronjobState](#resources-common-cron-CronjobState) | | | +| next_schedule_time | [resources.timestamp.Timestamp](#resources-timestamp-Timestamp) | | | +| last_attempt_time | [resources.timestamp.Timestamp](#resources-timestamp-Timestamp) | | | + + + + + + + + +### CronjobData + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| updated_at | [resources.timestamp.Timestamp](#resources-timestamp-Timestamp) | | | +| data | [google.protobuf.Any](#google-protobuf-Any) | optional | | + + + + + + + + + + +### CronjobState + + +| Name | Number | Description | +| ---- | ------ | ----------- | +| CRONJOB_STATE_UNSPECIFIED | 0 | | +| CRONJOB_STATE_WAITING | 1 | | +| CRONJOB_STATE_PENDING | 2 | | +| CRONJOB_STATE_RUNNING | 3 | | + + + + + + + + + + + +

Top

+ +## resources/common/uuid.proto + + + + + +### UUID + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| uuid | [string](#string) | | | + + diff --git a/gen/ts/google/protobuf/any.ts b/gen/ts/google/protobuf/any.ts new file mode 100644 index 000000000..c359a3366 --- /dev/null +++ b/gen/ts/google/protobuf/any.ts @@ -0,0 +1,322 @@ +// @generated by protobuf-ts 2.9.4 with parameter optimize_speed,long_type_number,force_server_none +// @generated from protobuf file "google/protobuf/any.proto" (package "google.protobuf", syntax proto3) +// @ts-nocheck +// +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +import type { BinaryWriteOptions } from "@protobuf-ts/runtime"; +import type { IBinaryWriter } from "@protobuf-ts/runtime"; +import { WireType } from "@protobuf-ts/runtime"; +import type { IBinaryReader } from "@protobuf-ts/runtime"; +import { UnknownFieldHandler } from "@protobuf-ts/runtime"; +import type { PartialMessage } from "@protobuf-ts/runtime"; +import { reflectionMergePartial } from "@protobuf-ts/runtime"; +import { isJsonObject } from "@protobuf-ts/runtime"; +import { typeofJsonValue } from "@protobuf-ts/runtime"; +import type { JsonValue } from "@protobuf-ts/runtime"; +import { jsonWriteOptions } from "@protobuf-ts/runtime"; +import type { JsonReadOptions } from "@protobuf-ts/runtime"; +import type { JsonWriteOptions } from "@protobuf-ts/runtime"; +import type { BinaryReadOptions } from "@protobuf-ts/runtime"; +import type { IMessageType } from "@protobuf-ts/runtime"; +import { MessageType } from "@protobuf-ts/runtime"; +/** + * `Any` contains an arbitrary serialized protocol buffer message along with a + * URL that describes the type of the serialized message. + * + * Protobuf library provides support to pack/unpack Any values in the form + * of utility functions or additional generated methods of the Any type. + * + * Example 1: Pack and unpack a message in C++. + * + * Foo foo = ...; + * Any any; + * any.PackFrom(foo); + * ... + * if (any.UnpackTo(&foo)) { + * ... + * } + * + * Example 2: Pack and unpack a message in Java. + * + * Foo foo = ...; + * Any any = Any.pack(foo); + * ... + * if (any.is(Foo.class)) { + * foo = any.unpack(Foo.class); + * } + * + * Example 3: Pack and unpack a message in Python. + * + * foo = Foo(...) + * any = Any() + * any.Pack(foo) + * ... + * if any.Is(Foo.DESCRIPTOR): + * any.Unpack(foo) + * ... + * + * Example 4: Pack and unpack a message in Go + * + * foo := &pb.Foo{...} + * any, err := anypb.New(foo) + * if err != nil { + * ... + * } + * ... + * foo := &pb.Foo{} + * if err := any.UnmarshalTo(foo); err != nil { + * ... + * } + * + * The pack methods provided by protobuf library will by default use + * 'type.googleapis.com/full.type.name' as the type URL and the unpack + * methods only use the fully qualified type name after the last '/' + * in the type URL, for example "foo.bar.com/x/y.z" will yield type + * name "y.z". + * + * + * JSON + * + * The JSON representation of an `Any` value uses the regular + * representation of the deserialized, embedded message, with an + * additional field `@type` which contains the type URL. Example: + * + * package google.profile; + * message Person { + * string first_name = 1; + * string last_name = 2; + * } + * + * { + * "@type": "type.googleapis.com/google.profile.Person", + * "firstName": , + * "lastName": + * } + * + * If the embedded message type is well-known and has a custom JSON + * representation, that representation will be embedded adding a field + * `value` which holds the custom JSON in addition to the `@type` + * field. Example (for message [google.protobuf.Duration][]): + * + * { + * "@type": "type.googleapis.com/google.protobuf.Duration", + * "value": "1.212s" + * } + * + * + * @generated from protobuf message google.protobuf.Any + */ +export interface Any { + /** + * A URL/resource name that uniquely identifies the type of the serialized + * protocol buffer message. This string must contain at least + * one "/" character. The last segment of the URL's path must represent + * the fully qualified name of the type (as in + * `path/google.protobuf.Duration`). The name should be in a canonical form + * (e.g., leading "." is not accepted). + * + * In practice, teams usually precompile into the binary all types that they + * expect it to use in the context of Any. However, for URLs which use the + * scheme `http`, `https`, or no scheme, one can optionally set up a type + * server that maps type URLs to message definitions as follows: + * + * * If no scheme is provided, `https` is assumed. + * * An HTTP GET on the URL must yield a [google.protobuf.Type][] + * value in binary format, or produce an error. + * * Applications are allowed to cache lookup results based on the + * URL, or have them precompiled into a binary to avoid any + * lookup. Therefore, binary compatibility needs to be preserved + * on changes to types. (Use versioned type names to manage + * breaking changes.) + * + * Note: this functionality is not currently available in the official + * protobuf release, and it is not used for type URLs beginning with + * type.googleapis.com. + * + * Schemes other than `http`, `https` (or the empty scheme) might be + * used with implementation specific semantics. + * + * + * @generated from protobuf field: string type_url = 1; + */ + typeUrl: string; + /** + * Must be a valid serialized protocol buffer of the above specified type. + * + * @generated from protobuf field: bytes value = 2; + */ + value: Uint8Array; +} +// @generated message type with reflection information, may provide speed optimized methods +class Any$Type extends MessageType { + constructor() { + super("google.protobuf.Any", [ + { no: 1, name: "type_url", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, + { no: 2, name: "value", kind: "scalar", T: 12 /*ScalarType.BYTES*/ } + ]); + } + /** + * Pack the message into a new `Any`. + * + * Uses 'type.googleapis.com/full.type.name' as the type URL. + */ + pack(message: T, type: IMessageType): Any { + return { + typeUrl: this.typeNameToUrl(type.typeName), value: type.toBinary(message), + }; + } + /** + * Unpack the message from the `Any`. + */ + unpack(any: Any, type: IMessageType, options?: Partial): T { + if (!this.contains(any, type)) + throw new Error("Cannot unpack google.protobuf.Any with typeUrl '" + any.typeUrl + "' as " + type.typeName + "."); + return type.fromBinary(any.value, options); + } + /** + * Does the given `Any` contain a packed message of the given type? + */ + contains(any: Any, type: IMessageType | string): boolean { + if (!any.typeUrl.length) + return false; + let wants = typeof type == "string" ? type : type.typeName; + let has = this.typeUrlToName(any.typeUrl); + return wants === has; + } + /** + * Convert the message to canonical JSON value. + * + * You have to provide the `typeRegistry` option so that the + * packed message can be converted to JSON. + * + * The `typeRegistry` option is also required to read + * `google.protobuf.Any` from JSON format. + */ + internalJsonWrite(any: Any, options: JsonWriteOptions): JsonValue { + if (any.typeUrl === "") + return {}; + let typeName = this.typeUrlToName(any.typeUrl); + let opt = jsonWriteOptions(options); + let type = opt.typeRegistry?.find(t => t.typeName === typeName); + if (!type) + throw new globalThis.Error("Unable to convert google.protobuf.Any with typeUrl '" + any.typeUrl + "' to JSON. The specified type " + typeName + " is not available in the type registry."); + let value = type.fromBinary(any.value, { readUnknownField: false }); + let json = type.internalJsonWrite(value, opt); + if (typeName.startsWith("google.protobuf.") || !isJsonObject(json)) + json = { value: json }; + json["@type"] = any.typeUrl; + return json; + } + internalJsonRead(json: JsonValue, options: JsonReadOptions, target?: Any): Any { + if (!isJsonObject(json)) + throw new globalThis.Error("Unable to parse google.protobuf.Any from JSON " + typeofJsonValue(json) + "."); + if (typeof json["@type"] != "string" || json["@type"] == "") + return this.create(); + let typeName = this.typeUrlToName(json["@type"]); + let type = options?.typeRegistry?.find(t => t.typeName == typeName); + if (!type) + throw new globalThis.Error("Unable to parse google.protobuf.Any from JSON. The specified type " + typeName + " is not available in the type registry."); + let value; + if (typeName.startsWith("google.protobuf.") && json.hasOwnProperty("value")) + value = type.fromJson(json["value"], options); + else { + let copy = Object.assign({}, json); + delete copy["@type"]; + value = type.fromJson(copy, options); + } + if (target === undefined) + target = this.create(); + target.typeUrl = json["@type"]; + target.value = type.toBinary(value); + return target; + } + typeNameToUrl(name: string): string { + if (!name.length) + throw new Error("invalid type name: " + name); + return "type.googleapis.com/" + name; + } + typeUrlToName(url: string): string { + if (!url.length) + throw new Error("invalid type url: " + url); + let slash = url.lastIndexOf("/"); + let name = slash > 0 ? url.substring(slash + 1) : url; + if (!name.length) + throw new Error("invalid type url: " + url); + return name; + } + create(value?: PartialMessage): Any { + const message = globalThis.Object.create((this.messagePrototype!)); + message.typeUrl = ""; + message.value = new Uint8Array(0); + if (value !== undefined) + reflectionMergePartial(this, message, value); + return message; + } + internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: Any): Any { + let message = target ?? this.create(), end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case /* string type_url */ 1: + message.typeUrl = reader.string(); + break; + case /* bytes value */ 2: + message.value = reader.bytes(); + break; + default: + let u = options.readUnknownField; + if (u === "throw") + throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) + (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d); + } + } + return message; + } + internalBinaryWrite(message: Any, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { + /* string type_url = 1; */ + if (message.typeUrl !== "") + writer.tag(1, WireType.LengthDelimited).string(message.typeUrl); + /* bytes value = 2; */ + if (message.value.length) + writer.tag(2, WireType.LengthDelimited).bytes(message.value); + let u = options.writeUnknownFields; + if (u !== false) + (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer; + } +} +/** + * @generated MessageType for protobuf message google.protobuf.Any + */ +export const Any = new Any$Type(); diff --git a/gen/ts/perms.ts b/gen/ts/perms.ts index 227469cb6..73352ec66 100644 --- a/gen/ts/perms.ts +++ b/gen/ts/perms.ts @@ -8,6 +8,7 @@ // source: resources/centrum/settings.proto // source: resources/centrum/units.proto // source: resources/common/i18n.proto +// source: resources/common/uuid.proto // source: resources/common/cron/cron.proto // source: resources/common/database/database.proto // source: resources/common/grpcws/grpcws.proto diff --git a/gen/ts/resources/common/cron/cron.ts b/gen/ts/resources/common/cron/cron.ts index c78f16bcc..40559fd96 100644 --- a/gen/ts/resources/common/cron/cron.ts +++ b/gen/ts/resources/common/cron/cron.ts @@ -3,32 +3,141 @@ // @ts-nocheck import type { BinaryWriteOptions } from "@protobuf-ts/runtime"; import type { IBinaryWriter } from "@protobuf-ts/runtime"; -import { UnknownFieldHandler } from "@protobuf-ts/runtime"; +import { WireType } from "@protobuf-ts/runtime"; import type { BinaryReadOptions } from "@protobuf-ts/runtime"; import type { IBinaryReader } from "@protobuf-ts/runtime"; +import { UnknownFieldHandler } from "@protobuf-ts/runtime"; import type { PartialMessage } from "@protobuf-ts/runtime"; import { reflectionMergePartial } from "@protobuf-ts/runtime"; import { MessageType } from "@protobuf-ts/runtime"; +import { Any } from "../../../google/protobuf/any"; +import { Timestamp } from "../../timestamp/timestamp"; /** * @generated from protobuf message resources.common.cron.Cronjob */ export interface Cronjob { + /** + * @generated from protobuf field: string name = 1; + */ + name: string; + /** + * @generated from protobuf field: string schedule = 2; + */ + schedule: string; + /** + * @generated from protobuf field: resources.common.cron.CronjobState state = 3; + */ + state: CronjobState; + /** + * @generated from protobuf field: resources.timestamp.Timestamp next_schedule_time = 4; + */ + nextScheduleTime?: Timestamp; + /** + * @generated from protobuf field: resources.timestamp.Timestamp last_attempt_time = 5; + */ + lastAttemptTime?: Timestamp; +} +/** + * @generated from protobuf message resources.common.cron.CronjobData + */ +export interface CronjobData { + /** + * @generated from protobuf field: resources.timestamp.Timestamp updated_at = 1; + */ + updatedAt?: Timestamp; + /** + * @generated from protobuf field: optional google.protobuf.Any data = 2; + */ + data?: Any; +} +/** + * @generated from protobuf enum resources.common.cron.CronjobState + */ +export enum CronjobState { + /** + * @generated from protobuf enum value: CRONJOB_STATE_UNSPECIFIED = 0; + */ + UNSPECIFIED = 0, + /** + * @generated from protobuf enum value: CRONJOB_STATE_WAITING = 1; + */ + WAITING = 1, + /** + * @generated from protobuf enum value: CRONJOB_STATE_PENDING = 2; + */ + PENDING = 2, + /** + * @generated from protobuf enum value: CRONJOB_STATE_RUNNING = 3; + */ + RUNNING = 3 } // @generated message type with reflection information, may provide speed optimized methods class Cronjob$Type extends MessageType { constructor() { - super("resources.common.cron.Cronjob", []); + super("resources.common.cron.Cronjob", [ + { no: 1, name: "name", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, + { no: 2, name: "schedule", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, + { no: 3, name: "state", kind: "enum", T: () => ["resources.common.cron.CronjobState", CronjobState, "CRONJOB_STATE_"] }, + { no: 4, name: "next_schedule_time", kind: "message", T: () => Timestamp }, + { no: 5, name: "last_attempt_time", kind: "message", T: () => Timestamp } + ]); } create(value?: PartialMessage): Cronjob { const message = globalThis.Object.create((this.messagePrototype!)); + message.name = ""; + message.schedule = ""; + message.state = 0; if (value !== undefined) reflectionMergePartial(this, message, value); return message; } internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: Cronjob): Cronjob { - return target ?? this.create(); + let message = target ?? this.create(), end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case /* string name */ 1: + message.name = reader.string(); + break; + case /* string schedule */ 2: + message.schedule = reader.string(); + break; + case /* resources.common.cron.CronjobState state */ 3: + message.state = reader.int32(); + break; + case /* resources.timestamp.Timestamp next_schedule_time */ 4: + message.nextScheduleTime = Timestamp.internalBinaryRead(reader, reader.uint32(), options, message.nextScheduleTime); + break; + case /* resources.timestamp.Timestamp last_attempt_time */ 5: + message.lastAttemptTime = Timestamp.internalBinaryRead(reader, reader.uint32(), options, message.lastAttemptTime); + break; + default: + let u = options.readUnknownField; + if (u === "throw") + throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) + (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d); + } + } + return message; } internalBinaryWrite(message: Cronjob, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { + /* string name = 1; */ + if (message.name !== "") + writer.tag(1, WireType.LengthDelimited).string(message.name); + /* string schedule = 2; */ + if (message.schedule !== "") + writer.tag(2, WireType.LengthDelimited).string(message.schedule); + /* resources.common.cron.CronjobState state = 3; */ + if (message.state !== 0) + writer.tag(3, WireType.Varint).int32(message.state); + /* resources.timestamp.Timestamp next_schedule_time = 4; */ + if (message.nextScheduleTime) + Timestamp.internalBinaryWrite(message.nextScheduleTime, writer.tag(4, WireType.LengthDelimited).fork(), options).join(); + /* resources.timestamp.Timestamp last_attempt_time = 5; */ + if (message.lastAttemptTime) + Timestamp.internalBinaryWrite(message.lastAttemptTime, writer.tag(5, WireType.LengthDelimited).fork(), options).join(); let u = options.writeUnknownFields; if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); @@ -39,3 +148,56 @@ class Cronjob$Type extends MessageType { * @generated MessageType for protobuf message resources.common.cron.Cronjob */ export const Cronjob = new Cronjob$Type(); +// @generated message type with reflection information, may provide speed optimized methods +class CronjobData$Type extends MessageType { + constructor() { + super("resources.common.cron.CronjobData", [ + { no: 1, name: "updated_at", kind: "message", T: () => Timestamp }, + { no: 2, name: "data", kind: "message", T: () => Any } + ]); + } + create(value?: PartialMessage): CronjobData { + const message = globalThis.Object.create((this.messagePrototype!)); + if (value !== undefined) + reflectionMergePartial(this, message, value); + return message; + } + internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: CronjobData): CronjobData { + let message = target ?? this.create(), end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case /* resources.timestamp.Timestamp updated_at */ 1: + message.updatedAt = Timestamp.internalBinaryRead(reader, reader.uint32(), options, message.updatedAt); + break; + case /* optional google.protobuf.Any data */ 2: + message.data = Any.internalBinaryRead(reader, reader.uint32(), options, message.data); + break; + default: + let u = options.readUnknownField; + if (u === "throw") + throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) + (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d); + } + } + return message; + } + internalBinaryWrite(message: CronjobData, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { + /* resources.timestamp.Timestamp updated_at = 1; */ + if (message.updatedAt) + Timestamp.internalBinaryWrite(message.updatedAt, writer.tag(1, WireType.LengthDelimited).fork(), options).join(); + /* optional google.protobuf.Any data = 2; */ + if (message.data) + Any.internalBinaryWrite(message.data, writer.tag(2, WireType.LengthDelimited).fork(), options).join(); + let u = options.writeUnknownFields; + if (u !== false) + (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer; + } +} +/** + * @generated MessageType for protobuf message resources.common.cron.CronjobData + */ +export const CronjobData = new CronjobData$Type(); diff --git a/gen/ts/resources/common/uuid.ts b/gen/ts/resources/common/uuid.ts new file mode 100644 index 000000000..8b887ead9 --- /dev/null +++ b/gen/ts/resources/common/uuid.ts @@ -0,0 +1,68 @@ +// @generated by protobuf-ts 2.9.4 with parameter optimize_speed,long_type_number,force_server_none +// @generated from protobuf file "resources/common/uuid.proto" (package "resources.common", syntax proto3) +// @ts-nocheck +import type { BinaryWriteOptions } from "@protobuf-ts/runtime"; +import type { IBinaryWriter } from "@protobuf-ts/runtime"; +import { WireType } from "@protobuf-ts/runtime"; +import type { BinaryReadOptions } from "@protobuf-ts/runtime"; +import type { IBinaryReader } from "@protobuf-ts/runtime"; +import { UnknownFieldHandler } from "@protobuf-ts/runtime"; +import type { PartialMessage } from "@protobuf-ts/runtime"; +import { reflectionMergePartial } from "@protobuf-ts/runtime"; +import { MessageType } from "@protobuf-ts/runtime"; +/** + * @generated from protobuf message resources.common.UUID + */ +export interface UUID { + /** + * @generated from protobuf field: string uuid = 1; + */ + uuid: string; +} +// @generated message type with reflection information, may provide speed optimized methods +class UUID$Type extends MessageType { + constructor() { + super("resources.common.UUID", [ + { no: 1, name: "uuid", kind: "scalar", T: 9 /*ScalarType.STRING*/, options: { "validate.rules": { string: { uuid: true } } } } + ]); + } + create(value?: PartialMessage): UUID { + const message = globalThis.Object.create((this.messagePrototype!)); + message.uuid = ""; + if (value !== undefined) + reflectionMergePartial(this, message, value); + return message; + } + internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: UUID): UUID { + let message = target ?? this.create(), end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case /* string uuid */ 1: + message.uuid = reader.string(); + break; + default: + let u = options.readUnknownField; + if (u === "throw") + throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) + (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d); + } + } + return message; + } + internalBinaryWrite(message: UUID, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { + /* string uuid = 1; */ + if (message.uuid !== "") + writer.tag(1, WireType.LengthDelimited).string(message.uuid); + let u = options.writeUnknownFields; + if (u !== false) + (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer; + } +} +/** + * @generated MessageType for protobuf message resources.common.UUID + */ +export const UUID = new UUID$Type(); diff --git a/go.mod b/go.mod index b4d4be4ab..1b80faba1 100644 --- a/go.mod +++ b/go.mod @@ -25,6 +25,7 @@ require ( github.com/golang-jwt/jwt/v5 v5.2.1 github.com/golang-migrate/migrate/v4 v4.18.1 github.com/golang/protobuf v1.5.4 + github.com/google/uuid v1.6.0 github.com/gosimple/slug v1.14.0 github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus v1.0.1 github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.1.0 @@ -131,7 +132,6 @@ require ( github.com/golang/snappy v0.0.4 // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect - github.com/google/uuid v1.6.0 // indirect github.com/gorilla/context v1.1.2 // indirect github.com/gorilla/css v1.0.1 // indirect github.com/gorilla/schema v1.4.1 // indirect diff --git a/proto/resources/common/cron/cron.proto b/proto/resources/common/cron/cron.proto index 0051a05b5..6eb404447 100644 --- a/proto/resources/common/cron/cron.proto +++ b/proto/resources/common/cron/cron.proto @@ -2,6 +2,28 @@ syntax = "proto3"; package resources.common.cron; +import "google/protobuf/any.proto"; +import "resources/timestamp/timestamp.proto"; + option go_package = "github.com/fivenet-app/fivenet/gen/go/proto/resources/common/cron;cron"; -message Cronjob {} +message Cronjob { + string name = 1; + string schedule = 2; + CronjobState state = 3; + + resources.timestamp.Timestamp next_schedule_time = 4; + resources.timestamp.Timestamp last_attempt_time = 5; +} + +enum CronjobState { + CRONJOB_STATE_UNSPECIFIED = 0; + CRONJOB_STATE_WAITING = 1; + CRONJOB_STATE_PENDING = 2; + CRONJOB_STATE_RUNNING = 3; +} + +message CronjobData { + resources.timestamp.Timestamp updated_at = 1; + optional google.protobuf.Any data = 2; +} diff --git a/proto/resources/common/uuid.proto b/proto/resources/common/uuid.proto new file mode 100644 index 000000000..43aad3a2c --- /dev/null +++ b/proto/resources/common/uuid.proto @@ -0,0 +1,11 @@ +syntax = "proto3"; + +package resources.common; + +import "validate/validate.proto"; + +option go_package = "github.com/fivenet-app/fivenet/gen/go/proto/resources/common;common"; + +message UUID { + string uuid = 1 [(validate.rules).string.uuid = true]; +}