diff --git a/cmd/memos.go b/cmd/memos.go index 06a6c919..edcbd974 100644 --- a/cmd/memos.go +++ b/cmd/memos.go @@ -10,11 +10,12 @@ import ( "github.com/spf13/cobra" "github.com/spf13/viper" - + "github.com/usememos/memos/common/log" "github.com/usememos/memos/server" _profile "github.com/usememos/memos/server/profile" "github.com/usememos/memos/store" "github.com/usememos/memos/store/db" + "go.uber.org/zap" ) const ( @@ -42,7 +43,7 @@ var ( db := db.NewDB(profile) if err := db.Open(ctx); err != nil { cancel() - fmt.Printf("failed to open db, error: %+v\n", err) + log.Error("failed to open db", zap.Error(err)) return } @@ -50,7 +51,7 @@ var ( s, err := server.NewServer(ctx, profile, store) if err != nil { cancel() - fmt.Printf("failed to create server, error: %+v\n", err) + log.Error("failed to create server", zap.Error(err)) return } @@ -61,16 +62,16 @@ var ( signal.Notify(c, os.Interrupt, syscall.SIGTERM) go func() { sig := <-c - fmt.Printf("%s received.\n", sig.String()) + log.Info(fmt.Sprintf("%s received.\n", sig.String())) s.Shutdown(ctx) cancel() }() - println(greetingBanner) - fmt.Printf("Version %s has started at :%d\n", profile.Version, profile.Port) + printGreetings() + if err := s.Start(ctx); err != nil { if err != http.ErrServerClosed { - fmt.Printf("failed to start server, error: %+v\n", err) + log.Error("failed to start server", zap.Error(err)) cancel() } } @@ -82,6 +83,7 @@ var ( ) func Execute() error { + defer log.Sync() return rootCmd.Execute() } @@ -127,3 +129,13 @@ func initConfig() { println("version:", profile.Version) println("---") } + +func printGreetings() { + fmt.Print(greetingBanner) + fmt.Printf("Version %s has been started on port %d\n", profile.Version, profile.Port) + fmt.Println("---") + fmt.Println("See more in:") + fmt.Printf("👉Website: %s\n", "https://usememos.com") + fmt.Printf("👉GitHub: %s\n", "https://github.com/usememos/memos") + fmt.Println("---") +} diff --git a/common/log/logger.go b/common/log/logger.go index 26762a5d..c8395214 100644 --- a/common/log/logger.go +++ b/common/log/logger.go @@ -1,4 +1,3 @@ -// Package log implements a simple logging package. package log import ( diff --git a/proto/buf.gen.yaml b/proto/buf.gen.yaml index 55c80623..776a3bd8 100644 --- a/proto/buf.gen.yaml +++ b/proto/buf.gen.yaml @@ -18,6 +18,9 @@ plugins: out: gen opt: - paths=source_relative + # Build the TypeScript definitions for the web. + - plugin: buf.build/bufbuild/es:v1.3.0 + out: ../web/src/types/proto - plugin: buf.build/community/pseudomuto-doc:v1.5.1 out: gen opt: diff --git a/server/backup.go b/server/backup.go index 25780a6f..6eaded62 100644 --- a/server/backup.go +++ b/server/backup.go @@ -25,7 +25,7 @@ func NewBackupRunner(store *store.Store) *BackupRunner { func (r *BackupRunner) Run(ctx context.Context) { intervalStr := r.Store.GetSystemSettingValueWithDefault(&ctx, apiv1.SystemSettingAutoBackupIntervalName.String(), "") if intervalStr == "" { - log.Info("no SystemSettingAutoBackupIntervalName setting, disable auto backup") + log.Debug("no SystemSettingAutoBackupIntervalName setting, disable auto backup") return } diff --git a/web/src/types/proto/api/v2/common_pb.d.ts b/web/src/types/proto/api/v2/common_pb.d.ts new file mode 100644 index 00000000..4d8214e5 --- /dev/null +++ b/web/src/types/proto/api/v2/common_pb.d.ts @@ -0,0 +1,25 @@ +// @generated by protoc-gen-es v1.3.0 +// @generated from file api/v2/common.proto (package memos.api.v2, syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +/** + * @generated from enum memos.api.v2.RowStatus + */ +export declare enum RowStatus { + /** + * @generated from enum value: ROW_STATUS_UNSPECIFIED = 0; + */ + ROW_STATUS_UNSPECIFIED = 0, + + /** + * @generated from enum value: ACTIVE = 1; + */ + ACTIVE = 1, + + /** + * @generated from enum value: ARCHIVED = 2; + */ + ARCHIVED = 2, +} + diff --git a/web/src/types/proto/api/v2/common_pb.js b/web/src/types/proto/api/v2/common_pb.js new file mode 100644 index 00000000..b4cb85a8 --- /dev/null +++ b/web/src/types/proto/api/v2/common_pb.js @@ -0,0 +1,19 @@ +// @generated by protoc-gen-es v1.3.0 +// @generated from file api/v2/common.proto (package memos.api.v2, syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import { proto3 } from "@bufbuild/protobuf"; + +/** + * @generated from enum memos.api.v2.RowStatus + */ +export const RowStatus = proto3.makeEnum( + "memos.api.v2.RowStatus", + [ + {no: 0, name: "ROW_STATUS_UNSPECIFIED"}, + {no: 1, name: "ACTIVE"}, + {no: 2, name: "ARCHIVED"}, + ], +); + diff --git a/web/src/types/proto/api/v2/memo_service_pb.d.ts b/web/src/types/proto/api/v2/memo_service_pb.d.ts new file mode 100644 index 00000000..45b935b3 --- /dev/null +++ b/web/src/types/proto/api/v2/memo_service_pb.d.ts @@ -0,0 +1,206 @@ +// @generated by protoc-gen-es v1.3.0 +// @generated from file api/v2/memo_service.proto (package memos.api.v2, syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; +import { Message, proto3 } from "@bufbuild/protobuf"; +import type { RowStatus } from "./common_pb.js"; + +/** + * @generated from enum memos.api.v2.Visibility + */ +export declare enum Visibility { + /** + * @generated from enum value: VISIBILITY_UNSPECIFIED = 0; + */ + VISIBILITY_UNSPECIFIED = 0, + + /** + * @generated from enum value: PRIVATE = 1; + */ + PRIVATE = 1, + + /** + * @generated from enum value: PROTECTED = 2; + */ + PROTECTED = 2, + + /** + * @generated from enum value: PUBLIC = 3; + */ + PUBLIC = 3, +} + +/** + * @generated from message memos.api.v2.Memo + */ +export declare class Memo extends Message { + /** + * @generated from field: int32 id = 1; + */ + id: number; + + /** + * @generated from field: memos.api.v2.RowStatus row_status = 2; + */ + rowStatus: RowStatus; + + /** + * @generated from field: int32 creator_id = 3; + */ + creatorId: number; + + /** + * @generated from field: int64 created_ts = 4; + */ + createdTs: bigint; + + /** + * @generated from field: int64 updated_ts = 5; + */ + updatedTs: bigint; + + /** + * @generated from field: string content = 6; + */ + content: string; + + /** + * @generated from field: memos.api.v2.Visibility visibility = 7; + */ + visibility: Visibility; + + /** + * @generated from field: bool pinned = 8; + */ + pinned: boolean; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "memos.api.v2.Memo"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): Memo; + + static fromJson(jsonValue: JsonValue, options?: Partial): Memo; + + static fromJsonString(jsonString: string, options?: Partial): Memo; + + static equals(a: Memo | PlainMessage | undefined, b: Memo | PlainMessage | undefined): boolean; +} + +/** + * @generated from message memos.api.v2.ListMemosRequest + */ +export declare class ListMemosRequest extends Message { + /** + * @generated from field: int32 page = 1; + */ + page: number; + + /** + * @generated from field: int32 page_size = 2; + */ + pageSize: number; + + /** + * Filter is used to filter memos returned in the list. + * + * @generated from field: string filter = 3; + */ + filter: string; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "memos.api.v2.ListMemosRequest"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): ListMemosRequest; + + static fromJson(jsonValue: JsonValue, options?: Partial): ListMemosRequest; + + static fromJsonString(jsonString: string, options?: Partial): ListMemosRequest; + + static equals(a: ListMemosRequest | PlainMessage | undefined, b: ListMemosRequest | PlainMessage | undefined): boolean; +} + +/** + * @generated from message memos.api.v2.ListMemosResponse + */ +export declare class ListMemosResponse extends Message { + /** + * @generated from field: repeated memos.api.v2.Memo memos = 1; + */ + memos: Memo[]; + + /** + * @generated from field: int32 total = 2; + */ + total: number; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "memos.api.v2.ListMemosResponse"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): ListMemosResponse; + + static fromJson(jsonValue: JsonValue, options?: Partial): ListMemosResponse; + + static fromJsonString(jsonString: string, options?: Partial): ListMemosResponse; + + static equals(a: ListMemosResponse | PlainMessage | undefined, b: ListMemosResponse | PlainMessage | undefined): boolean; +} + +/** + * @generated from message memos.api.v2.GetMemoRequest + */ +export declare class GetMemoRequest extends Message { + /** + * @generated from field: int32 id = 1; + */ + id: number; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "memos.api.v2.GetMemoRequest"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): GetMemoRequest; + + static fromJson(jsonValue: JsonValue, options?: Partial): GetMemoRequest; + + static fromJsonString(jsonString: string, options?: Partial): GetMemoRequest; + + static equals(a: GetMemoRequest | PlainMessage | undefined, b: GetMemoRequest | PlainMessage | undefined): boolean; +} + +/** + * @generated from message memos.api.v2.GetMemoResponse + */ +export declare class GetMemoResponse extends Message { + /** + * @generated from field: memos.api.v2.Memo memo = 1; + */ + memo?: Memo; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "memos.api.v2.GetMemoResponse"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): GetMemoResponse; + + static fromJson(jsonValue: JsonValue, options?: Partial): GetMemoResponse; + + static fromJsonString(jsonString: string, options?: Partial): GetMemoResponse; + + static equals(a: GetMemoResponse | PlainMessage | undefined, b: GetMemoResponse | PlainMessage | undefined): boolean; +} + diff --git a/web/src/types/proto/api/v2/memo_service_pb.js b/web/src/types/proto/api/v2/memo_service_pb.js new file mode 100644 index 00000000..c77c4cf4 --- /dev/null +++ b/web/src/types/proto/api/v2/memo_service_pb.js @@ -0,0 +1,81 @@ +// @generated by protoc-gen-es v1.3.0 +// @generated from file api/v2/memo_service.proto (package memos.api.v2, syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import { proto3 } from "@bufbuild/protobuf"; +import { RowStatus } from "./common_pb.js"; + +/** + * @generated from enum memos.api.v2.Visibility + */ +export const Visibility = proto3.makeEnum( + "memos.api.v2.Visibility", + [ + {no: 0, name: "VISIBILITY_UNSPECIFIED"}, + {no: 1, name: "PRIVATE"}, + {no: 2, name: "PROTECTED"}, + {no: 3, name: "PUBLIC"}, + ], +); + +/** + * @generated from message memos.api.v2.Memo + */ +export const Memo = proto3.makeMessageType( + "memos.api.v2.Memo", + () => [ + { no: 1, name: "id", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, + { no: 2, name: "row_status", kind: "enum", T: proto3.getEnumType(RowStatus) }, + { no: 3, name: "creator_id", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, + { no: 4, name: "created_ts", kind: "scalar", T: 3 /* ScalarType.INT64 */ }, + { no: 5, name: "updated_ts", kind: "scalar", T: 3 /* ScalarType.INT64 */ }, + { no: 6, name: "content", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 7, name: "visibility", kind: "enum", T: proto3.getEnumType(Visibility) }, + { no: 8, name: "pinned", kind: "scalar", T: 8 /* ScalarType.BOOL */ }, + ], +); + +/** + * @generated from message memos.api.v2.ListMemosRequest + */ +export const ListMemosRequest = proto3.makeMessageType( + "memos.api.v2.ListMemosRequest", + () => [ + { no: 1, name: "page", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, + { no: 2, name: "page_size", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, + { no: 3, name: "filter", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ], +); + +/** + * @generated from message memos.api.v2.ListMemosResponse + */ +export const ListMemosResponse = proto3.makeMessageType( + "memos.api.v2.ListMemosResponse", + () => [ + { no: 1, name: "memos", kind: "message", T: Memo, repeated: true }, + { no: 2, name: "total", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, + ], +); + +/** + * @generated from message memos.api.v2.GetMemoRequest + */ +export const GetMemoRequest = proto3.makeMessageType( + "memos.api.v2.GetMemoRequest", + () => [ + { no: 1, name: "id", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, + ], +); + +/** + * @generated from message memos.api.v2.GetMemoResponse + */ +export const GetMemoResponse = proto3.makeMessageType( + "memos.api.v2.GetMemoResponse", + () => [ + { no: 1, name: "memo", kind: "message", T: Memo }, + ], +); + diff --git a/web/src/types/proto/api/v2/system_service_pb.d.ts b/web/src/types/proto/api/v2/system_service_pb.d.ts new file mode 100644 index 00000000..1f10cb55 --- /dev/null +++ b/web/src/types/proto/api/v2/system_service_pb.d.ts @@ -0,0 +1,105 @@ +// @generated by protoc-gen-es v1.3.0 +// @generated from file api/v2/system_service.proto (package memos.api.v2, 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 memos.api.v2.SystemInfo + */ +export declare class SystemInfo extends Message { + /** + * @generated from field: string version = 1; + */ + version: string; + + /** + * @generated from field: string mode = 2; + */ + mode: string; + + /** + * @generated from field: bool allow_registration = 3; + */ + allowRegistration: boolean; + + /** + * @generated from field: bool disable_password_login = 4; + */ + disablePasswordLogin: boolean; + + /** + * @generated from field: string additional_script = 5; + */ + additionalScript: string; + + /** + * @generated from field: string additional_style = 6; + */ + additionalStyle: string; + + /** + * @generated from field: int64 db_size = 7; + */ + dbSize: bigint; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "memos.api.v2.SystemInfo"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): SystemInfo; + + static fromJson(jsonValue: JsonValue, options?: Partial): SystemInfo; + + static fromJsonString(jsonString: string, options?: Partial): SystemInfo; + + static equals(a: SystemInfo | PlainMessage | undefined, b: SystemInfo | PlainMessage | undefined): boolean; +} + +/** + * @generated from message memos.api.v2.GetSystemInfoRequest + */ +export declare class GetSystemInfoRequest extends Message { + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "memos.api.v2.GetSystemInfoRequest"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): GetSystemInfoRequest; + + static fromJson(jsonValue: JsonValue, options?: Partial): GetSystemInfoRequest; + + static fromJsonString(jsonString: string, options?: Partial): GetSystemInfoRequest; + + static equals(a: GetSystemInfoRequest | PlainMessage | undefined, b: GetSystemInfoRequest | PlainMessage | undefined): boolean; +} + +/** + * @generated from message memos.api.v2.GetSystemInfoResponse + */ +export declare class GetSystemInfoResponse extends Message { + /** + * @generated from field: memos.api.v2.SystemInfo system_info = 1; + */ + systemInfo?: SystemInfo; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "memos.api.v2.GetSystemInfoResponse"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): GetSystemInfoResponse; + + static fromJson(jsonValue: JsonValue, options?: Partial): GetSystemInfoResponse; + + static fromJsonString(jsonString: string, options?: Partial): GetSystemInfoResponse; + + static equals(a: GetSystemInfoResponse | PlainMessage | undefined, b: GetSystemInfoResponse | PlainMessage | undefined): boolean; +} + diff --git a/web/src/types/proto/api/v2/system_service_pb.js b/web/src/types/proto/api/v2/system_service_pb.js new file mode 100644 index 00000000..6c8fd74e --- /dev/null +++ b/web/src/types/proto/api/v2/system_service_pb.js @@ -0,0 +1,41 @@ +// @generated by protoc-gen-es v1.3.0 +// @generated from file api/v2/system_service.proto (package memos.api.v2, syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import { proto3 } from "@bufbuild/protobuf"; + +/** + * @generated from message memos.api.v2.SystemInfo + */ +export const SystemInfo = proto3.makeMessageType( + "memos.api.v2.SystemInfo", + () => [ + { no: 1, name: "version", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "mode", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 3, name: "allow_registration", kind: "scalar", T: 8 /* ScalarType.BOOL */ }, + { no: 4, name: "disable_password_login", kind: "scalar", T: 8 /* ScalarType.BOOL */ }, + { no: 5, name: "additional_script", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 6, name: "additional_style", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 7, name: "db_size", kind: "scalar", T: 3 /* ScalarType.INT64 */ }, + ], +); + +/** + * @generated from message memos.api.v2.GetSystemInfoRequest + */ +export const GetSystemInfoRequest = proto3.makeMessageType( + "memos.api.v2.GetSystemInfoRequest", + [], +); + +/** + * @generated from message memos.api.v2.GetSystemInfoResponse + */ +export const GetSystemInfoResponse = proto3.makeMessageType( + "memos.api.v2.GetSystemInfoResponse", + () => [ + { no: 1, name: "system_info", kind: "message", T: SystemInfo }, + ], +); + diff --git a/web/src/types/proto/api/v2/tag_service_pb.d.ts b/web/src/types/proto/api/v2/tag_service_pb.d.ts new file mode 100644 index 00000000..fb8aa26a --- /dev/null +++ b/web/src/types/proto/api/v2/tag_service_pb.d.ts @@ -0,0 +1,85 @@ +// @generated by protoc-gen-es v1.3.0 +// @generated from file api/v2/tag_service.proto (package memos.api.v2, 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 memos.api.v2.Tag + */ +export declare class Tag extends Message { + /** + * @generated from field: string name = 1; + */ + name: string; + + /** + * @generated from field: int32 creator_id = 2; + */ + creatorId: number; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "memos.api.v2.Tag"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): Tag; + + static fromJson(jsonValue: JsonValue, options?: Partial): Tag; + + static fromJsonString(jsonString: string, options?: Partial): Tag; + + static equals(a: Tag | PlainMessage | undefined, b: Tag | PlainMessage | undefined): boolean; +} + +/** + * @generated from message memos.api.v2.ListTagsRequest + */ +export declare class ListTagsRequest extends Message { + /** + * @generated from field: int32 creator_id = 1; + */ + creatorId: number; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "memos.api.v2.ListTagsRequest"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): ListTagsRequest; + + static fromJson(jsonValue: JsonValue, options?: Partial): ListTagsRequest; + + static fromJsonString(jsonString: string, options?: Partial): ListTagsRequest; + + static equals(a: ListTagsRequest | PlainMessage | undefined, b: ListTagsRequest | PlainMessage | undefined): boolean; +} + +/** + * @generated from message memos.api.v2.ListTagsResponse + */ +export declare class ListTagsResponse extends Message { + /** + * @generated from field: repeated memos.api.v2.Tag tags = 1; + */ + tags: Tag[]; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "memos.api.v2.ListTagsResponse"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): ListTagsResponse; + + static fromJson(jsonValue: JsonValue, options?: Partial): ListTagsResponse; + + static fromJsonString(jsonString: string, options?: Partial): ListTagsResponse; + + static equals(a: ListTagsResponse | PlainMessage | undefined, b: ListTagsResponse | PlainMessage | undefined): boolean; +} + diff --git a/web/src/types/proto/api/v2/tag_service_pb.js b/web/src/types/proto/api/v2/tag_service_pb.js new file mode 100644 index 00000000..475546b4 --- /dev/null +++ b/web/src/types/proto/api/v2/tag_service_pb.js @@ -0,0 +1,38 @@ +// @generated by protoc-gen-es v1.3.0 +// @generated from file api/v2/tag_service.proto (package memos.api.v2, syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import { proto3 } from "@bufbuild/protobuf"; + +/** + * @generated from message memos.api.v2.Tag + */ +export const Tag = proto3.makeMessageType( + "memos.api.v2.Tag", + () => [ + { no: 1, name: "name", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "creator_id", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, + ], +); + +/** + * @generated from message memos.api.v2.ListTagsRequest + */ +export const ListTagsRequest = proto3.makeMessageType( + "memos.api.v2.ListTagsRequest", + () => [ + { no: 1, name: "creator_id", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, + ], +); + +/** + * @generated from message memos.api.v2.ListTagsResponse + */ +export const ListTagsResponse = proto3.makeMessageType( + "memos.api.v2.ListTagsResponse", + () => [ + { no: 1, name: "tags", kind: "message", T: Tag, repeated: true }, + ], +); + diff --git a/web/src/types/proto/api/v2/user_service_pb.d.ts b/web/src/types/proto/api/v2/user_service_pb.d.ts new file mode 100644 index 00000000..7f01c0c5 --- /dev/null +++ b/web/src/types/proto/api/v2/user_service_pb.d.ts @@ -0,0 +1,268 @@ +// @generated by protoc-gen-es v1.3.0 +// @generated from file api/v2/user_service.proto (package memos.api.v2, syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; +import { Message, proto3 } from "@bufbuild/protobuf"; +import type { RowStatus } from "./common_pb.js"; +import type { Visibility } from "./memo_service_pb.js"; + +/** + * @generated from enum memos.api.v2.Role + */ +export declare enum Role { + /** + * @generated from enum value: ROLE_UNSPECIFIED = 0; + */ + ROLE_UNSPECIFIED = 0, + + /** + * @generated from enum value: HOST = 1; + */ + HOST = 1, + + /** + * @generated from enum value: ADMIN = 2; + */ + ADMIN = 2, + + /** + * @generated from enum value: USER = 3; + */ + USER = 3, +} + +/** + * @generated from message memos.api.v2.User + */ +export declare class User extends Message { + /** + * @generated from field: int32 id = 1; + */ + id: number; + + /** + * @generated from field: memos.api.v2.RowStatus row_status = 2; + */ + rowStatus: RowStatus; + + /** + * @generated from field: int64 created_ts = 3; + */ + createdTs: bigint; + + /** + * @generated from field: int64 updated_ts = 4; + */ + updatedTs: bigint; + + /** + * @generated from field: string username = 5; + */ + username: string; + + /** + * @generated from field: memos.api.v2.Role role = 6; + */ + role: Role; + + /** + * @generated from field: string email = 7; + */ + email: string; + + /** + * @generated from field: string nickname = 8; + */ + nickname: string; + + /** + * @generated from field: string open_id = 9; + */ + openId: string; + + /** + * @generated from field: string avatar_url = 10; + */ + avatarUrl: string; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "memos.api.v2.User"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): User; + + static fromJson(jsonValue: JsonValue, options?: Partial): User; + + static fromJsonString(jsonString: string, options?: Partial): User; + + static equals(a: User | PlainMessage | undefined, b: User | PlainMessage | undefined): boolean; +} + +/** + * @generated from message memos.api.v2.GetUserRequest + */ +export declare class GetUserRequest extends Message { + /** + * @generated from field: string name = 1; + */ + name: string; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "memos.api.v2.GetUserRequest"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): GetUserRequest; + + static fromJson(jsonValue: JsonValue, options?: Partial): GetUserRequest; + + static fromJsonString(jsonString: string, options?: Partial): GetUserRequest; + + static equals(a: GetUserRequest | PlainMessage | undefined, b: GetUserRequest | PlainMessage | undefined): boolean; +} + +/** + * @generated from message memos.api.v2.GetUserResponse + */ +export declare class GetUserResponse extends Message { + /** + * @generated from field: memos.api.v2.User user = 1; + */ + user?: User; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "memos.api.v2.GetUserResponse"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): GetUserResponse; + + static fromJson(jsonValue: JsonValue, options?: Partial): GetUserResponse; + + static fromJsonString(jsonString: string, options?: Partial): GetUserResponse; + + static equals(a: GetUserResponse | PlainMessage | undefined, b: GetUserResponse | PlainMessage | undefined): boolean; +} + +/** + * @generated from message memos.api.v2.UserSetting + */ +export declare class UserSetting extends Message { + /** + * The user id of the setting. + * + * @generated from field: int32 user_id = 1; + */ + userId: number; + + /** + * The key of the setting. + * + * @generated from field: memos.api.v2.UserSetting.Key key = 2; + */ + key: UserSetting_Key; + + /** + * The value of the setting. + * + * @generated from field: memos.api.v2.UserSettingValue value = 3; + */ + value?: UserSettingValue; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "memos.api.v2.UserSetting"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): UserSetting; + + static fromJson(jsonValue: JsonValue, options?: Partial): UserSetting; + + static fromJsonString(jsonString: string, options?: Partial): UserSetting; + + static equals(a: UserSetting | PlainMessage | undefined, b: UserSetting | PlainMessage | undefined): boolean; +} + +/** + * @generated from enum memos.api.v2.UserSetting.Key + */ +export declare enum UserSetting_Key { + /** + * @generated from enum value: KEY_UNSPECIFIED = 0; + */ + KEY_UNSPECIFIED = 0, + + /** + * The preferred locale. + * + * @generated from enum value: LOCALE = 1; + */ + LOCALE = 1, + + /** + * The preferred appearance. + * + * @generated from enum value: APPEARANCE = 2; + */ + APPEARANCE = 2, + + /** + * The default visibility of the memo when creating a new memo. + * + * @generated from enum value: MEMO_VISIBILITY = 3; + */ + MEMO_VISIBILITY = 3, + + /** + * User's telegram id + * + * @generated from enum value: TELEGRAM_USER_ID = 4; + */ + TELEGRAM_USER_ID = 4, +} + +/** + * @generated from message memos.api.v2.UserSettingValue + */ +export declare class UserSettingValue extends Message { + /** + * @generated from oneof memos.api.v2.UserSettingValue.value + */ + value: { + /** + * Default value as a string. + * + * @generated from field: string string_value = 1; + */ + value: string; + case: "stringValue"; + } | { + /** + * @generated from field: memos.api.v2.Visibility visibility_value = 2; + */ + value: Visibility; + case: "visibilityValue"; + } | { case: undefined; value?: undefined }; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "memos.api.v2.UserSettingValue"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): UserSettingValue; + + static fromJson(jsonValue: JsonValue, options?: Partial): UserSettingValue; + + static fromJsonString(jsonString: string, options?: Partial): UserSettingValue; + + static equals(a: UserSettingValue | PlainMessage | undefined, b: UserSettingValue | PlainMessage | undefined): boolean; +} + diff --git a/web/src/types/proto/api/v2/user_service_pb.js b/web/src/types/proto/api/v2/user_service_pb.js new file mode 100644 index 00000000..c08be801 --- /dev/null +++ b/web/src/types/proto/api/v2/user_service_pb.js @@ -0,0 +1,98 @@ +// @generated by protoc-gen-es v1.3.0 +// @generated from file api/v2/user_service.proto (package memos.api.v2, syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import { proto3 } from "@bufbuild/protobuf"; +import { RowStatus } from "./common_pb.js"; +import { Visibility } from "./memo_service_pb.js"; + +/** + * @generated from enum memos.api.v2.Role + */ +export const Role = proto3.makeEnum( + "memos.api.v2.Role", + [ + {no: 0, name: "ROLE_UNSPECIFIED"}, + {no: 1, name: "HOST"}, + {no: 2, name: "ADMIN"}, + {no: 3, name: "USER"}, + ], +); + +/** + * @generated from message memos.api.v2.User + */ +export const User = proto3.makeMessageType( + "memos.api.v2.User", + () => [ + { no: 1, name: "id", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, + { no: 2, name: "row_status", kind: "enum", T: proto3.getEnumType(RowStatus) }, + { no: 3, name: "created_ts", kind: "scalar", T: 3 /* ScalarType.INT64 */ }, + { no: 4, name: "updated_ts", kind: "scalar", T: 3 /* ScalarType.INT64 */ }, + { no: 5, name: "username", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 6, name: "role", kind: "enum", T: proto3.getEnumType(Role) }, + { no: 7, name: "email", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 8, name: "nickname", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 9, name: "open_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 10, name: "avatar_url", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ], +); + +/** + * @generated from message memos.api.v2.GetUserRequest + */ +export const GetUserRequest = proto3.makeMessageType( + "memos.api.v2.GetUserRequest", + () => [ + { no: 1, name: "name", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ], +); + +/** + * @generated from message memos.api.v2.GetUserResponse + */ +export const GetUserResponse = proto3.makeMessageType( + "memos.api.v2.GetUserResponse", + () => [ + { no: 1, name: "user", kind: "message", T: User }, + ], +); + +/** + * @generated from message memos.api.v2.UserSetting + */ +export const UserSetting = proto3.makeMessageType( + "memos.api.v2.UserSetting", + () => [ + { no: 1, name: "user_id", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, + { no: 2, name: "key", kind: "enum", T: proto3.getEnumType(UserSetting_Key) }, + { no: 3, name: "value", kind: "message", T: UserSettingValue }, + ], +); + +/** + * @generated from enum memos.api.v2.UserSetting.Key + */ +export const UserSetting_Key = proto3.makeEnum( + "memos.api.v2.UserSetting.Key", + [ + {no: 0, name: "KEY_UNSPECIFIED"}, + {no: 1, name: "LOCALE"}, + {no: 2, name: "APPEARANCE"}, + {no: 3, name: "MEMO_VISIBILITY"}, + {no: 4, name: "TELEGRAM_USER_ID"}, + ], +); + +/** + * @generated from message memos.api.v2.UserSettingValue + */ +export const UserSettingValue = proto3.makeMessageType( + "memos.api.v2.UserSettingValue", + () => [ + { no: 1, name: "string_value", kind: "scalar", T: 9 /* ScalarType.STRING */, oneof: "value" }, + { no: 2, name: "visibility_value", kind: "enum", T: proto3.getEnumType(Visibility), oneof: "value" }, + ], +); +