@astromonacinema/contracts 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/gen/auth.ts ADDED
@@ -0,0 +1,107 @@
1
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
+ // versions:
3
+ // protoc-gen-ts_proto v2.10.1
4
+ // protoc v3.21.12
5
+ // source: auth.proto
6
+
7
+ /* eslint-disable */
8
+ import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices";
9
+ import { wrappers } from "protobufjs";
10
+ import { Observable } from "rxjs";
11
+ import { Any } from "./google/protobuf/any";
12
+ import { Struct } from "./google/protobuf/struct";
13
+ import { Timestamp } from "./google/protobuf/timestamp";
14
+
15
+ export const protobufPackage = "auth.v1";
16
+
17
+ /** Перечисление статусов */
18
+ export enum Status {
19
+ /** STATUS_UNKNOWN - STATUS_UNKNOWN - значение по умолчанию (0): всегда первое значение в enum должно быть 0 */
20
+ STATUS_UNKNOWN = 0,
21
+ /** STATUS_ACTIVE - STATUS_ACTIVE - целочисленная константа (1): активный статус */
22
+ STATUS_ACTIVE = 1,
23
+ /** STATUS_BANNED - STATUS_BANNED - целочисленная константа (2): заблокированный статус */
24
+ STATUS_BANNED = 2,
25
+ UNRECOGNIZED = -1,
26
+ }
27
+
28
+ export interface SendOtpRequest {
29
+ identifier: string;
30
+ type: string;
31
+ }
32
+
33
+ export interface SendOtpResponse {
34
+ ok: boolean;
35
+ }
36
+
37
+ export interface UserSession {
38
+ id: string;
39
+ /** временное значение */
40
+ createdAt:
41
+ | Timestamp
42
+ | undefined;
43
+ /** структура данных JSON формата */
44
+ data:
45
+ | { [key: string]: any }
46
+ | undefined;
47
+ /** структура данных любого формата */
48
+ anyData: Any | undefined;
49
+ }
50
+
51
+ /** Сообщение профиля пользователя */
52
+ export interface UserProfile {
53
+ /** id - строка (string): текстовый идентификатор переменной длины, UTF-8 */
54
+ id: string;
55
+ /** age - 32-битное целое число со знаком (int32): диапазон от -2,147,483,648 до 2,147,483,647 */
56
+ age: number;
57
+ /** rating - число двойной точности (double): 64-битное число с плавающей точкой, IEEE 754 */
58
+ rating: number;
59
+ /** verified - булево значение (bool): true или false, занимает 1 байт */
60
+ verified: boolean;
61
+ /** roles - повторяющееся поле строк (repeated string): массив строковых значений, может быть пустым или содержать множество элементов */
62
+ roles: string[];
63
+ /** meta - словарь строка-строка (map<string, string>): ключ и значение - строки, неупорядоченная коллекция пар ключ-значение */
64
+ meta: { [key: string]: string };
65
+ /** status - перечисление (Status): одно из предопределенных значений enum Status, хранится как int32 */
66
+ status: Status;
67
+ /** phone - строка (string): номер телефона, будет установлен только если email не задан */
68
+ phone?:
69
+ | string
70
+ | undefined;
71
+ /** email - строка (string): электронная почта, будет установлен только если phone не задан */
72
+ email?: string | undefined;
73
+ }
74
+
75
+ export interface UserProfile_MetaEntry {
76
+ key: string;
77
+ value: string;
78
+ }
79
+
80
+ export const AUTH_V1_PACKAGE_NAME = "auth.v1";
81
+
82
+ wrappers[".google.protobuf.Struct"] = { fromObject: Struct.wrap, toObject: Struct.unwrap } as any;
83
+
84
+ export interface AuthServiceClient {
85
+ sendOtp(request: SendOtpRequest): Observable<SendOtpResponse>;
86
+ }
87
+
88
+ export interface AuthServiceController {
89
+ sendOtp(request: SendOtpRequest): Promise<SendOtpResponse> | Observable<SendOtpResponse> | SendOtpResponse;
90
+ }
91
+
92
+ export function AuthServiceControllerMethods() {
93
+ return function (constructor: Function) {
94
+ const grpcMethods: string[] = ["sendOtp"];
95
+ for (const method of grpcMethods) {
96
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
97
+ GrpcMethod("AuthService", method)(constructor.prototype[method], method, descriptor);
98
+ }
99
+ const grpcStreamMethods: string[] = [];
100
+ for (const method of grpcStreamMethods) {
101
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
102
+ GrpcStreamMethod("AuthService", method)(constructor.prototype[method], method, descriptor);
103
+ }
104
+ };
105
+ }
106
+
107
+ export const AUTH_SERVICE_NAME = "AuthService";
@@ -0,0 +1,129 @@
1
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
+ // versions:
3
+ // protoc-gen-ts_proto v2.10.1
4
+ // protoc v3.21.12
5
+ // source: google/protobuf/any.proto
6
+
7
+ /* eslint-disable */
8
+
9
+ export const protobufPackage = "google.protobuf";
10
+
11
+ /**
12
+ * `Any` contains an arbitrary serialized protocol buffer message along with a
13
+ * URL that describes the type of the serialized message.
14
+ *
15
+ * Protobuf library provides support to pack/unpack Any values in the form
16
+ * of utility functions or additional generated methods of the Any type.
17
+ *
18
+ * Example 1: Pack and unpack a message in C++.
19
+ *
20
+ * Foo foo = ...;
21
+ * Any any;
22
+ * any.PackFrom(foo);
23
+ * ...
24
+ * if (any.UnpackTo(&foo)) {
25
+ * ...
26
+ * }
27
+ *
28
+ * Example 2: Pack and unpack a message in Java.
29
+ *
30
+ * Foo foo = ...;
31
+ * Any any = Any.pack(foo);
32
+ * ...
33
+ * if (any.is(Foo.class)) {
34
+ * foo = any.unpack(Foo.class);
35
+ * }
36
+ *
37
+ * Example 3: Pack and unpack a message in Python.
38
+ *
39
+ * foo = Foo(...)
40
+ * any = Any()
41
+ * any.Pack(foo)
42
+ * ...
43
+ * if any.Is(Foo.DESCRIPTOR):
44
+ * any.Unpack(foo)
45
+ * ...
46
+ *
47
+ * Example 4: Pack and unpack a message in Go
48
+ *
49
+ * foo := &pb.Foo{...}
50
+ * any, err := anypb.New(foo)
51
+ * if err != nil {
52
+ * ...
53
+ * }
54
+ * ...
55
+ * foo := &pb.Foo{}
56
+ * if err := any.UnmarshalTo(foo); err != nil {
57
+ * ...
58
+ * }
59
+ *
60
+ * The pack methods provided by protobuf library will by default use
61
+ * 'type.googleapis.com/full.type.name' as the type URL and the unpack
62
+ * methods only use the fully qualified type name after the last '/'
63
+ * in the type URL, for example "foo.bar.com/x/y.z" will yield type
64
+ * name "y.z".
65
+ *
66
+ * JSON
67
+ *
68
+ * The JSON representation of an `Any` value uses the regular
69
+ * representation of the deserialized, embedded message, with an
70
+ * additional field `@type` which contains the type URL. Example:
71
+ *
72
+ * package google.profile;
73
+ * message Person {
74
+ * string first_name = 1;
75
+ * string last_name = 2;
76
+ * }
77
+ *
78
+ * {
79
+ * "@type": "type.googleapis.com/google.profile.Person",
80
+ * "firstName": <string>,
81
+ * "lastName": <string>
82
+ * }
83
+ *
84
+ * If the embedded message type is well-known and has a custom JSON
85
+ * representation, that representation will be embedded adding a field
86
+ * `value` which holds the custom JSON in addition to the `@type`
87
+ * field. Example (for message [google.protobuf.Duration][]):
88
+ *
89
+ * {
90
+ * "@type": "type.googleapis.com/google.protobuf.Duration",
91
+ * "value": "1.212s"
92
+ * }
93
+ */
94
+ export interface Any {
95
+ /**
96
+ * A URL/resource name that uniquely identifies the type of the serialized
97
+ * protocol buffer message. This string must contain at least
98
+ * one "/" character. The last segment of the URL's path must represent
99
+ * the fully qualified name of the type (as in
100
+ * `path/google.protobuf.Duration`). The name should be in a canonical form
101
+ * (e.g., leading "." is not accepted).
102
+ *
103
+ * In practice, teams usually precompile into the binary all types that they
104
+ * expect it to use in the context of Any. However, for URLs which use the
105
+ * scheme `http`, `https`, or no scheme, one can optionally set up a type
106
+ * server that maps type URLs to message definitions as follows:
107
+ *
108
+ * * If no scheme is provided, `https` is assumed.
109
+ * * An HTTP GET on the URL must yield a [google.protobuf.Type][]
110
+ * value in binary format, or produce an error.
111
+ * * Applications are allowed to cache lookup results based on the
112
+ * URL, or have them precompiled into a binary to avoid any
113
+ * lookup. Therefore, binary compatibility needs to be preserved
114
+ * on changes to types. (Use versioned type names to manage
115
+ * breaking changes.)
116
+ *
117
+ * Note: this functionality is not currently available in the official
118
+ * protobuf release, and it is not used for type URLs beginning with
119
+ * type.googleapis.com.
120
+ *
121
+ * Schemes other than `http`, `https` (or the empty scheme) might be
122
+ * used with implementation specific semantics.
123
+ */
124
+ typeUrl: string;
125
+ /** Must be a valid serialized protocol buffer of the above specified type. */
126
+ value: Uint8Array;
127
+ }
128
+
129
+ export const GOOGLE_PROTOBUF_PACKAGE_NAME = "google.protobuf";
@@ -0,0 +1,197 @@
1
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
+ // versions:
3
+ // protoc-gen-ts_proto v2.10.1
4
+ // protoc v3.21.12
5
+ // source: google/protobuf/struct.proto
6
+
7
+ /* eslint-disable */
8
+ import { wrappers } from "protobufjs";
9
+
10
+ export const protobufPackage = "google.protobuf";
11
+
12
+ /**
13
+ * `NullValue` is a singleton enumeration to represent the null value for the
14
+ * `Value` type union.
15
+ *
16
+ * The JSON representation for `NullValue` is JSON `null`.
17
+ */
18
+ export enum NullValue {
19
+ /** NULL_VALUE - Null value. */
20
+ NULL_VALUE = 0,
21
+ UNRECOGNIZED = -1,
22
+ }
23
+
24
+ /**
25
+ * `Struct` represents a structured data value, consisting of fields
26
+ * which map to dynamically typed values. In some languages, `Struct`
27
+ * might be supported by a native representation. For example, in
28
+ * scripting languages like JS a struct is represented as an
29
+ * object. The details of that representation are described together
30
+ * with the proto support for the language.
31
+ *
32
+ * The JSON representation for `Struct` is JSON object.
33
+ */
34
+ export interface Struct {
35
+ /** Unordered map of dynamically typed values. */
36
+ fields: { [key: string]: any | undefined };
37
+ }
38
+
39
+ export interface Struct_FieldsEntry {
40
+ key: string;
41
+ value: any | undefined;
42
+ }
43
+
44
+ /**
45
+ * `Value` represents a dynamically typed value which can be either
46
+ * null, a number, a string, a boolean, a recursive struct value, or a
47
+ * list of values. A producer of value is expected to set one of these
48
+ * variants. Absence of any variant indicates an error.
49
+ *
50
+ * The JSON representation for `Value` is JSON value.
51
+ */
52
+ export interface Value {
53
+ /** Represents a null value. */
54
+ nullValue?:
55
+ | NullValue
56
+ | undefined;
57
+ /** Represents a double value. */
58
+ numberValue?:
59
+ | number
60
+ | undefined;
61
+ /** Represents a string value. */
62
+ stringValue?:
63
+ | string
64
+ | undefined;
65
+ /** Represents a boolean value. */
66
+ boolValue?:
67
+ | boolean
68
+ | undefined;
69
+ /** Represents a structured value. */
70
+ structValue?:
71
+ | { [key: string]: any }
72
+ | undefined;
73
+ /** Represents a repeated `Value`. */
74
+ listValue?: Array<any> | undefined;
75
+ }
76
+
77
+ /**
78
+ * `ListValue` is a wrapper around a repeated field of values.
79
+ *
80
+ * The JSON representation for `ListValue` is JSON array.
81
+ */
82
+ export interface ListValue {
83
+ /** Repeated field of dynamically typed values. */
84
+ values: any[];
85
+ }
86
+
87
+ export const GOOGLE_PROTOBUF_PACKAGE_NAME = "google.protobuf";
88
+
89
+ function createBaseStruct(): Struct {
90
+ return { fields: {} };
91
+ }
92
+
93
+ export const Struct: MessageFns<Struct> & StructWrapperFns = {
94
+ wrap(object: { [key: string]: any } | undefined): Struct {
95
+ const struct = createBaseStruct();
96
+
97
+ if (object !== undefined) {
98
+ for (const key of globalThis.Object.keys(object)) {
99
+ struct.fields[key] = Value.wrap(object[key]);
100
+ }
101
+ }
102
+ return struct;
103
+ },
104
+
105
+ unwrap(message: Struct): { [key: string]: any } {
106
+ const object: { [key: string]: any } = {};
107
+ if (message.fields) {
108
+ for (const key of globalThis.Object.keys(message.fields)) {
109
+ object[key] = Value.unwrap(message.fields[key]);
110
+ }
111
+ }
112
+ return object;
113
+ },
114
+ };
115
+
116
+ function createBaseValue(): Value {
117
+ return {};
118
+ }
119
+
120
+ export const Value: MessageFns<Value> & AnyValueWrapperFns = {
121
+ wrap(value: any): Value {
122
+ const result = {} as any;
123
+ if (value === null) {
124
+ result.nullValue = NullValue.NULL_VALUE;
125
+ } else if (typeof value === "boolean") {
126
+ result.boolValue = value;
127
+ } else if (typeof value === "number") {
128
+ result.numberValue = value;
129
+ } else if (typeof value === "string") {
130
+ result.stringValue = value;
131
+ } else if (globalThis.Array.isArray(value)) {
132
+ result.listValue = ListValue.wrap(value);
133
+ } else if (typeof value === "object") {
134
+ result.structValue = Struct.wrap(value);
135
+ } else if (typeof value !== "undefined") {
136
+ throw new globalThis.Error("Unsupported any value type: " + typeof value);
137
+ }
138
+ return result;
139
+ },
140
+
141
+ unwrap(message: any): string | number | boolean | Object | null | Array<any> | undefined {
142
+ if (message?.hasOwnProperty("stringValue") && message.stringValue !== undefined) {
143
+ return message.stringValue;
144
+ } else if (message?.hasOwnProperty("numberValue") && message?.numberValue !== undefined) {
145
+ return message.numberValue;
146
+ } else if (message?.hasOwnProperty("boolValue") && message?.boolValue !== undefined) {
147
+ return message.boolValue;
148
+ } else if (message?.hasOwnProperty("structValue") && message?.structValue !== undefined) {
149
+ return Struct.unwrap(message.structValue as any);
150
+ } else if (message?.hasOwnProperty("listValue") && message?.listValue !== undefined) {
151
+ return ListValue.unwrap(message.listValue);
152
+ } else if (message?.hasOwnProperty("nullValue") && message?.nullValue !== undefined) {
153
+ return null;
154
+ }
155
+ return undefined;
156
+ },
157
+ };
158
+
159
+ function createBaseListValue(): ListValue {
160
+ return { values: [] };
161
+ }
162
+
163
+ export const ListValue: MessageFns<ListValue> & ListValueWrapperFns = {
164
+ wrap(array: Array<any> | undefined): ListValue {
165
+ const result = createBaseListValue();
166
+ result.values = (array ?? []).map(Value.wrap);
167
+ return result;
168
+ },
169
+
170
+ unwrap(message: ListValue): Array<any> {
171
+ if (message?.hasOwnProperty("values") && globalThis.Array.isArray(message.values)) {
172
+ return message.values.map(Value.unwrap);
173
+ } else {
174
+ return message as any;
175
+ }
176
+ },
177
+ };
178
+
179
+ wrappers[".google.protobuf.Struct"] = { fromObject: Struct.wrap, toObject: Struct.unwrap } as any;
180
+
181
+ export interface MessageFns<T> {
182
+ }
183
+
184
+ export interface StructWrapperFns {
185
+ wrap(object: { [key: string]: any } | undefined): Struct;
186
+ unwrap(message: Struct): { [key: string]: any };
187
+ }
188
+
189
+ export interface AnyValueWrapperFns {
190
+ wrap(value: any): Value;
191
+ unwrap(message: any): string | number | boolean | Object | null | Array<any> | undefined;
192
+ }
193
+
194
+ export interface ListValueWrapperFns {
195
+ wrap(array: Array<any> | undefined): ListValue;
196
+ unwrap(message: ListValue): Array<any>;
197
+ }
@@ -0,0 +1,118 @@
1
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
+ // versions:
3
+ // protoc-gen-ts_proto v2.10.1
4
+ // protoc v3.21.12
5
+ // source: google/protobuf/timestamp.proto
6
+
7
+ /* eslint-disable */
8
+
9
+ export const protobufPackage = "google.protobuf";
10
+
11
+ /**
12
+ * A Timestamp represents a point in time independent of any time zone or local
13
+ * calendar, encoded as a count of seconds and fractions of seconds at
14
+ * nanosecond resolution. The count is relative to an epoch at UTC midnight on
15
+ * January 1, 1970, in the proleptic Gregorian calendar which extends the
16
+ * Gregorian calendar backwards to year one.
17
+ *
18
+ * All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap
19
+ * second table is needed for interpretation, using a [24-hour linear
20
+ * smear](https://developers.google.com/time/smear).
21
+ *
22
+ * The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By
23
+ * restricting to that range, we ensure that we can convert to and from [RFC
24
+ * 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.
25
+ *
26
+ * # Examples
27
+ *
28
+ * Example 1: Compute Timestamp from POSIX `time()`.
29
+ *
30
+ * Timestamp timestamp;
31
+ * timestamp.set_seconds(time(NULL));
32
+ * timestamp.set_nanos(0);
33
+ *
34
+ * Example 2: Compute Timestamp from POSIX `gettimeofday()`.
35
+ *
36
+ * struct timeval tv;
37
+ * gettimeofday(&tv, NULL);
38
+ *
39
+ * Timestamp timestamp;
40
+ * timestamp.set_seconds(tv.tv_sec);
41
+ * timestamp.set_nanos(tv.tv_usec * 1000);
42
+ *
43
+ * Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
44
+ *
45
+ * FILETIME ft;
46
+ * GetSystemTimeAsFileTime(&ft);
47
+ * UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
48
+ *
49
+ * // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
50
+ * // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
51
+ * Timestamp timestamp;
52
+ * timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
53
+ * timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
54
+ *
55
+ * Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
56
+ *
57
+ * long millis = System.currentTimeMillis();
58
+ *
59
+ * Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
60
+ * .setNanos((int) ((millis % 1000) * 1000000)).build();
61
+ *
62
+ * Example 5: Compute Timestamp from Java `Instant.now()`.
63
+ *
64
+ * Instant now = Instant.now();
65
+ *
66
+ * Timestamp timestamp =
67
+ * Timestamp.newBuilder().setSeconds(now.getEpochSecond())
68
+ * .setNanos(now.getNano()).build();
69
+ *
70
+ * Example 6: Compute Timestamp from current time in Python.
71
+ *
72
+ * timestamp = Timestamp()
73
+ * timestamp.GetCurrentTime()
74
+ *
75
+ * # JSON Mapping
76
+ *
77
+ * In JSON format, the Timestamp type is encoded as a string in the
78
+ * [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
79
+ * format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"
80
+ * where {year} is always expressed using four digits while {month}, {day},
81
+ * {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
82
+ * seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
83
+ * are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
84
+ * is required. A proto3 JSON serializer should always use UTC (as indicated by
85
+ * "Z") when printing the Timestamp type and a proto3 JSON parser should be
86
+ * able to accept both UTC and other timezones (as indicated by an offset).
87
+ *
88
+ * For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
89
+ * 01:30 UTC on January 15, 2017.
90
+ *
91
+ * In JavaScript, one can convert a Date object to this format using the
92
+ * standard
93
+ * [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
94
+ * method. In Python, a standard `datetime.datetime` object can be converted
95
+ * to this format using
96
+ * [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with
97
+ * the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use
98
+ * the Joda Time's [`ISODateTimeFormat.dateTime()`](
99
+ * http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D
100
+ * ) to obtain a formatter capable of generating timestamps in this format.
101
+ */
102
+ export interface Timestamp {
103
+ /**
104
+ * Represents seconds of UTC time since Unix epoch
105
+ * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
106
+ * 9999-12-31T23:59:59Z inclusive.
107
+ */
108
+ seconds: number;
109
+ /**
110
+ * Non-negative fractions of a second at nanosecond resolution. Negative
111
+ * second values with fractions must still have non-negative nanos values
112
+ * that count forward in time. Must be from 0 to 999,999,999
113
+ * inclusive.
114
+ */
115
+ nanos: number;
116
+ }
117
+
118
+ export const GOOGLE_PROTOBUF_PACKAGE_NAME = "google.protobuf";
package/package.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "@astromonacinema/contracts",
3
+ "version": "1.0.0",
4
+ "license": "MIT",
5
+ "description": "Protobuf contracts for microservices",
6
+ "scripts": {
7
+ "generate": "protoc -I ./proto ./proto/*.proto --ts_proto_out=./gen --ts_proto_opt=nestJs=true,package=omit"
8
+ },
9
+ "files": [
10
+ "proto",
11
+ "gen"
12
+ ],
13
+ "publishConfig": {
14
+ "access": "public"
15
+ },
16
+ "dependencies": {
17
+ "@nestjs/microservices": "^11.1.11",
18
+ "protobufjs": "^8.0.0",
19
+ "rxjs": "^7.8.2",
20
+ "ts-proto": "^2.10.1"
21
+ }
22
+ }
@@ -0,0 +1,75 @@
1
+ syntax = "proto3";
2
+
3
+ package auth.v1;
4
+
5
+ import "google/protobuf/timestamp.proto";
6
+ import "google/protobuf/struct.proto";
7
+ import "google/protobuf/any.proto";
8
+
9
+ service AuthService {
10
+ rpc SendOtp (SendOtpRequest) returns (SendOtpResponse);
11
+ }
12
+
13
+ message SendOtpRequest {
14
+ string identifier = 1;
15
+ string type = 2;
16
+ }
17
+
18
+ message SendOtpResponse {
19
+ bool ok = 1;
20
+ }
21
+
22
+
23
+ /* Для пояснений типов */
24
+
25
+ message UserSession {
26
+ string id = 1;
27
+ google.protobuf.Timestamp created_at = 3; // временное значение
28
+ google.protobuf.Struct data = 4; // структура данных JSON формата
29
+ google.protobuf.Any anyData = 5; // структура данных любого формата
30
+ }
31
+
32
+ // Сообщение профиля пользователя
33
+ message UserProfile {
34
+ // id - строка (string): текстовый идентификатор переменной длины, UTF-8
35
+ string id = 1;
36
+
37
+ // age - 32-битное целое число со знаком (int32): диапазон от -2,147,483,648 до 2,147,483,647
38
+ int32 age = 2;
39
+
40
+ // rating - число двойной точности (double): 64-битное число с плавающей точкой, IEEE 754
41
+ double rating = 3;
42
+
43
+ // verified - булево значение (bool): true или false, занимает 1 байт
44
+ bool verified = 4;
45
+
46
+ // roles - повторяющееся поле строк (repeated string): массив строковых значений, может быть пустым или содержать множество элементов
47
+ repeated string roles = 5;
48
+
49
+ // meta - словарь строка-строка (map<string, string>): ключ и значение - строки, неупорядоченная коллекция пар ключ-значение
50
+ map<string, string> meta = 6;
51
+
52
+ // status - перечисление (Status): одно из предопределенных значений enum Status, хранится как int32
53
+ Status status = 7;
54
+
55
+ // contact - oneof (выбор одного из): позволяет задать только одно поле из группы, взаимоисключающие варианты контакта
56
+ oneof contact {
57
+ // phone - строка (string): номер телефона, будет установлен только если email не задан
58
+ string phone = 8;
59
+
60
+ // email - строка (string): электронная почта, будет установлен только если phone не задан
61
+ string email = 9;
62
+ }
63
+ }
64
+
65
+ // Перечисление статусов
66
+ enum Status {
67
+ // STATUS_UNKNOWN - значение по умолчанию (0): всегда первое значение в enum должно быть 0
68
+ STATUS_UNKNOWN = 0;
69
+
70
+ // STATUS_ACTIVE - целочисленная константа (1): активный статус
71
+ STATUS_ACTIVE = 1;
72
+
73
+ // STATUS_BANNED - целочисленная константа (2): заблокированный статус
74
+ STATUS_BANNED = 2;
75
+ }