@nexiolab/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,55 @@
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 { Observable } from "rxjs";
10
+
11
+ export const protobufPackage = "auth.v1";
12
+
13
+ export interface SendOtpRequest {
14
+ identifier: string;
15
+ type: string;
16
+ }
17
+
18
+ export interface SendOtpResponse {
19
+ ok: boolean;
20
+ }
21
+
22
+ export const AUTH_V1_PACKAGE_NAME = "auth.v1";
23
+
24
+ /** AuthService provides authentication related operations */
25
+
26
+ export interface AuthServiceClient {
27
+ /** SendOtp sends an OTP to the user */
28
+
29
+ sendOtp(request: SendOtpRequest): Observable<SendOtpResponse>;
30
+ }
31
+
32
+ /** AuthService provides authentication related operations */
33
+
34
+ export interface AuthServiceController {
35
+ /** SendOtp sends an OTP to the user */
36
+
37
+ sendOtp(request: SendOtpRequest): Promise<SendOtpResponse> | Observable<SendOtpResponse> | SendOtpResponse;
38
+ }
39
+
40
+ export function AuthServiceControllerMethods() {
41
+ return function (constructor: Function) {
42
+ const grpcMethods: string[] = ["sendOtp"];
43
+ for (const method of grpcMethods) {
44
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
45
+ GrpcMethod("AuthService", method)(constructor.prototype[method], method, descriptor);
46
+ }
47
+ const grpcStreamMethods: string[] = [];
48
+ for (const method of grpcStreamMethods) {
49
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
50
+ GrpcStreamMethod("AuthService", method)(constructor.prototype[method], method, descriptor);
51
+ }
52
+ };
53
+ }
54
+
55
+ export const AUTH_SERVICE_NAME = "AuthService";
package/gen/example.ts ADDED
@@ -0,0 +1,90 @@
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: example.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 { Duration } from "./google/protobuf/duration";
13
+ import { Empty } from "./google/protobuf/empty";
14
+ import { Struct } from "./google/protobuf/struct";
15
+ import { Timestamp } from "./google/protobuf/timestamp";
16
+
17
+ export const protobufPackage = "example.v1";
18
+
19
+ export enum Status {
20
+ STATUS_UNKNOWN = 0,
21
+ STATUS_ACTIVE = 1,
22
+ STATUS_BANNED = 2,
23
+ UNRECOGNIZED = -1,
24
+ }
25
+
26
+ export interface SendOtpRequest {
27
+ identifier: string;
28
+ type: string;
29
+ }
30
+
31
+ export interface SendOtpResponse {
32
+ }
33
+
34
+ export interface UserSession {
35
+ id: string;
36
+ createdAt: Timestamp | undefined;
37
+ duration: Duration | undefined;
38
+ data: { [key: string]: any } | undefined;
39
+ any: Any | undefined;
40
+ }
41
+
42
+ export interface UserProfile {
43
+ id: string;
44
+ age: number;
45
+ rating: number;
46
+ verified: boolean;
47
+ roles: string[];
48
+ meta: { [key: string]: string };
49
+ status: Status;
50
+ phone?: string | undefined;
51
+ email?: string | undefined;
52
+ }
53
+
54
+ export interface UserProfile_MetaEntry {
55
+ key: string;
56
+ value: string;
57
+ }
58
+
59
+ export const EXAMPLE_V1_PACKAGE_NAME = "example.v1";
60
+
61
+ wrappers[".google.protobuf.Struct"] = { fromObject: Struct.wrap, toObject: Struct.unwrap } as any;
62
+
63
+ export interface AuthServiceClient {
64
+ sendOtp(request: SendOtpRequest): Observable<SendOtpResponse>;
65
+
66
+ ping(request: Empty): Observable<SendOtpResponse>;
67
+ }
68
+
69
+ export interface AuthServiceController {
70
+ sendOtp(request: SendOtpRequest): Promise<SendOtpResponse> | Observable<SendOtpResponse> | SendOtpResponse;
71
+
72
+ ping(request: Empty): Promise<SendOtpResponse> | Observable<SendOtpResponse> | SendOtpResponse;
73
+ }
74
+
75
+ export function AuthServiceControllerMethods() {
76
+ return function (constructor: Function) {
77
+ const grpcMethods: string[] = ["sendOtp", "ping"];
78
+ for (const method of grpcMethods) {
79
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
80
+ GrpcMethod("AuthService", method)(constructor.prototype[method], method, descriptor);
81
+ }
82
+ const grpcStreamMethods: string[] = [];
83
+ for (const method of grpcStreamMethods) {
84
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
85
+ GrpcStreamMethod("AuthService", method)(constructor.prototype[method], method, descriptor);
86
+ }
87
+ };
88
+ }
89
+
90
+ 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,89 @@
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/duration.proto
6
+
7
+ /* eslint-disable */
8
+
9
+ export const protobufPackage = "google.protobuf";
10
+
11
+ /**
12
+ * A Duration represents a signed, fixed-length span of time represented
13
+ * as a count of seconds and fractions of seconds at nanosecond
14
+ * resolution. It is independent of any calendar and concepts like "day"
15
+ * or "month". It is related to Timestamp in that the difference between
16
+ * two Timestamp values is a Duration and it can be added or subtracted
17
+ * from a Timestamp. Range is approximately +-10,000 years.
18
+ *
19
+ * # Examples
20
+ *
21
+ * Example 1: Compute Duration from two Timestamps in pseudo code.
22
+ *
23
+ * Timestamp start = ...;
24
+ * Timestamp end = ...;
25
+ * Duration duration = ...;
26
+ *
27
+ * duration.seconds = end.seconds - start.seconds;
28
+ * duration.nanos = end.nanos - start.nanos;
29
+ *
30
+ * if (duration.seconds < 0 && duration.nanos > 0) {
31
+ * duration.seconds += 1;
32
+ * duration.nanos -= 1000000000;
33
+ * } else if (duration.seconds > 0 && duration.nanos < 0) {
34
+ * duration.seconds -= 1;
35
+ * duration.nanos += 1000000000;
36
+ * }
37
+ *
38
+ * Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.
39
+ *
40
+ * Timestamp start = ...;
41
+ * Duration duration = ...;
42
+ * Timestamp end = ...;
43
+ *
44
+ * end.seconds = start.seconds + duration.seconds;
45
+ * end.nanos = start.nanos + duration.nanos;
46
+ *
47
+ * if (end.nanos < 0) {
48
+ * end.seconds -= 1;
49
+ * end.nanos += 1000000000;
50
+ * } else if (end.nanos >= 1000000000) {
51
+ * end.seconds += 1;
52
+ * end.nanos -= 1000000000;
53
+ * }
54
+ *
55
+ * Example 3: Compute Duration from datetime.timedelta in Python.
56
+ *
57
+ * td = datetime.timedelta(days=3, minutes=10)
58
+ * duration = Duration()
59
+ * duration.FromTimedelta(td)
60
+ *
61
+ * # JSON Mapping
62
+ *
63
+ * In JSON format, the Duration type is encoded as a string rather than an
64
+ * object, where the string ends in the suffix "s" (indicating seconds) and
65
+ * is preceded by the number of seconds, with nanoseconds expressed as
66
+ * fractional seconds. For example, 3 seconds with 0 nanoseconds should be
67
+ * encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should
68
+ * be expressed in JSON format as "3.000000001s", and 3 seconds and 1
69
+ * microsecond should be expressed in JSON format as "3.000001s".
70
+ */
71
+ export interface Duration {
72
+ /**
73
+ * Signed seconds of the span of time. Must be from -315,576,000,000
74
+ * to +315,576,000,000 inclusive. Note: these bounds are computed from:
75
+ * 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
76
+ */
77
+ seconds: number;
78
+ /**
79
+ * Signed fractions of a second at nanosecond resolution of the span
80
+ * of time. Durations less than one second are represented with a 0
81
+ * `seconds` field and a positive or negative `nanos` field. For durations
82
+ * of one second or more, a non-zero value for the `nanos` field must be
83
+ * of the same sign as the `seconds` field. Must be from -999,999,999
84
+ * to +999,999,999 inclusive.
85
+ */
86
+ nanos: number;
87
+ }
88
+
89
+ export const GOOGLE_PROTOBUF_PACKAGE_NAME = "google.protobuf";
@@ -0,0 +1,23 @@
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/empty.proto
6
+
7
+ /* eslint-disable */
8
+
9
+ export const protobufPackage = "google.protobuf";
10
+
11
+ /**
12
+ * A generic empty message that you can re-use to avoid defining duplicated
13
+ * empty messages in your APIs. A typical example is to use it as the request
14
+ * or the response type of an API method. For instance:
15
+ *
16
+ * service Foo {
17
+ * rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
18
+ * }
19
+ */
20
+ export interface Empty {
21
+ }
22
+
23
+ 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,20 @@
1
+ {
2
+ "name": "@nexiolab/contracts",
3
+ "version": "1.0.0",
4
+ "description": "Protobuf definitions and generated TypeScript types",
5
+ "scripts": {
6
+ "generate": "protoc -I ./proto ./proto/*.proto --ts_proto_out=./gen --ts_proto_opt=nestJs=true,package=omit"
7
+ },
8
+ "files": [
9
+ "proto",
10
+ "gen"
11
+ ],
12
+ "publishConfig": {
13
+ "access": "public"
14
+ },
15
+ "dependencies": {
16
+ "@nestjs/microservices": "^11.1.11",
17
+ "rxjs": "^7.8.2",
18
+ "ts-proto": "^2.10.1"
19
+ }
20
+ }
@@ -0,0 +1,18 @@
1
+ syntax="proto3";
2
+
3
+ package auth.v1;
4
+
5
+ // AuthService provides authentication related operations
6
+ service AuthService {
7
+ // SendOtp sends an OTP to the user
8
+ rpc SendOtp (SendOtpRequest) returns (SendOtpResponse);
9
+ }
10
+
11
+ message SendOtpRequest {
12
+ string identifier = 1;
13
+ string type = 2;
14
+ }
15
+
16
+ message SendOtpResponse {
17
+ bool ok = 1;
18
+ }
@@ -0,0 +1,54 @@
1
+ syntax="proto3";
2
+
3
+ package example.v1;
4
+
5
+ import "google/protobuf/empty.proto";
6
+ import "google/protobuf/timestamp.proto";
7
+ import "google/protobuf/duration.proto";
8
+ import "google/protobuf/struct.proto";
9
+ import "google/protobuf/any.proto";
10
+
11
+ service AuthService {
12
+ rpc SendOtp (SendOtpRequest) returns (SendOtpResponse);
13
+
14
+ rpc Ping(google.protobuf.Empty) returns (SendOtpResponse);
15
+ }
16
+
17
+ message SendOtpRequest {
18
+ string identifier = 1;
19
+ string type = 2;
20
+ }
21
+
22
+ message SendOtpResponse {
23
+
24
+ }
25
+
26
+ message UserSession {
27
+ string id = 1;
28
+ google.protobuf.Timestamp created_at = 2;
29
+ google.protobuf.Duration duration = 3;
30
+ google.protobuf.Struct data = 4;
31
+ google.protobuf.Any any = 5;
32
+ }
33
+
34
+ // [fieldNumber: 2][writeType: string][value: email]
35
+
36
+ message UserProfile {
37
+ string id = 1;
38
+ int32 age = 2;
39
+ double rating = 3;
40
+ bool verified = 4;
41
+ repeated string roles = 5;
42
+ map<string, string> meta = 6;
43
+ Status status = 7;
44
+ oneof contact {
45
+ string phone = 8;
46
+ string email = 9;
47
+ }
48
+ }
49
+
50
+ enum Status {
51
+ STATUS_UNKNOWN = 0;
52
+ STATUS_ACTIVE = 1;
53
+ STATUS_BANNED = 2;
54
+ }