From 119409966777a25c2d1f4b99b3dcdda674c09180 Mon Sep 17 00:00:00 2001 From: Steven Date: Wed, 9 Aug 2023 23:31:52 +0800 Subject: [PATCH] feat: add create shortcut api --- api/v2/shortcut_service.go | 52 ++++ .../proto/api/v2/shortcut_service_pb.d.ts | 48 ++++ .../types/proto/api/v2/shortcut_service_pb.js | 20 ++ .../src/types/proto/store/activity_pb.d.ts | 32 +++ .../src/types/proto/store/activity_pb.js | 17 ++ proto/api/v2/shortcut_service.proto | 16 ++ proto/api/v2/user_service.proto | 1 + proto/gen/api/v2/README.md | 37 ++- proto/gen/api/v2/shortcut_service.pb.go | 258 ++++++++++++++---- proto/gen/api/v2/shortcut_service.pb.gw.go | 85 ++++++ proto/gen/api/v2/shortcut_service_grpc.pb.go | 45 ++- proto/gen/api/v2/user_service_grpc.pb.go | 2 + proto/gen/store/README.md | 34 +++ proto/gen/store/activity.pb.go | 153 +++++++++++ proto/store/activity.proto | 9 + .../proto/api/v2/shortcut_service_pb.d.ts | 48 ++++ .../types/proto/api/v2/shortcut_service_pb.js | 20 ++ web/src/types/proto/store/activity_pb.d.ts | 32 +++ web/src/types/proto/store/activity_pb.js | 17 ++ 19 files changed, 864 insertions(+), 62 deletions(-) create mode 100644 extension/src/types/proto/store/activity_pb.d.ts create mode 100644 extension/src/types/proto/store/activity_pb.js create mode 100644 proto/gen/store/activity.pb.go create mode 100644 proto/store/activity.proto create mode 100644 web/src/types/proto/store/activity_pb.d.ts create mode 100644 web/src/types/proto/store/activity_pb.js diff --git a/api/v2/shortcut_service.go b/api/v2/shortcut_service.go index 0bf115c..60cd103 100644 --- a/api/v2/shortcut_service.go +++ b/api/v2/shortcut_service.go @@ -6,8 +6,10 @@ import ( apiv2pb "github.com/boojack/slash/proto/gen/api/v2" storepb "github.com/boojack/slash/proto/gen/store" "github.com/boojack/slash/store" + "github.com/pkg/errors" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + "google.golang.org/protobuf/encoding/protojson" ) type ShortcutService struct { @@ -75,6 +77,56 @@ func (s *ShortcutService) GetShortcut(ctx context.Context, request *apiv2pb.GetS return response, nil } +func (s *ShortcutService) CreateShortcut(ctx context.Context, request *apiv2pb.CreateShortcutRequest) (*apiv2pb.CreateShortcutResponse, error) { + userID := ctx.Value(UserIDContextKey).(int32) + shortcut, err := s.Store.CreateShortcut(ctx, &storepb.Shortcut{ + CreatorId: userID, + Name: request.Shortcut.Name, + Link: request.Shortcut.Link, + Title: request.Shortcut.Title, + Tags: request.Shortcut.Tags, + Description: request.Shortcut.Description, + Visibility: storepb.Visibility(request.Shortcut.Visibility), + OgMetadata: &storepb.OpenGraphMetadata{ + Title: request.Shortcut.OgMetadata.Title, + Description: request.Shortcut.OgMetadata.Description, + Image: request.Shortcut.OgMetadata.Image, + }, + }) + if err != nil { + return nil, status.Errorf(codes.Internal, "failed to create shortcut, err: %v", err) + } + if err := s.createShortcutCreateActivity(ctx, shortcut); err != nil { + return nil, status.Errorf(codes.Internal, "failed to create activity, err: %v", err) + } + + response := &apiv2pb.CreateShortcutResponse{ + Shortcut: convertShortcutFromStorepb(shortcut), + } + return response, nil +} + +func (s *ShortcutService) createShortcutCreateActivity(ctx context.Context, shortcut *storepb.Shortcut) error { + payload := &storepb.ActivityShorcutCreatePayload{ + ShortcutId: shortcut.Id, + } + payloadStr, err := protojson.Marshal(payload) + if err != nil { + return errors.Wrap(err, "Failed to marshal activity payload") + } + activity := &store.Activity{ + CreatorID: shortcut.CreatorId, + Type: store.ActivityShortcutCreate, + Level: store.ActivityInfo, + Payload: string(payloadStr), + } + _, err = s.Store.CreateActivity(ctx, activity) + if err != nil { + return errors.Wrap(err, "Failed to create activity") + } + return nil +} + func convertShortcutFromStorepb(shortcut *storepb.Shortcut) *apiv2pb.Shortcut { return &apiv2pb.Shortcut{ Id: shortcut.Id, diff --git a/extension/src/types/proto/api/v2/shortcut_service_pb.d.ts b/extension/src/types/proto/api/v2/shortcut_service_pb.d.ts index cf58f56..aebf175 100644 --- a/extension/src/types/proto/api/v2/shortcut_service_pb.d.ts +++ b/extension/src/types/proto/api/v2/shortcut_service_pb.d.ts @@ -236,3 +236,51 @@ export declare class GetShortcutResponse extends Message { static equals(a: GetShortcutResponse | PlainMessage | undefined, b: GetShortcutResponse | PlainMessage | undefined): boolean; } +/** + * @generated from message slash.api.v2.CreateShortcutRequest + */ +export declare class CreateShortcutRequest extends Message { + /** + * @generated from field: slash.api.v2.Shortcut shortcut = 1; + */ + shortcut?: Shortcut; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "slash.api.v2.CreateShortcutRequest"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): CreateShortcutRequest; + + static fromJson(jsonValue: JsonValue, options?: Partial): CreateShortcutRequest; + + static fromJsonString(jsonString: string, options?: Partial): CreateShortcutRequest; + + static equals(a: CreateShortcutRequest | PlainMessage | undefined, b: CreateShortcutRequest | PlainMessage | undefined): boolean; +} + +/** + * @generated from message slash.api.v2.CreateShortcutResponse + */ +export declare class CreateShortcutResponse extends Message { + /** + * @generated from field: slash.api.v2.Shortcut shortcut = 1; + */ + shortcut?: Shortcut; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "slash.api.v2.CreateShortcutResponse"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): CreateShortcutResponse; + + static fromJson(jsonValue: JsonValue, options?: Partial): CreateShortcutResponse; + + static fromJsonString(jsonString: string, options?: Partial): CreateShortcutResponse; + + static equals(a: CreateShortcutResponse | PlainMessage | undefined, b: CreateShortcutResponse | PlainMessage | undefined): boolean; +} + diff --git a/extension/src/types/proto/api/v2/shortcut_service_pb.js b/extension/src/types/proto/api/v2/shortcut_service_pb.js index 1043b7f..418e677 100644 --- a/extension/src/types/proto/api/v2/shortcut_service_pb.js +++ b/extension/src/types/proto/api/v2/shortcut_service_pb.js @@ -90,3 +90,23 @@ export const GetShortcutResponse = proto3.makeMessageType( ], ); +/** + * @generated from message slash.api.v2.CreateShortcutRequest + */ +export const CreateShortcutRequest = proto3.makeMessageType( + "slash.api.v2.CreateShortcutRequest", + () => [ + { no: 1, name: "shortcut", kind: "message", T: Shortcut }, + ], +); + +/** + * @generated from message slash.api.v2.CreateShortcutResponse + */ +export const CreateShortcutResponse = proto3.makeMessageType( + "slash.api.v2.CreateShortcutResponse", + () => [ + { no: 1, name: "shortcut", kind: "message", T: Shortcut }, + ], +); + diff --git a/extension/src/types/proto/store/activity_pb.d.ts b/extension/src/types/proto/store/activity_pb.d.ts new file mode 100644 index 0000000..a3c8c09 --- /dev/null +++ b/extension/src/types/proto/store/activity_pb.d.ts @@ -0,0 +1,32 @@ +// @generated by protoc-gen-es v1.3.0 +// @generated from file store/activity.proto (package slash.store, syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; +import { Message, proto3 } from "@bufbuild/protobuf"; + +/** + * @generated from message slash.store.ActivityShorcutCreatePayload + */ +export declare class ActivityShorcutCreatePayload extends Message { + /** + * @generated from field: int32 shortcut_id = 1; + */ + shortcutId: number; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "slash.store.ActivityShorcutCreatePayload"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): ActivityShorcutCreatePayload; + + static fromJson(jsonValue: JsonValue, options?: Partial): ActivityShorcutCreatePayload; + + static fromJsonString(jsonString: string, options?: Partial): ActivityShorcutCreatePayload; + + static equals(a: ActivityShorcutCreatePayload | PlainMessage | undefined, b: ActivityShorcutCreatePayload | PlainMessage | undefined): boolean; +} + diff --git a/extension/src/types/proto/store/activity_pb.js b/extension/src/types/proto/store/activity_pb.js new file mode 100644 index 0000000..4e4e768 --- /dev/null +++ b/extension/src/types/proto/store/activity_pb.js @@ -0,0 +1,17 @@ +// @generated by protoc-gen-es v1.3.0 +// @generated from file store/activity.proto (package slash.store, syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import { proto3 } from "@bufbuild/protobuf"; + +/** + * @generated from message slash.store.ActivityShorcutCreatePayload + */ +export const ActivityShorcutCreatePayload = proto3.makeMessageType( + "slash.store.ActivityShorcutCreatePayload", + () => [ + { no: 1, name: "shortcut_id", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, + ], +); + diff --git a/proto/api/v2/shortcut_service.proto b/proto/api/v2/shortcut_service.proto index 0192702..02540c2 100644 --- a/proto/api/v2/shortcut_service.proto +++ b/proto/api/v2/shortcut_service.proto @@ -9,6 +9,7 @@ import "google/api/client.proto"; option go_package = "gen/api/v2"; service ShortcutService { + // ListShortcuts returns a list of shortcuts. rpc ListShortcuts(ListShortcutsRequest) returns (ListShortcutsResponse) { option (google.api.http) = {get: "/api/v2/shortcuts"}; } @@ -17,6 +18,13 @@ service ShortcutService { option (google.api.http) = {get: "/api/v2/shortcuts/{name}"}; option (google.api.method_signature) = "name"; } + // CreateShortcut creates a shortcut. + rpc CreateShortcut(CreateShortcutRequest) returns (CreateShortcutResponse) { + option (google.api.http) = { + post: "/api/v2/shortcuts" + body: "shortcut" + }; + } } message Shortcut { @@ -76,3 +84,11 @@ message GetShortcutRequest { message GetShortcutResponse { Shortcut shortcut = 1; } + +message CreateShortcutRequest { + Shortcut shortcut = 1; +} + +message CreateShortcutResponse { + Shortcut shortcut = 1; +} diff --git a/proto/api/v2/user_service.proto b/proto/api/v2/user_service.proto index 8d69a21..f3f6554 100644 --- a/proto/api/v2/user_service.proto +++ b/proto/api/v2/user_service.proto @@ -15,6 +15,7 @@ service UserService { option (google.api.http) = {get: "/api/v2/users/{id}"}; option (google.api.method_signature) = "id"; } + // CreateUser creates a new user. rpc CreateUser(CreateUserRequest) returns (CreateUserResponse) { option (google.api.http) = { post: "/api/v2/users" diff --git a/proto/gen/api/v2/README.md b/proto/gen/api/v2/README.md index 182a58e..21c18e2 100644 --- a/proto/gen/api/v2/README.md +++ b/proto/gen/api/v2/README.md @@ -7,6 +7,8 @@ - [RowStatus](#slash-api-v2-RowStatus) - [api/v2/shortcut_service.proto](#api_v2_shortcut_service-proto) + - [CreateShortcutRequest](#slash-api-v2-CreateShortcutRequest) + - [CreateShortcutResponse](#slash-api-v2-CreateShortcutResponse) - [GetShortcutRequest](#slash-api-v2-GetShortcutRequest) - [GetShortcutResponse](#slash-api-v2-GetShortcutResponse) - [ListShortcutsRequest](#slash-api-v2-ListShortcutsRequest) @@ -76,6 +78,36 @@ + + +### CreateShortcutRequest + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| shortcut | [Shortcut](#slash-api-v2-Shortcut) | | | + + + + + + + + +### CreateShortcutResponse + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| shortcut | [Shortcut](#slash-api-v2-Shortcut) | | | + + + + + + ### GetShortcutRequest @@ -201,8 +233,9 @@ | Method Name | Request Type | Response Type | Description | | ----------- | ------------ | ------------- | ------------| -| ListShortcuts | [ListShortcutsRequest](#slash-api-v2-ListShortcutsRequest) | [ListShortcutsResponse](#slash-api-v2-ListShortcutsResponse) | | +| ListShortcuts | [ListShortcutsRequest](#slash-api-v2-ListShortcutsRequest) | [ListShortcutsResponse](#slash-api-v2-ListShortcutsResponse) | ListShortcuts returns a list of shortcuts. | | GetShortcut | [GetShortcutRequest](#slash-api-v2-GetShortcutRequest) | [GetShortcutResponse](#slash-api-v2-GetShortcutResponse) | GetShortcut returns a shortcut by name. | +| CreateShortcut | [CreateShortcutRequest](#slash-api-v2-CreateShortcutRequest) | [CreateShortcutResponse](#slash-api-v2-CreateShortcutResponse) | CreateShortcut creates a shortcut. | @@ -429,7 +462,7 @@ | Method Name | Request Type | Response Type | Description | | ----------- | ------------ | ------------- | ------------| | GetUser | [GetUserRequest](#slash-api-v2-GetUserRequest) | [GetUserResponse](#slash-api-v2-GetUserResponse) | GetUser returns a user by id. | -| CreateUser | [CreateUserRequest](#slash-api-v2-CreateUserRequest) | [CreateUserResponse](#slash-api-v2-CreateUserResponse) | | +| CreateUser | [CreateUserRequest](#slash-api-v2-CreateUserRequest) | [CreateUserResponse](#slash-api-v2-CreateUserResponse) | CreateUser creates a new user. | | ListUserAccessTokens | [ListUserAccessTokensRequest](#slash-api-v2-ListUserAccessTokensRequest) | [ListUserAccessTokensResponse](#slash-api-v2-ListUserAccessTokensResponse) | ListUserAccessTokens returns a list of access tokens for a user. | | CreateUserAccessToken | [CreateUserAccessTokenRequest](#slash-api-v2-CreateUserAccessTokenRequest) | [CreateUserAccessTokenResponse](#slash-api-v2-CreateUserAccessTokenResponse) | CreateUserAccessToken creates a new access token for a user. | | DeleteUserAccessToken | [DeleteUserAccessTokenRequest](#slash-api-v2-DeleteUserAccessTokenRequest) | [DeleteUserAccessTokenResponse](#slash-api-v2-DeleteUserAccessTokenResponse) | DeleteUserAccessToken deletes an access token for a user. | diff --git a/proto/gen/api/v2/shortcut_service.pb.go b/proto/gen/api/v2/shortcut_service.pb.go index 98cf881..085f5ba 100644 --- a/proto/gen/api/v2/shortcut_service.pb.go +++ b/proto/gen/api/v2/shortcut_service.pb.go @@ -450,6 +450,100 @@ func (x *GetShortcutResponse) GetShortcut() *Shortcut { return nil } +type CreateShortcutRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Shortcut *Shortcut `protobuf:"bytes,1,opt,name=shortcut,proto3" json:"shortcut,omitempty"` +} + +func (x *CreateShortcutRequest) Reset() { + *x = CreateShortcutRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_api_v2_shortcut_service_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreateShortcutRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateShortcutRequest) ProtoMessage() {} + +func (x *CreateShortcutRequest) ProtoReflect() protoreflect.Message { + mi := &file_api_v2_shortcut_service_proto_msgTypes[6] + 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 CreateShortcutRequest.ProtoReflect.Descriptor instead. +func (*CreateShortcutRequest) Descriptor() ([]byte, []int) { + return file_api_v2_shortcut_service_proto_rawDescGZIP(), []int{6} +} + +func (x *CreateShortcutRequest) GetShortcut() *Shortcut { + if x != nil { + return x.Shortcut + } + return nil +} + +type CreateShortcutResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Shortcut *Shortcut `protobuf:"bytes,1,opt,name=shortcut,proto3" json:"shortcut,omitempty"` +} + +func (x *CreateShortcutResponse) Reset() { + *x = CreateShortcutResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_api_v2_shortcut_service_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreateShortcutResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateShortcutResponse) ProtoMessage() {} + +func (x *CreateShortcutResponse) ProtoReflect() protoreflect.Message { + mi := &file_api_v2_shortcut_service_proto_msgTypes[7] + 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 CreateShortcutResponse.ProtoReflect.Descriptor instead. +func (*CreateShortcutResponse) Descriptor() ([]byte, []int) { + return file_api_v2_shortcut_service_proto_rawDescGZIP(), []int{7} +} + +func (x *CreateShortcutResponse) GetShortcut() *Shortcut { + if x != nil { + return x.Shortcut + } + return nil +} + var File_api_v2_shortcut_service_proto protoreflect.FileDescriptor var file_api_v2_shortcut_service_proto_rawDesc = []byte{ @@ -506,40 +600,58 @@ var file_api_v2_shortcut_service_proto_rawDesc = []byte{ 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x32, 0x0a, 0x08, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x63, 0x75, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x63, 0x75, 0x74, - 0x52, 0x08, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x63, 0x75, 0x74, 0x2a, 0x50, 0x0a, 0x0a, 0x56, 0x69, - 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x12, 0x1a, 0x0a, 0x16, 0x56, 0x49, 0x53, 0x49, - 0x42, 0x49, 0x4c, 0x49, 0x54, 0x59, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, - 0x45, 0x44, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x50, 0x52, 0x49, 0x56, 0x41, 0x54, 0x45, 0x10, - 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x57, 0x4f, 0x52, 0x4b, 0x53, 0x50, 0x41, 0x43, 0x45, 0x10, 0x02, - 0x12, 0x0a, 0x0a, 0x06, 0x50, 0x55, 0x42, 0x4c, 0x49, 0x43, 0x10, 0x03, 0x32, 0x83, 0x02, 0x0a, - 0x0f, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x63, 0x75, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x12, 0x73, 0x0a, 0x0d, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x63, 0x75, 0x74, - 0x73, 0x12, 0x22, 0x2e, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, - 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x63, 0x75, 0x74, 0x73, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x2e, 0x61, 0x70, - 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x63, 0x75, - 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x19, 0x82, 0xd3, 0xe4, 0x93, - 0x02, 0x13, 0x12, 0x11, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x32, 0x2f, 0x73, 0x68, 0x6f, 0x72, - 0x74, 0x63, 0x75, 0x74, 0x73, 0x12, 0x7b, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x53, 0x68, 0x6f, 0x72, - 0x74, 0x63, 0x75, 0x74, 0x12, 0x20, 0x2e, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x2e, 0x61, 0x70, 0x69, - 0x2e, 0x76, 0x32, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x63, 0x75, 0x74, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x2e, 0x61, - 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x63, 0x75, - 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x27, 0xda, 0x41, 0x04, 0x6e, 0x61, - 0x6d, 0x65, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1a, 0x12, 0x18, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, - 0x32, 0x2f, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x63, 0x75, 0x74, 0x73, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, - 0x65, 0x7d, 0x42, 0xab, 0x01, 0x0a, 0x10, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x6c, 0x61, 0x73, 0x68, - 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x42, 0x14, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x63, 0x75, - 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, - 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x6f, 0x6f, 0x6a, - 0x61, 0x63, 0x6b, 0x2f, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, - 0x67, 0x65, 0x6e, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x32, 0x3b, 0x61, 0x70, 0x69, 0x76, 0x32, - 0xa2, 0x02, 0x03, 0x53, 0x41, 0x58, 0xaa, 0x02, 0x0c, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x2e, 0x41, - 0x70, 0x69, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x0c, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x5c, 0x41, 0x70, - 0x69, 0x5c, 0x56, 0x32, 0xe2, 0x02, 0x18, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x5c, 0x41, 0x70, 0x69, - 0x5c, 0x56, 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, - 0x02, 0x0e, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x3a, 0x3a, 0x41, 0x70, 0x69, 0x3a, 0x3a, 0x56, 0x32, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x52, 0x08, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x63, 0x75, 0x74, 0x22, 0x4b, 0x0a, 0x15, 0x43, 0x72, + 0x65, 0x61, 0x74, 0x65, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x63, 0x75, 0x74, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x32, 0x0a, 0x08, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x63, 0x75, 0x74, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x2e, 0x61, 0x70, + 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x63, 0x75, 0x74, 0x52, 0x08, 0x73, + 0x68, 0x6f, 0x72, 0x74, 0x63, 0x75, 0x74, 0x22, 0x4c, 0x0a, 0x16, 0x43, 0x72, 0x65, 0x61, 0x74, + 0x65, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x63, 0x75, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x32, 0x0a, 0x08, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x63, 0x75, 0x74, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x2e, 0x61, 0x70, 0x69, 0x2e, + 0x76, 0x32, 0x2e, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x63, 0x75, 0x74, 0x52, 0x08, 0x73, 0x68, 0x6f, + 0x72, 0x74, 0x63, 0x75, 0x74, 0x2a, 0x50, 0x0a, 0x0a, 0x56, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, + 0x69, 0x74, 0x79, 0x12, 0x1a, 0x0a, 0x16, 0x56, 0x49, 0x53, 0x49, 0x42, 0x49, 0x4c, 0x49, 0x54, + 0x59, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, + 0x0b, 0x0a, 0x07, 0x50, 0x52, 0x49, 0x56, 0x41, 0x54, 0x45, 0x10, 0x01, 0x12, 0x0d, 0x0a, 0x09, + 0x57, 0x4f, 0x52, 0x4b, 0x53, 0x50, 0x41, 0x43, 0x45, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, 0x50, + 0x55, 0x42, 0x4c, 0x49, 0x43, 0x10, 0x03, 0x32, 0x86, 0x03, 0x0a, 0x0f, 0x53, 0x68, 0x6f, 0x72, + 0x74, 0x63, 0x75, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x73, 0x0a, 0x0d, 0x4c, + 0x69, 0x73, 0x74, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x63, 0x75, 0x74, 0x73, 0x12, 0x22, 0x2e, 0x73, + 0x6c, 0x61, 0x73, 0x68, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x73, 0x74, + 0x53, 0x68, 0x6f, 0x72, 0x74, 0x63, 0x75, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x23, 0x2e, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, + 0x4c, 0x69, 0x73, 0x74, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x63, 0x75, 0x74, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x19, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x13, 0x12, 0x11, 0x2f, + 0x61, 0x70, 0x69, 0x2f, 0x76, 0x32, 0x2f, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x63, 0x75, 0x74, 0x73, + 0x12, 0x7b, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x63, 0x75, 0x74, 0x12, + 0x20, 0x2e, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x47, + 0x65, 0x74, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x63, 0x75, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x21, 0x2e, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, + 0x2e, 0x47, 0x65, 0x74, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x63, 0x75, 0x74, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x27, 0xda, 0x41, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x82, 0xd3, 0xe4, + 0x93, 0x02, 0x1a, 0x12, 0x18, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x32, 0x2f, 0x73, 0x68, 0x6f, + 0x72, 0x74, 0x63, 0x75, 0x74, 0x73, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x7d, 0x12, 0x80, 0x01, + 0x0a, 0x0e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x63, 0x75, 0x74, + 0x12, 0x23, 0x2e, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, + 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x63, 0x75, 0x74, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x2e, 0x61, 0x70, + 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x53, 0x68, 0x6f, 0x72, 0x74, + 0x63, 0x75, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x23, 0x82, 0xd3, 0xe4, + 0x93, 0x02, 0x1d, 0x3a, 0x08, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x63, 0x75, 0x74, 0x22, 0x11, 0x2f, + 0x61, 0x70, 0x69, 0x2f, 0x76, 0x32, 0x2f, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x63, 0x75, 0x74, 0x73, + 0x42, 0xab, 0x01, 0x0a, 0x10, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x2e, 0x61, + 0x70, 0x69, 0x2e, 0x76, 0x32, 0x42, 0x14, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x63, 0x75, 0x74, 0x53, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2f, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x6f, 0x6f, 0x6a, 0x61, 0x63, + 0x6b, 0x2f, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x65, + 0x6e, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x32, 0x3b, 0x61, 0x70, 0x69, 0x76, 0x32, 0xa2, 0x02, + 0x03, 0x53, 0x41, 0x58, 0xaa, 0x02, 0x0c, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x2e, 0x41, 0x70, 0x69, + 0x2e, 0x56, 0x32, 0xca, 0x02, 0x0c, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x5c, 0x41, 0x70, 0x69, 0x5c, + 0x56, 0x32, 0xe2, 0x02, 0x18, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x5c, 0x41, 0x70, 0x69, 0x5c, 0x56, + 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0e, + 0x53, 0x6c, 0x61, 0x73, 0x68, 0x3a, 0x3a, 0x41, 0x70, 0x69, 0x3a, 0x3a, 0x56, 0x32, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -555,32 +667,38 @@ func file_api_v2_shortcut_service_proto_rawDescGZIP() []byte { } var file_api_v2_shortcut_service_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_api_v2_shortcut_service_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_api_v2_shortcut_service_proto_msgTypes = make([]protoimpl.MessageInfo, 8) var file_api_v2_shortcut_service_proto_goTypes = []interface{}{ - (Visibility)(0), // 0: slash.api.v2.Visibility - (*Shortcut)(nil), // 1: slash.api.v2.Shortcut - (*OpenGraphMetadata)(nil), // 2: slash.api.v2.OpenGraphMetadata - (*ListShortcutsRequest)(nil), // 3: slash.api.v2.ListShortcutsRequest - (*ListShortcutsResponse)(nil), // 4: slash.api.v2.ListShortcutsResponse - (*GetShortcutRequest)(nil), // 5: slash.api.v2.GetShortcutRequest - (*GetShortcutResponse)(nil), // 6: slash.api.v2.GetShortcutResponse - (RowStatus)(0), // 7: slash.api.v2.RowStatus + (Visibility)(0), // 0: slash.api.v2.Visibility + (*Shortcut)(nil), // 1: slash.api.v2.Shortcut + (*OpenGraphMetadata)(nil), // 2: slash.api.v2.OpenGraphMetadata + (*ListShortcutsRequest)(nil), // 3: slash.api.v2.ListShortcutsRequest + (*ListShortcutsResponse)(nil), // 4: slash.api.v2.ListShortcutsResponse + (*GetShortcutRequest)(nil), // 5: slash.api.v2.GetShortcutRequest + (*GetShortcutResponse)(nil), // 6: slash.api.v2.GetShortcutResponse + (*CreateShortcutRequest)(nil), // 7: slash.api.v2.CreateShortcutRequest + (*CreateShortcutResponse)(nil), // 8: slash.api.v2.CreateShortcutResponse + (RowStatus)(0), // 9: slash.api.v2.RowStatus } var file_api_v2_shortcut_service_proto_depIdxs = []int32{ - 7, // 0: slash.api.v2.Shortcut.row_status:type_name -> slash.api.v2.RowStatus - 0, // 1: slash.api.v2.Shortcut.visibility:type_name -> slash.api.v2.Visibility - 2, // 2: slash.api.v2.Shortcut.og_metadata:type_name -> slash.api.v2.OpenGraphMetadata - 1, // 3: slash.api.v2.ListShortcutsResponse.shortcuts:type_name -> slash.api.v2.Shortcut - 1, // 4: slash.api.v2.GetShortcutResponse.shortcut:type_name -> slash.api.v2.Shortcut - 3, // 5: slash.api.v2.ShortcutService.ListShortcuts:input_type -> slash.api.v2.ListShortcutsRequest - 5, // 6: slash.api.v2.ShortcutService.GetShortcut:input_type -> slash.api.v2.GetShortcutRequest - 4, // 7: slash.api.v2.ShortcutService.ListShortcuts:output_type -> slash.api.v2.ListShortcutsResponse - 6, // 8: slash.api.v2.ShortcutService.GetShortcut:output_type -> slash.api.v2.GetShortcutResponse - 7, // [7:9] is the sub-list for method output_type - 5, // [5:7] 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 + 9, // 0: slash.api.v2.Shortcut.row_status:type_name -> slash.api.v2.RowStatus + 0, // 1: slash.api.v2.Shortcut.visibility:type_name -> slash.api.v2.Visibility + 2, // 2: slash.api.v2.Shortcut.og_metadata:type_name -> slash.api.v2.OpenGraphMetadata + 1, // 3: slash.api.v2.ListShortcutsResponse.shortcuts:type_name -> slash.api.v2.Shortcut + 1, // 4: slash.api.v2.GetShortcutResponse.shortcut:type_name -> slash.api.v2.Shortcut + 1, // 5: slash.api.v2.CreateShortcutRequest.shortcut:type_name -> slash.api.v2.Shortcut + 1, // 6: slash.api.v2.CreateShortcutResponse.shortcut:type_name -> slash.api.v2.Shortcut + 3, // 7: slash.api.v2.ShortcutService.ListShortcuts:input_type -> slash.api.v2.ListShortcutsRequest + 5, // 8: slash.api.v2.ShortcutService.GetShortcut:input_type -> slash.api.v2.GetShortcutRequest + 7, // 9: slash.api.v2.ShortcutService.CreateShortcut:input_type -> slash.api.v2.CreateShortcutRequest + 4, // 10: slash.api.v2.ShortcutService.ListShortcuts:output_type -> slash.api.v2.ListShortcutsResponse + 6, // 11: slash.api.v2.ShortcutService.GetShortcut:output_type -> slash.api.v2.GetShortcutResponse + 8, // 12: slash.api.v2.ShortcutService.CreateShortcut:output_type -> slash.api.v2.CreateShortcutResponse + 10, // [10:13] is the sub-list for method output_type + 7, // [7:10] is the sub-list for method input_type + 7, // [7:7] is the sub-list for extension type_name + 7, // [7:7] is the sub-list for extension extendee + 0, // [0:7] is the sub-list for field type_name } func init() { file_api_v2_shortcut_service_proto_init() } @@ -662,6 +780,30 @@ func file_api_v2_shortcut_service_proto_init() { return nil } } + file_api_v2_shortcut_service_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreateShortcutRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_api_v2_shortcut_service_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreateShortcutResponse); 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{ @@ -669,7 +811,7 @@ func file_api_v2_shortcut_service_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_api_v2_shortcut_service_proto_rawDesc, NumEnums: 1, - NumMessages: 6, + NumMessages: 8, NumExtensions: 0, NumServices: 1, }, diff --git a/proto/gen/api/v2/shortcut_service.pb.gw.go b/proto/gen/api/v2/shortcut_service.pb.gw.go index 5ae9fa3..b69ca4a 100644 --- a/proto/gen/api/v2/shortcut_service.pb.gw.go +++ b/proto/gen/api/v2/shortcut_service.pb.gw.go @@ -101,6 +101,40 @@ func local_request_ShortcutService_GetShortcut_0(ctx context.Context, marshaler } +func request_ShortcutService_CreateShortcut_0(ctx context.Context, marshaler runtime.Marshaler, client ShortcutServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq CreateShortcutRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Shortcut); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.CreateShortcut(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_ShortcutService_CreateShortcut_0(ctx context.Context, marshaler runtime.Marshaler, server ShortcutServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq CreateShortcutRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Shortcut); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.CreateShortcut(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterShortcutServiceHandlerServer registers the http handlers for service ShortcutService to "mux". // UnaryRPC :call ShortcutServiceServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -157,6 +191,31 @@ func RegisterShortcutServiceHandlerServer(ctx context.Context, mux *runtime.Serv }) + mux.Handle("POST", pattern_ShortcutService_CreateShortcut_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/slash.api.v2.ShortcutService/CreateShortcut", runtime.WithHTTPPathPattern("/api/v2/shortcuts")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_ShortcutService_CreateShortcut_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_ShortcutService_CreateShortcut_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -242,6 +301,28 @@ func RegisterShortcutServiceHandlerClient(ctx context.Context, mux *runtime.Serv }) + mux.Handle("POST", pattern_ShortcutService_CreateShortcut_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/slash.api.v2.ShortcutService/CreateShortcut", runtime.WithHTTPPathPattern("/api/v2/shortcuts")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_ShortcutService_CreateShortcut_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_ShortcutService_CreateShortcut_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -249,10 +330,14 @@ var ( pattern_ShortcutService_ListShortcuts_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v2", "shortcuts"}, "")) pattern_ShortcutService_GetShortcut_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"api", "v2", "shortcuts", "name"}, "")) + + pattern_ShortcutService_CreateShortcut_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v2", "shortcuts"}, "")) ) var ( forward_ShortcutService_ListShortcuts_0 = runtime.ForwardResponseMessage forward_ShortcutService_GetShortcut_0 = runtime.ForwardResponseMessage + + forward_ShortcutService_CreateShortcut_0 = runtime.ForwardResponseMessage ) diff --git a/proto/gen/api/v2/shortcut_service_grpc.pb.go b/proto/gen/api/v2/shortcut_service_grpc.pb.go index 79efc7a..35458ba 100644 --- a/proto/gen/api/v2/shortcut_service_grpc.pb.go +++ b/proto/gen/api/v2/shortcut_service_grpc.pb.go @@ -19,17 +19,21 @@ import ( const _ = grpc.SupportPackageIsVersion7 const ( - ShortcutService_ListShortcuts_FullMethodName = "/slash.api.v2.ShortcutService/ListShortcuts" - ShortcutService_GetShortcut_FullMethodName = "/slash.api.v2.ShortcutService/GetShortcut" + ShortcutService_ListShortcuts_FullMethodName = "/slash.api.v2.ShortcutService/ListShortcuts" + ShortcutService_GetShortcut_FullMethodName = "/slash.api.v2.ShortcutService/GetShortcut" + ShortcutService_CreateShortcut_FullMethodName = "/slash.api.v2.ShortcutService/CreateShortcut" ) // ShortcutServiceClient is the client API for ShortcutService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type ShortcutServiceClient interface { + // ListShortcuts returns a list of shortcuts. ListShortcuts(ctx context.Context, in *ListShortcutsRequest, opts ...grpc.CallOption) (*ListShortcutsResponse, error) // GetShortcut returns a shortcut by name. GetShortcut(ctx context.Context, in *GetShortcutRequest, opts ...grpc.CallOption) (*GetShortcutResponse, error) + // CreateShortcut creates a shortcut. + CreateShortcut(ctx context.Context, in *CreateShortcutRequest, opts ...grpc.CallOption) (*CreateShortcutResponse, error) } type shortcutServiceClient struct { @@ -58,13 +62,25 @@ func (c *shortcutServiceClient) GetShortcut(ctx context.Context, in *GetShortcut return out, nil } +func (c *shortcutServiceClient) CreateShortcut(ctx context.Context, in *CreateShortcutRequest, opts ...grpc.CallOption) (*CreateShortcutResponse, error) { + out := new(CreateShortcutResponse) + err := c.cc.Invoke(ctx, ShortcutService_CreateShortcut_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // ShortcutServiceServer is the server API for ShortcutService service. // All implementations must embed UnimplementedShortcutServiceServer // for forward compatibility type ShortcutServiceServer interface { + // ListShortcuts returns a list of shortcuts. ListShortcuts(context.Context, *ListShortcutsRequest) (*ListShortcutsResponse, error) // GetShortcut returns a shortcut by name. GetShortcut(context.Context, *GetShortcutRequest) (*GetShortcutResponse, error) + // CreateShortcut creates a shortcut. + CreateShortcut(context.Context, *CreateShortcutRequest) (*CreateShortcutResponse, error) mustEmbedUnimplementedShortcutServiceServer() } @@ -78,6 +94,9 @@ func (UnimplementedShortcutServiceServer) ListShortcuts(context.Context, *ListSh func (UnimplementedShortcutServiceServer) GetShortcut(context.Context, *GetShortcutRequest) (*GetShortcutResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetShortcut not implemented") } +func (UnimplementedShortcutServiceServer) CreateShortcut(context.Context, *CreateShortcutRequest) (*CreateShortcutResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateShortcut not implemented") +} func (UnimplementedShortcutServiceServer) mustEmbedUnimplementedShortcutServiceServer() {} // UnsafeShortcutServiceServer may be embedded to opt out of forward compatibility for this service. @@ -127,6 +146,24 @@ func _ShortcutService_GetShortcut_Handler(srv interface{}, ctx context.Context, return interceptor(ctx, in, info, handler) } +func _ShortcutService_CreateShortcut_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreateShortcutRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ShortcutServiceServer).CreateShortcut(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: ShortcutService_CreateShortcut_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ShortcutServiceServer).CreateShortcut(ctx, req.(*CreateShortcutRequest)) + } + return interceptor(ctx, in, info, handler) +} + // ShortcutService_ServiceDesc is the grpc.ServiceDesc for ShortcutService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -142,6 +179,10 @@ var ShortcutService_ServiceDesc = grpc.ServiceDesc{ MethodName: "GetShortcut", Handler: _ShortcutService_GetShortcut_Handler, }, + { + MethodName: "CreateShortcut", + Handler: _ShortcutService_CreateShortcut_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "api/v2/shortcut_service.proto", diff --git a/proto/gen/api/v2/user_service_grpc.pb.go b/proto/gen/api/v2/user_service_grpc.pb.go index b96b44f..edbf6de 100644 --- a/proto/gen/api/v2/user_service_grpc.pb.go +++ b/proto/gen/api/v2/user_service_grpc.pb.go @@ -32,6 +32,7 @@ const ( type UserServiceClient interface { // GetUser returns a user by id. GetUser(ctx context.Context, in *GetUserRequest, opts ...grpc.CallOption) (*GetUserResponse, error) + // CreateUser creates a new user. CreateUser(ctx context.Context, in *CreateUserRequest, opts ...grpc.CallOption) (*CreateUserResponse, error) // ListUserAccessTokens returns a list of access tokens for a user. ListUserAccessTokens(ctx context.Context, in *ListUserAccessTokensRequest, opts ...grpc.CallOption) (*ListUserAccessTokensResponse, error) @@ -100,6 +101,7 @@ func (c *userServiceClient) DeleteUserAccessToken(ctx context.Context, in *Delet type UserServiceServer interface { // GetUser returns a user by id. GetUser(context.Context, *GetUserRequest) (*GetUserResponse, error) + // CreateUser creates a new user. CreateUser(context.Context, *CreateUserRequest) (*CreateUserResponse, error) // ListUserAccessTokens returns a list of access tokens for a user. ListUserAccessTokens(context.Context, *ListUserAccessTokensRequest) (*ListUserAccessTokensResponse, error) diff --git a/proto/gen/store/README.md b/proto/gen/store/README.md index 58d9af5..c71067e 100644 --- a/proto/gen/store/README.md +++ b/proto/gen/store/README.md @@ -3,6 +3,9 @@ ## Table of Contents +- [store/activity.proto](#store_activity-proto) + - [ActivityShorcutCreatePayload](#slash-store-ActivityShorcutCreatePayload) + - [store/common.proto](#store_common-proto) - [RowStatus](#slash-store-RowStatus) @@ -23,6 +26,37 @@ + +

Top

+ +## store/activity.proto + + + + + +### ActivityShorcutCreatePayload + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| shortcut_id | [int32](#int32) | | | + + + + + + + + + + + + + + +

Top

diff --git a/proto/gen/store/activity.pb.go b/proto/gen/store/activity.pb.go new file mode 100644 index 0000000..4f6abf9 --- /dev/null +++ b/proto/gen/store/activity.pb.go @@ -0,0 +1,153 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc (unknown) +// source: store/activity.proto + +package store + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type ActivityShorcutCreatePayload struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ShortcutId int32 `protobuf:"varint,1,opt,name=shortcut_id,json=shortcutId,proto3" json:"shortcut_id,omitempty"` +} + +func (x *ActivityShorcutCreatePayload) Reset() { + *x = ActivityShorcutCreatePayload{} + if protoimpl.UnsafeEnabled { + mi := &file_store_activity_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ActivityShorcutCreatePayload) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ActivityShorcutCreatePayload) ProtoMessage() {} + +func (x *ActivityShorcutCreatePayload) ProtoReflect() protoreflect.Message { + mi := &file_store_activity_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 ActivityShorcutCreatePayload.ProtoReflect.Descriptor instead. +func (*ActivityShorcutCreatePayload) Descriptor() ([]byte, []int) { + return file_store_activity_proto_rawDescGZIP(), []int{0} +} + +func (x *ActivityShorcutCreatePayload) GetShortcutId() int32 { + if x != nil { + return x.ShortcutId + } + return 0 +} + +var File_store_activity_proto protoreflect.FileDescriptor + +var file_store_activity_proto_rawDesc = []byte{ + 0x0a, 0x14, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0b, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x2e, 0x73, 0x74, + 0x6f, 0x72, 0x65, 0x22, 0x3f, 0x0a, 0x1c, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x53, + 0x68, 0x6f, 0x72, 0x63, 0x75, 0x74, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x61, 0x79, 0x6c, + 0x6f, 0x61, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x63, 0x75, 0x74, 0x5f, + 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x63, + 0x75, 0x74, 0x49, 0x64, 0x42, 0x97, 0x01, 0x0a, 0x0f, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x6c, 0x61, + 0x73, 0x68, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x42, 0x0d, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, + 0x74, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x6f, 0x6f, 0x6a, 0x61, 0x63, 0x6b, 0x2f, 0x73, 0x6c, + 0x61, 0x73, 0x68, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x73, 0x74, + 0x6f, 0x72, 0x65, 0xa2, 0x02, 0x03, 0x53, 0x53, 0x58, 0xaa, 0x02, 0x0b, 0x53, 0x6c, 0x61, 0x73, + 0x68, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x65, 0xca, 0x02, 0x0b, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x5c, + 0x53, 0x74, 0x6f, 0x72, 0x65, 0xe2, 0x02, 0x17, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x5c, 0x53, 0x74, + 0x6f, 0x72, 0x65, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, + 0x02, 0x0c, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x3a, 0x3a, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_store_activity_proto_rawDescOnce sync.Once + file_store_activity_proto_rawDescData = file_store_activity_proto_rawDesc +) + +func file_store_activity_proto_rawDescGZIP() []byte { + file_store_activity_proto_rawDescOnce.Do(func() { + file_store_activity_proto_rawDescData = protoimpl.X.CompressGZIP(file_store_activity_proto_rawDescData) + }) + return file_store_activity_proto_rawDescData +} + +var file_store_activity_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_store_activity_proto_goTypes = []interface{}{ + (*ActivityShorcutCreatePayload)(nil), // 0: slash.store.ActivityShorcutCreatePayload +} +var file_store_activity_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_store_activity_proto_init() } +func file_store_activity_proto_init() { + if File_store_activity_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_store_activity_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ActivityShorcutCreatePayload); 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_store_activity_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_store_activity_proto_goTypes, + DependencyIndexes: file_store_activity_proto_depIdxs, + MessageInfos: file_store_activity_proto_msgTypes, + }.Build() + File_store_activity_proto = out.File + file_store_activity_proto_rawDesc = nil + file_store_activity_proto_goTypes = nil + file_store_activity_proto_depIdxs = nil +} diff --git a/proto/store/activity.proto b/proto/store/activity.proto new file mode 100644 index 0000000..0039d22 --- /dev/null +++ b/proto/store/activity.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +package slash.store; + +option go_package = "gen/store"; + +message ActivityShorcutCreatePayload { + int32 shortcut_id = 1; +} diff --git a/web/src/types/proto/api/v2/shortcut_service_pb.d.ts b/web/src/types/proto/api/v2/shortcut_service_pb.d.ts index cf58f56..aebf175 100644 --- a/web/src/types/proto/api/v2/shortcut_service_pb.d.ts +++ b/web/src/types/proto/api/v2/shortcut_service_pb.d.ts @@ -236,3 +236,51 @@ export declare class GetShortcutResponse extends Message { static equals(a: GetShortcutResponse | PlainMessage | undefined, b: GetShortcutResponse | PlainMessage | undefined): boolean; } +/** + * @generated from message slash.api.v2.CreateShortcutRequest + */ +export declare class CreateShortcutRequest extends Message { + /** + * @generated from field: slash.api.v2.Shortcut shortcut = 1; + */ + shortcut?: Shortcut; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "slash.api.v2.CreateShortcutRequest"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): CreateShortcutRequest; + + static fromJson(jsonValue: JsonValue, options?: Partial): CreateShortcutRequest; + + static fromJsonString(jsonString: string, options?: Partial): CreateShortcutRequest; + + static equals(a: CreateShortcutRequest | PlainMessage | undefined, b: CreateShortcutRequest | PlainMessage | undefined): boolean; +} + +/** + * @generated from message slash.api.v2.CreateShortcutResponse + */ +export declare class CreateShortcutResponse extends Message { + /** + * @generated from field: slash.api.v2.Shortcut shortcut = 1; + */ + shortcut?: Shortcut; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "slash.api.v2.CreateShortcutResponse"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): CreateShortcutResponse; + + static fromJson(jsonValue: JsonValue, options?: Partial): CreateShortcutResponse; + + static fromJsonString(jsonString: string, options?: Partial): CreateShortcutResponse; + + static equals(a: CreateShortcutResponse | PlainMessage | undefined, b: CreateShortcutResponse | PlainMessage | undefined): boolean; +} + diff --git a/web/src/types/proto/api/v2/shortcut_service_pb.js b/web/src/types/proto/api/v2/shortcut_service_pb.js index 1043b7f..418e677 100644 --- a/web/src/types/proto/api/v2/shortcut_service_pb.js +++ b/web/src/types/proto/api/v2/shortcut_service_pb.js @@ -90,3 +90,23 @@ export const GetShortcutResponse = proto3.makeMessageType( ], ); +/** + * @generated from message slash.api.v2.CreateShortcutRequest + */ +export const CreateShortcutRequest = proto3.makeMessageType( + "slash.api.v2.CreateShortcutRequest", + () => [ + { no: 1, name: "shortcut", kind: "message", T: Shortcut }, + ], +); + +/** + * @generated from message slash.api.v2.CreateShortcutResponse + */ +export const CreateShortcutResponse = proto3.makeMessageType( + "slash.api.v2.CreateShortcutResponse", + () => [ + { no: 1, name: "shortcut", kind: "message", T: Shortcut }, + ], +); + diff --git a/web/src/types/proto/store/activity_pb.d.ts b/web/src/types/proto/store/activity_pb.d.ts new file mode 100644 index 0000000..a3c8c09 --- /dev/null +++ b/web/src/types/proto/store/activity_pb.d.ts @@ -0,0 +1,32 @@ +// @generated by protoc-gen-es v1.3.0 +// @generated from file store/activity.proto (package slash.store, syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; +import { Message, proto3 } from "@bufbuild/protobuf"; + +/** + * @generated from message slash.store.ActivityShorcutCreatePayload + */ +export declare class ActivityShorcutCreatePayload extends Message { + /** + * @generated from field: int32 shortcut_id = 1; + */ + shortcutId: number; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "slash.store.ActivityShorcutCreatePayload"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): ActivityShorcutCreatePayload; + + static fromJson(jsonValue: JsonValue, options?: Partial): ActivityShorcutCreatePayload; + + static fromJsonString(jsonString: string, options?: Partial): ActivityShorcutCreatePayload; + + static equals(a: ActivityShorcutCreatePayload | PlainMessage | undefined, b: ActivityShorcutCreatePayload | PlainMessage | undefined): boolean; +} + diff --git a/web/src/types/proto/store/activity_pb.js b/web/src/types/proto/store/activity_pb.js new file mode 100644 index 0000000..4e4e768 --- /dev/null +++ b/web/src/types/proto/store/activity_pb.js @@ -0,0 +1,17 @@ +// @generated by protoc-gen-es v1.3.0 +// @generated from file store/activity.proto (package slash.store, syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import { proto3 } from "@bufbuild/protobuf"; + +/** + * @generated from message slash.store.ActivityShorcutCreatePayload + */ +export const ActivityShorcutCreatePayload = proto3.makeMessageType( + "slash.store.ActivityShorcutCreatePayload", + () => [ + { no: 1, name: "shortcut_id", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, + ], +); +