diff --git a/api/buf.lock b/api/buf.lock index 693f572..851707c 100644 --- a/api/buf.lock +++ b/api/buf.lock @@ -9,8 +9,8 @@ deps: - remote: buf.build owner: googleapis repository: googleapis - commit: 751cbe31638d43a9bfb6162cd2352e67 - digest: shake256:87f55470d9d124e2d1dedfe0231221f4ed7efbc55bc5268917c678e2d9b9c41573a7f9a557f6d8539044524d9fc5ca8fbb7db05eb81379d168285d76b57eb8a4 + commit: 61b203b9a9164be9a834f58c37be6f62 + digest: shake256:e619113001d6e284ee8a92b1561e5d4ea89a47b28bf0410815cb2fa23914df8be9f1a6a98dcf069f5bc2d829a2cfb1ac614863be45cd4f8a5ad8606c5f200224 - remote: buf.build owner: srikrsna repository: protoc-gen-gotag diff --git a/api/core/registry/key_value/v1/data_definition_lang.pb.go b/api/core/registry/key_value/v1/data_definition_lang.pb.go new file mode 100644 index 0000000..23eca0d --- /dev/null +++ b/api/core/registry/key_value/v1/data_definition_lang.pb.go @@ -0,0 +1,454 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.34.2 +// protoc (unknown) +// source: core/registry/key_value/v1/data_definition_lang.proto + +package v1 + +import ( + _ "github.com/envoyproxy/protoc-gen-validate/validate" + 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" +) + +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 Operation int32 + +const ( + // No operation is specified, this is the default value. + Operation_NONE Operation = 0 + // Select is a query that can be used to search for specific objects in `blueprint`. + // A kind is supplied to the query and it can be used to return all objects of that kind. + // A singular `Where` clause is used to filter the results. + Operation_SELECT Operation = 1 // `select * from `kind` where id = "123"` + Operation_DELETE Operation = 2 // `delete from `kind` where id = "123"` + Operation_UPDATE Operation = 3 // `update `kind` set name = "new name" where id = "123"` + Operation_INSERT Operation = 4 // `insert into `kind` (name, description) values ("new name", "new description")` +) + +// Enum value maps for Operation. +var ( + Operation_name = map[int32]string{ + 0: "NONE", + 1: "SELECT", + 2: "DELETE", + 3: "UPDATE", + 4: "INSERT", + } + Operation_value = map[string]int32{ + "NONE": 0, + "SELECT": 1, + "DELETE": 2, + "UPDATE": 3, + "INSERT": 4, + } +) + +func (x Operation) Enum() *Operation { + p := new(Operation) + *p = x + return p +} + +func (x Operation) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Operation) Descriptor() protoreflect.EnumDescriptor { + return file_core_registry_key_value_v1_data_definition_lang_proto_enumTypes[0].Descriptor() +} + +func (Operation) Type() protoreflect.EnumType { + return &file_core_registry_key_value_v1_data_definition_lang_proto_enumTypes[0] +} + +func (x Operation) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use Operation.Descriptor instead. +func (Operation) EnumDescriptor() ([]byte, []int) { + return file_core_registry_key_value_v1_data_definition_lang_proto_rawDescGZIP(), []int{0} +} + +// Standard ID to be used in the whole system +type ID struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // generated system uuid + Uuid string `protobuf:"bytes,1,opt,name=uuid,proto3" json:"uuid" bun:"uuid" csv:"uuid" pg:"uuid" yaml:"uuid"` +} + +func (x *ID) Reset() { + *x = ID{} + if protoimpl.UnsafeEnabled { + mi := &file_core_registry_key_value_v1_data_definition_lang_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ID) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ID) ProtoMessage() {} + +func (x *ID) ProtoReflect() protoreflect.Message { + mi := &file_core_registry_key_value_v1_data_definition_lang_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 ID.ProtoReflect.Descriptor instead. +func (*ID) Descriptor() ([]byte, []int) { + return file_core_registry_key_value_v1_data_definition_lang_proto_rawDescGZIP(), []int{0} +} + +func (x *ID) GetUuid() string { + if x != nil { + return x.Uuid + } + return "" +} + +// Statement is the root node of the query. It's the entry point to the query system. +type Statement struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // select * from `kind` + Kind *anypb.Any `protobuf:"bytes,1,opt,name=kind,proto3" json:"kind" bun:"kind" csv:"kind" pg:"kind" yaml:"kind"` + // The operation to perform on the `kind` object + Operation Operation `protobuf:"varint,2,opt,name=operation,proto3,enum=core.registry.key_value.v1.Operation" json:"operation" bun:"operation" csv:"operation" pg:"operation" yaml:"operation"` + // The `where` clause is used to filter the results of the query. + // + // Types that are assignable to Where: + // + // *Statement_IsAll + // *Statement_Id + // *Statement_KeyVal + Where isStatement_Where `protobuf_oneof:"where"` +} + +func (x *Statement) Reset() { + *x = Statement{} + if protoimpl.UnsafeEnabled { + mi := &file_core_registry_key_value_v1_data_definition_lang_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Statement) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Statement) ProtoMessage() {} + +func (x *Statement) ProtoReflect() protoreflect.Message { + mi := &file_core_registry_key_value_v1_data_definition_lang_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 Statement.ProtoReflect.Descriptor instead. +func (*Statement) Descriptor() ([]byte, []int) { + return file_core_registry_key_value_v1_data_definition_lang_proto_rawDescGZIP(), []int{1} +} + +func (x *Statement) GetKind() *anypb.Any { + if x != nil { + return x.Kind + } + return nil +} + +func (x *Statement) GetOperation() Operation { + if x != nil { + return x.Operation + } + return Operation_NONE +} + +func (m *Statement) GetWhere() isStatement_Where { + if m != nil { + return m.Where + } + return nil +} + +func (x *Statement) GetIsAll() bool { + if x, ok := x.GetWhere().(*Statement_IsAll); ok { + return x.IsAll + } + return false +} + +func (x *Statement) GetId() *ID { + if x, ok := x.GetWhere().(*Statement_Id); ok { + return x.Id + } + return nil +} + +func (x *Statement) GetKeyVal() *Equal { + if x, ok := x.GetWhere().(*Statement_KeyVal); ok { + return x.KeyVal + } + return nil +} + +type isStatement_Where interface { + isStatement_Where() +} + +type Statement_IsAll struct { + // return all `kinds` - `select * from `courses` + IsAll bool `protobuf:"varint,3,opt,name=is_all,json=isAll,proto3,oneof" bun:"is_all" csv:"is_all" json:"is_all" pg:"is_all" yaml:"is_all"` +} + +type Statement_Id struct { + // return a `kind` that matches the `ID` - `select * from courses where id = "123" + Id *ID `protobuf:"bytes,4,opt,name=id,proto3,oneof" bun:"id" csv:"id" json:"id" pg:"id" yaml:"id"` +} + +type Statement_KeyVal struct { + // return all `kind`'s that equal the key/value pairs fields + // `select * from courses where name = "Payne Stewart"` + KeyVal *Equal `protobuf:"bytes,5,opt,name=key_val,json=keyVal,proto3,oneof" bun:"key_val" csv:"key_val" json:"key_val" pg:"key_val" yaml:"key_val"` +} + +func (*Statement_IsAll) isStatement_Where() {} + +func (*Statement_Id) isStatement_Where() {} + +func (*Statement_KeyVal) isStatement_Where() {} + +type Equal struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // of the `Kind` being queried return the values that match the key/value pairs below + Match map[string]string `protobuf:"bytes,1,rep,name=match,proto3" json:"match" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3" bun:"match" csv:"match" pg:"match" yaml:"match"` +} + +func (x *Equal) Reset() { + *x = Equal{} + if protoimpl.UnsafeEnabled { + mi := &file_core_registry_key_value_v1_data_definition_lang_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Equal) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Equal) ProtoMessage() {} + +func (x *Equal) ProtoReflect() protoreflect.Message { + mi := &file_core_registry_key_value_v1_data_definition_lang_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 Equal.ProtoReflect.Descriptor instead. +func (*Equal) Descriptor() ([]byte, []int) { + return file_core_registry_key_value_v1_data_definition_lang_proto_rawDescGZIP(), []int{2} +} + +func (x *Equal) GetMatch() map[string]string { + if x != nil { + return x.Match + } + return nil +} + +var File_core_registry_key_value_v1_data_definition_lang_proto protoreflect.FileDescriptor + +var file_core_registry_key_value_v1_data_definition_lang_proto_rawDesc = []byte{ + 0x0a, 0x35, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2f, + 0x6b, 0x65, 0x79, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x64, 0x61, 0x74, + 0x61, 0x5f, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6c, 0x61, 0x6e, + 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1a, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x72, 0x65, + 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x6b, 0x65, 0x79, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x2e, 0x76, 0x31, 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, 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, 0x22, 0x0a, 0x02, 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, 0x22, 0x8c, 0x02, 0x0a, 0x09, + 0x53, 0x74, 0x61, 0x74, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x28, 0x0a, 0x04, 0x6b, 0x69, 0x6e, + 0x64, 0x18, 0x01, 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, 0x52, 0x04, 0x6b, + 0x69, 0x6e, 0x64, 0x12, 0x43, 0x0a, 0x09, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x25, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x72, 0x65, + 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x6b, 0x65, 0x79, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x09, 0x6f, + 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x17, 0x0a, 0x06, 0x69, 0x73, 0x5f, 0x61, + 0x6c, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x05, 0x69, 0x73, 0x41, 0x6c, + 0x6c, 0x12, 0x30, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, + 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x6b, 0x65, + 0x79, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x44, 0x48, 0x00, 0x52, + 0x02, 0x69, 0x64, 0x12, 0x3c, 0x0a, 0x07, 0x6b, 0x65, 0x79, 0x5f, 0x76, 0x61, 0x6c, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x72, 0x65, 0x67, 0x69, + 0x73, 0x74, 0x72, 0x79, 0x2e, 0x6b, 0x65, 0x79, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x2e, 0x76, + 0x31, 0x2e, 0x45, 0x71, 0x75, 0x61, 0x6c, 0x48, 0x00, 0x52, 0x06, 0x6b, 0x65, 0x79, 0x56, 0x61, + 0x6c, 0x42, 0x07, 0x0a, 0x05, 0x77, 0x68, 0x65, 0x72, 0x65, 0x22, 0x85, 0x01, 0x0a, 0x05, 0x45, + 0x71, 0x75, 0x61, 0x6c, 0x12, 0x42, 0x0a, 0x05, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x18, 0x01, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x72, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x72, 0x79, 0x2e, 0x6b, 0x65, 0x79, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x2e, 0x76, 0x31, + 0x2e, 0x45, 0x71, 0x75, 0x61, 0x6c, 0x2e, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x45, 0x6e, 0x74, 0x72, + 0x79, 0x52, 0x05, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x1a, 0x38, 0x0a, 0x0a, 0x4d, 0x61, 0x74, 0x63, + 0x68, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, + 0x38, 0x01, 0x2a, 0x45, 0x0a, 0x09, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, + 0x08, 0x0a, 0x04, 0x4e, 0x4f, 0x4e, 0x45, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x53, 0x45, 0x4c, + 0x45, 0x43, 0x54, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x44, 0x45, 0x4c, 0x45, 0x54, 0x45, 0x10, + 0x02, 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x10, 0x03, 0x12, 0x0a, 0x0a, + 0x06, 0x49, 0x4e, 0x53, 0x45, 0x52, 0x54, 0x10, 0x04, 0x42, 0x3e, 0x5a, 0x3c, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x74, 0x65, 0x61, 0x64, 0x79, 0x2d, 0x62, + 0x79, 0x74, 0x65, 0x73, 0x2f, 0x64, 0x72, 0x61, 0x66, 0x74, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, + 0x6f, 0x72, 0x65, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2f, 0x6b, 0x65, 0x79, + 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x2f, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, +} + +var ( + file_core_registry_key_value_v1_data_definition_lang_proto_rawDescOnce sync.Once + file_core_registry_key_value_v1_data_definition_lang_proto_rawDescData = file_core_registry_key_value_v1_data_definition_lang_proto_rawDesc +) + +func file_core_registry_key_value_v1_data_definition_lang_proto_rawDescGZIP() []byte { + file_core_registry_key_value_v1_data_definition_lang_proto_rawDescOnce.Do(func() { + file_core_registry_key_value_v1_data_definition_lang_proto_rawDescData = protoimpl.X.CompressGZIP(file_core_registry_key_value_v1_data_definition_lang_proto_rawDescData) + }) + return file_core_registry_key_value_v1_data_definition_lang_proto_rawDescData +} + +var file_core_registry_key_value_v1_data_definition_lang_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_core_registry_key_value_v1_data_definition_lang_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_core_registry_key_value_v1_data_definition_lang_proto_goTypes = []any{ + (Operation)(0), // 0: core.registry.key_value.v1.Operation + (*ID)(nil), // 1: core.registry.key_value.v1.ID + (*Statement)(nil), // 2: core.registry.key_value.v1.Statement + (*Equal)(nil), // 3: core.registry.key_value.v1.Equal + nil, // 4: core.registry.key_value.v1.Equal.MatchEntry + (*anypb.Any)(nil), // 5: google.protobuf.Any +} +var file_core_registry_key_value_v1_data_definition_lang_proto_depIdxs = []int32{ + 5, // 0: core.registry.key_value.v1.Statement.kind:type_name -> google.protobuf.Any + 0, // 1: core.registry.key_value.v1.Statement.operation:type_name -> core.registry.key_value.v1.Operation + 1, // 2: core.registry.key_value.v1.Statement.id:type_name -> core.registry.key_value.v1.ID + 3, // 3: core.registry.key_value.v1.Statement.key_val:type_name -> core.registry.key_value.v1.Equal + 4, // 4: core.registry.key_value.v1.Equal.match:type_name -> core.registry.key_value.v1.Equal.MatchEntry + 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_core_registry_key_value_v1_data_definition_lang_proto_init() } +func file_core_registry_key_value_v1_data_definition_lang_proto_init() { + if File_core_registry_key_value_v1_data_definition_lang_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_core_registry_key_value_v1_data_definition_lang_proto_msgTypes[0].Exporter = func(v any, i int) any { + switch v := v.(*ID); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_core_registry_key_value_v1_data_definition_lang_proto_msgTypes[1].Exporter = func(v any, i int) any { + switch v := v.(*Statement); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_core_registry_key_value_v1_data_definition_lang_proto_msgTypes[2].Exporter = func(v any, i int) any { + switch v := v.(*Equal); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_core_registry_key_value_v1_data_definition_lang_proto_msgTypes[1].OneofWrappers = []any{ + (*Statement_IsAll)(nil), + (*Statement_Id)(nil), + (*Statement_KeyVal)(nil), + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_core_registry_key_value_v1_data_definition_lang_proto_rawDesc, + NumEnums: 1, + NumMessages: 4, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_core_registry_key_value_v1_data_definition_lang_proto_goTypes, + DependencyIndexes: file_core_registry_key_value_v1_data_definition_lang_proto_depIdxs, + EnumInfos: file_core_registry_key_value_v1_data_definition_lang_proto_enumTypes, + MessageInfos: file_core_registry_key_value_v1_data_definition_lang_proto_msgTypes, + }.Build() + File_core_registry_key_value_v1_data_definition_lang_proto = out.File + file_core_registry_key_value_v1_data_definition_lang_proto_rawDesc = nil + file_core_registry_key_value_v1_data_definition_lang_proto_goTypes = nil + file_core_registry_key_value_v1_data_definition_lang_proto_depIdxs = nil +} diff --git a/api/core/registry/key_value/v1/data_definition_lang.pb.validate.go b/api/core/registry/key_value/v1/data_definition_lang.pb.validate.go new file mode 100644 index 0000000..96df334 --- /dev/null +++ b/api/core/registry/key_value/v1/data_definition_lang.pb.validate.go @@ -0,0 +1,486 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: core/registry/key_value/v1/data_definition_lang.proto + +package v1 + +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 _data_definition_lang_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 ID 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 *ID) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ID 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 IDMultiError, or nil if none found. +func (m *ID) ValidateAll() error { + return m.validate(true) +} + +func (m *ID) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if err := m._validateUuid(m.GetUuid()); err != nil { + err = IDValidationError{ + field: "Uuid", + reason: "value must be a valid UUID", + cause: err, + } + if !all { + return err + } + errors = append(errors, err) + } + + if len(errors) > 0 { + return IDMultiError(errors) + } + + return nil +} + +func (m *ID) _validateUuid(uuid string) error { + if matched := _data_definition_lang_uuidPattern.MatchString(uuid); !matched { + return errors.New("invalid uuid format") + } + + return nil +} + +// IDMultiError is an error wrapping multiple validation errors returned by +// ID.ValidateAll() if the designated constraints aren't met. +type IDMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m IDMultiError) 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 IDMultiError) AllErrors() []error { return m } + +// IDValidationError is the validation error returned by ID.Validate if the +// designated constraints aren't met. +type IDValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e IDValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e IDValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e IDValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e IDValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e IDValidationError) ErrorName() string { return "IDValidationError" } + +// Error satisfies the builtin error interface +func (e IDValidationError) 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 %sID.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = IDValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = IDValidationError{} + +// Validate checks the field values on Statement 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 *Statement) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on Statement 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 StatementMultiError, or nil +// if none found. +func (m *Statement) ValidateAll() error { + return m.validate(true) +} + +func (m *Statement) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetKind()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, StatementValidationError{ + field: "Kind", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, StatementValidationError{ + field: "Kind", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetKind()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return StatementValidationError{ + field: "Kind", + reason: "embedded message failed validation", + cause: err, + } + } + } + + // no validation rules for Operation + + switch v := m.Where.(type) { + case *Statement_IsAll: + if v == nil { + err := StatementValidationError{ + field: "Where", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + // no validation rules for IsAll + case *Statement_Id: + if v == nil { + err := StatementValidationError{ + field: "Where", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetId()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, StatementValidationError{ + field: "Id", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, StatementValidationError{ + field: "Id", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetId()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return StatementValidationError{ + field: "Id", + reason: "embedded message failed validation", + cause: err, + } + } + } + + case *Statement_KeyVal: + if v == nil { + err := StatementValidationError{ + field: "Where", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetKeyVal()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, StatementValidationError{ + field: "KeyVal", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, StatementValidationError{ + field: "KeyVal", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetKeyVal()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return StatementValidationError{ + field: "KeyVal", + reason: "embedded message failed validation", + cause: err, + } + } + } + + default: + _ = v // ensures v is used + } + + if len(errors) > 0 { + return StatementMultiError(errors) + } + + return nil +} + +// StatementMultiError is an error wrapping multiple validation errors returned +// by Statement.ValidateAll() if the designated constraints aren't met. +type StatementMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m StatementMultiError) 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 StatementMultiError) AllErrors() []error { return m } + +// StatementValidationError is the validation error returned by +// Statement.Validate if the designated constraints aren't met. +type StatementValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e StatementValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e StatementValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e StatementValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e StatementValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e StatementValidationError) ErrorName() string { return "StatementValidationError" } + +// Error satisfies the builtin error interface +func (e StatementValidationError) 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 %sStatement.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = StatementValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = StatementValidationError{} + +// Validate checks the field values on Equal 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 *Equal) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on Equal 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 EqualMultiError, or nil if none found. +func (m *Equal) ValidateAll() error { + return m.validate(true) +} + +func (m *Equal) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Match + + if len(errors) > 0 { + return EqualMultiError(errors) + } + + return nil +} + +// EqualMultiError is an error wrapping multiple validation errors returned by +// Equal.ValidateAll() if the designated constraints aren't met. +type EqualMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m EqualMultiError) 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 EqualMultiError) AllErrors() []error { return m } + +// EqualValidationError is the validation error returned by Equal.Validate if +// the designated constraints aren't met. +type EqualValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e EqualValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e EqualValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e EqualValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e EqualValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e EqualValidationError) ErrorName() string { return "EqualValidationError" } + +// Error satisfies the builtin error interface +func (e EqualValidationError) 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 %sEqual.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = EqualValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = EqualValidationError{} diff --git a/api/core/registry/key_value/v1/data_definition_lang.proto b/api/core/registry/key_value/v1/data_definition_lang.proto new file mode 100644 index 0000000..a22b110 --- /dev/null +++ b/api/core/registry/key_value/v1/data_definition_lang.proto @@ -0,0 +1,49 @@ +syntax = "proto3"; + +package core.registry.key_value.v1; + +option go_package = "github.com/steady-bytes/draft/api/core/registry/key_value/v1"; + +import "google/protobuf/any.proto"; +import "validate/validate.proto"; + +// Standard ID to be used in the whole system +message ID { + // generated system uuid + string uuid = 1 [(validate.rules).string.uuid = true]; +} + +// Statement is the root node of the query. It's the entry point to the query system. +message Statement { + // select * from `kind` + google.protobuf.Any kind = 1; + // The operation to perform on the `kind` object + Operation operation = 2; + // The `where` clause is used to filter the results of the query. + oneof where { + // return all `kinds` - `select * from `courses` + bool is_all = 3; + // return a `kind` that matches the `ID` - `select * from courses where id = "123" + ID id = 4; + // return all `kind`'s that equal the key/value pairs fields + // `select * from courses where name = "Payne Stewart"` + Equal key_val = 5; + } +} + +enum Operation { + // No operation is specified, this is the default value. + NONE = 0; + // Select is a query that can be used to search for specific objects in `blueprint`. + // A kind is supplied to the query and it can be used to return all objects of that kind. + // A singular `Where` clause is used to filter the results. + SELECT = 1; // `select * from `kind` where id = "123"` + DELETE = 2; // `delete from `kind` where id = "123"` + UPDATE = 3; // `update `kind` set name = "new name" where id = "123"` + INSERT = 4; // `insert into `kind` (name, description) values ("new name", "new description")` +} + +message Equal { + // of the `Kind` being queried return the values that match the key/value pairs below + map match = 1; +} \ No newline at end of file diff --git a/api/go.mod b/api/go.mod index d85bfff..2ec9012 100644 --- a/api/go.mod +++ b/api/go.mod @@ -4,5 +4,6 @@ go 1.21.3 require ( connectrpc.com/connect v1.16.2 - google.golang.org/protobuf v1.34.2 + github.com/envoyproxy/protoc-gen-validate v1.2.1 + google.golang.org/protobuf v1.36.3 ) diff --git a/api/go.sum b/api/go.sum index 7755073..61aa701 100644 --- a/api/go.sum +++ b/api/go.sum @@ -1,10 +1,12 @@ connectrpc.com/connect v1.16.2 h1:ybd6y+ls7GOlb7Bh5C8+ghA6SvCBajHwxssO2CGFjqE= connectrpc.com/connect v1.16.2/go.mod h1:n2kgwskMHXC+lVqb18wngEpF95ldBHXjZYJussz5FRc= +github.com/envoyproxy/protoc-gen-validate v1.2.1 h1:DEo3O99U8j4hBFwbJfrz9VtgcDfUKS7KJ7spH3d86P8= +github.com/envoyproxy/protoc-gen-validate v1.2.1/go.mod h1:d/C80l/jxXLdfEIhX1W2TmLfsJ31lvEjwamM4DxlWXU= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= -golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= -google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= +golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0= +golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k= +golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= +google.golang.org/protobuf v1.36.3 h1:82DV7MYdb8anAVi3qge1wSnMDrnKK7ebr+I0hHRN1BU= +google.golang.org/protobuf v1.36.3/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=