@shock-cinema/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 +202 -0
- package/gen/google/protobuf/any.ts +259 -0
- package/gen/google/protobuf/duration.ts +200 -0
- package/gen/google/protobuf/empty.ts +86 -0
- package/gen/google/protobuf/struct.ts +591 -0
- package/gen/google/protobuf/timestamp.ts +230 -0
- package/gen/test.ts +589 -0
- package/package.json +22 -0
- package/proto/auth.proto +16 -0
package/gen/auth.ts
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
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 { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
|
|
9
|
+
|
|
10
|
+
export const protobufPackage = "auth.v1";
|
|
11
|
+
|
|
12
|
+
export interface SendOtpRequest {
|
|
13
|
+
identifier: string;
|
|
14
|
+
type: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface SendOtpResponse {
|
|
18
|
+
ok: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function createBaseSendOtpRequest(): SendOtpRequest {
|
|
22
|
+
return { identifier: "", type: "" };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const SendOtpRequest: MessageFns<SendOtpRequest> = {
|
|
26
|
+
encode(message: SendOtpRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
|
|
27
|
+
if (message.identifier !== "") {
|
|
28
|
+
writer.uint32(10).string(message.identifier);
|
|
29
|
+
}
|
|
30
|
+
if (message.type !== "") {
|
|
31
|
+
writer.uint32(18).string(message.type);
|
|
32
|
+
}
|
|
33
|
+
return writer;
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
decode(input: BinaryReader | Uint8Array, length?: number): SendOtpRequest {
|
|
37
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
38
|
+
const end = length === undefined ? reader.len : reader.pos + length;
|
|
39
|
+
const message = createBaseSendOtpRequest();
|
|
40
|
+
while (reader.pos < end) {
|
|
41
|
+
const tag = reader.uint32();
|
|
42
|
+
switch (tag >>> 3) {
|
|
43
|
+
case 1: {
|
|
44
|
+
if (tag !== 10) {
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
message.identifier = reader.string();
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
case 2: {
|
|
52
|
+
if (tag !== 18) {
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
message.type = reader.string();
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
reader.skip(tag & 7);
|
|
64
|
+
}
|
|
65
|
+
return message;
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
fromJSON(object: any): SendOtpRequest {
|
|
69
|
+
return {
|
|
70
|
+
identifier: isSet(object.identifier) ? globalThis.String(object.identifier) : "",
|
|
71
|
+
type: isSet(object.type) ? globalThis.String(object.type) : "",
|
|
72
|
+
};
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
toJSON(message: SendOtpRequest): unknown {
|
|
76
|
+
const obj: any = {};
|
|
77
|
+
if (message.identifier !== "") {
|
|
78
|
+
obj.identifier = message.identifier;
|
|
79
|
+
}
|
|
80
|
+
if (message.type !== "") {
|
|
81
|
+
obj.type = message.type;
|
|
82
|
+
}
|
|
83
|
+
return obj;
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
create<I extends Exact<DeepPartial<SendOtpRequest>, I>>(base?: I): SendOtpRequest {
|
|
87
|
+
return SendOtpRequest.fromPartial(base ?? ({} as any));
|
|
88
|
+
},
|
|
89
|
+
fromPartial<I extends Exact<DeepPartial<SendOtpRequest>, I>>(object: I): SendOtpRequest {
|
|
90
|
+
const message = createBaseSendOtpRequest();
|
|
91
|
+
message.identifier = object.identifier ?? "";
|
|
92
|
+
message.type = object.type ?? "";
|
|
93
|
+
return message;
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
function createBaseSendOtpResponse(): SendOtpResponse {
|
|
98
|
+
return { ok: false };
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export const SendOtpResponse: MessageFns<SendOtpResponse> = {
|
|
102
|
+
encode(message: SendOtpResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
|
|
103
|
+
if (message.ok !== false) {
|
|
104
|
+
writer.uint32(8).bool(message.ok);
|
|
105
|
+
}
|
|
106
|
+
return writer;
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
decode(input: BinaryReader | Uint8Array, length?: number): SendOtpResponse {
|
|
110
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
111
|
+
const end = length === undefined ? reader.len : reader.pos + length;
|
|
112
|
+
const message = createBaseSendOtpResponse();
|
|
113
|
+
while (reader.pos < end) {
|
|
114
|
+
const tag = reader.uint32();
|
|
115
|
+
switch (tag >>> 3) {
|
|
116
|
+
case 1: {
|
|
117
|
+
if (tag !== 8) {
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
message.ok = reader.bool();
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
reader.skip(tag & 7);
|
|
129
|
+
}
|
|
130
|
+
return message;
|
|
131
|
+
},
|
|
132
|
+
|
|
133
|
+
fromJSON(object: any): SendOtpResponse {
|
|
134
|
+
return { ok: isSet(object.ok) ? globalThis.Boolean(object.ok) : false };
|
|
135
|
+
},
|
|
136
|
+
|
|
137
|
+
toJSON(message: SendOtpResponse): unknown {
|
|
138
|
+
const obj: any = {};
|
|
139
|
+
if (message.ok !== false) {
|
|
140
|
+
obj.ok = message.ok;
|
|
141
|
+
}
|
|
142
|
+
return obj;
|
|
143
|
+
},
|
|
144
|
+
|
|
145
|
+
create<I extends Exact<DeepPartial<SendOtpResponse>, I>>(base?: I): SendOtpResponse {
|
|
146
|
+
return SendOtpResponse.fromPartial(base ?? ({} as any));
|
|
147
|
+
},
|
|
148
|
+
fromPartial<I extends Exact<DeepPartial<SendOtpResponse>, I>>(object: I): SendOtpResponse {
|
|
149
|
+
const message = createBaseSendOtpResponse();
|
|
150
|
+
message.ok = object.ok ?? false;
|
|
151
|
+
return message;
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
export interface AuthService {
|
|
156
|
+
SendOtp(request: SendOtpRequest): Promise<SendOtpResponse>;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export const AuthServiceServiceName = "auth.v1.AuthService";
|
|
160
|
+
export class AuthServiceClientImpl implements AuthService {
|
|
161
|
+
private readonly rpc: Rpc;
|
|
162
|
+
private readonly service: string;
|
|
163
|
+
constructor(rpc: Rpc, opts?: { service?: string }) {
|
|
164
|
+
this.service = opts?.service || AuthServiceServiceName;
|
|
165
|
+
this.rpc = rpc;
|
|
166
|
+
this.SendOtp = this.SendOtp.bind(this);
|
|
167
|
+
}
|
|
168
|
+
SendOtp(request: SendOtpRequest): Promise<SendOtpResponse> {
|
|
169
|
+
const data = SendOtpRequest.encode(request).finish();
|
|
170
|
+
const promise = this.rpc.request(this.service, "SendOtp", data);
|
|
171
|
+
return promise.then((data) => SendOtpResponse.decode(new BinaryReader(data)));
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
interface Rpc {
|
|
176
|
+
request(service: string, method: string, data: Uint8Array): Promise<Uint8Array>;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
180
|
+
|
|
181
|
+
export type DeepPartial<T> = T extends Builtin ? T
|
|
182
|
+
: T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
|
|
183
|
+
: T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
|
|
184
|
+
: T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
|
|
185
|
+
: Partial<T>;
|
|
186
|
+
|
|
187
|
+
type KeysOfUnion<T> = T extends T ? keyof T : never;
|
|
188
|
+
export type Exact<P, I extends P> = P extends Builtin ? P
|
|
189
|
+
: P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };
|
|
190
|
+
|
|
191
|
+
function isSet(value: any): boolean {
|
|
192
|
+
return value !== null && value !== undefined;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export interface MessageFns<T> {
|
|
196
|
+
encode(message: T, writer?: BinaryWriter): BinaryWriter;
|
|
197
|
+
decode(input: BinaryReader | Uint8Array, length?: number): T;
|
|
198
|
+
fromJSON(object: any): T;
|
|
199
|
+
toJSON(message: T): unknown;
|
|
200
|
+
create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;
|
|
201
|
+
fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
|
|
202
|
+
}
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
2
|
+
// versions:
|
|
3
|
+
// protoc-gen-ts_proto v2.10.1
|
|
4
|
+
// protoc v6.33.2
|
|
5
|
+
// source: google/protobuf/any.proto
|
|
6
|
+
|
|
7
|
+
/* eslint-disable */
|
|
8
|
+
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
|
|
9
|
+
|
|
10
|
+
export const protobufPackage = "google.protobuf";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* `Any` contains an arbitrary serialized protocol buffer message along with a
|
|
14
|
+
* URL that describes the type of the serialized message.
|
|
15
|
+
*
|
|
16
|
+
* Protobuf library provides support to pack/unpack Any values in the form
|
|
17
|
+
* of utility functions or additional generated methods of the Any type.
|
|
18
|
+
*
|
|
19
|
+
* Example 1: Pack and unpack a message in C++.
|
|
20
|
+
*
|
|
21
|
+
* Foo foo = ...;
|
|
22
|
+
* Any any;
|
|
23
|
+
* any.PackFrom(foo);
|
|
24
|
+
* ...
|
|
25
|
+
* if (any.UnpackTo(&foo)) {
|
|
26
|
+
* ...
|
|
27
|
+
* }
|
|
28
|
+
*
|
|
29
|
+
* Example 2: Pack and unpack a message in Java.
|
|
30
|
+
*
|
|
31
|
+
* Foo foo = ...;
|
|
32
|
+
* Any any = Any.pack(foo);
|
|
33
|
+
* ...
|
|
34
|
+
* if (any.is(Foo.class)) {
|
|
35
|
+
* foo = any.unpack(Foo.class);
|
|
36
|
+
* }
|
|
37
|
+
* // or ...
|
|
38
|
+
* if (any.isSameTypeAs(Foo.getDefaultInstance())) {
|
|
39
|
+
* foo = any.unpack(Foo.getDefaultInstance());
|
|
40
|
+
* }
|
|
41
|
+
*
|
|
42
|
+
* Example 3: Pack and unpack a message in Python.
|
|
43
|
+
*
|
|
44
|
+
* foo = Foo(...)
|
|
45
|
+
* any = Any()
|
|
46
|
+
* any.Pack(foo)
|
|
47
|
+
* ...
|
|
48
|
+
* if any.Is(Foo.DESCRIPTOR):
|
|
49
|
+
* any.Unpack(foo)
|
|
50
|
+
* ...
|
|
51
|
+
*
|
|
52
|
+
* Example 4: Pack and unpack a message in Go
|
|
53
|
+
*
|
|
54
|
+
* foo := &pb.Foo{...}
|
|
55
|
+
* any, err := anypb.New(foo)
|
|
56
|
+
* if err != nil {
|
|
57
|
+
* ...
|
|
58
|
+
* }
|
|
59
|
+
* ...
|
|
60
|
+
* foo := &pb.Foo{}
|
|
61
|
+
* if err := any.UnmarshalTo(foo); err != nil {
|
|
62
|
+
* ...
|
|
63
|
+
* }
|
|
64
|
+
*
|
|
65
|
+
* The pack methods provided by protobuf library will by default use
|
|
66
|
+
* 'type.googleapis.com/full.type.name' as the type URL and the unpack
|
|
67
|
+
* methods only use the fully qualified type name after the last '/'
|
|
68
|
+
* in the type URL, for example "foo.bar.com/x/y.z" will yield type
|
|
69
|
+
* name "y.z".
|
|
70
|
+
*
|
|
71
|
+
* JSON
|
|
72
|
+
* ====
|
|
73
|
+
* The JSON representation of an `Any` value uses the regular
|
|
74
|
+
* representation of the deserialized, embedded message, with an
|
|
75
|
+
* additional field `@type` which contains the type URL. Example:
|
|
76
|
+
*
|
|
77
|
+
* package google.profile;
|
|
78
|
+
* message Person {
|
|
79
|
+
* string first_name = 1;
|
|
80
|
+
* string last_name = 2;
|
|
81
|
+
* }
|
|
82
|
+
*
|
|
83
|
+
* {
|
|
84
|
+
* "@type": "type.googleapis.com/google.profile.Person",
|
|
85
|
+
* "firstName": <string>,
|
|
86
|
+
* "lastName": <string>
|
|
87
|
+
* }
|
|
88
|
+
*
|
|
89
|
+
* If the embedded message type is well-known and has a custom JSON
|
|
90
|
+
* representation, that representation will be embedded adding a field
|
|
91
|
+
* `value` which holds the custom JSON in addition to the `@type`
|
|
92
|
+
* field. Example (for message [google.protobuf.Duration][]):
|
|
93
|
+
*
|
|
94
|
+
* {
|
|
95
|
+
* "@type": "type.googleapis.com/google.protobuf.Duration",
|
|
96
|
+
* "value": "1.212s"
|
|
97
|
+
* }
|
|
98
|
+
*/
|
|
99
|
+
export interface Any {
|
|
100
|
+
/**
|
|
101
|
+
* A URL/resource name that uniquely identifies the type of the serialized
|
|
102
|
+
* protocol buffer message. This string must contain at least
|
|
103
|
+
* one "/" character. The last segment of the URL's path must represent
|
|
104
|
+
* the fully qualified name of the type (as in
|
|
105
|
+
* `path/google.protobuf.Duration`). The name should be in a canonical form
|
|
106
|
+
* (e.g., leading "." is not accepted).
|
|
107
|
+
*
|
|
108
|
+
* In practice, teams usually precompile into the binary all types that they
|
|
109
|
+
* expect it to use in the context of Any. However, for URLs which use the
|
|
110
|
+
* scheme `http`, `https`, or no scheme, one can optionally set up a type
|
|
111
|
+
* server that maps type URLs to message definitions as follows:
|
|
112
|
+
*
|
|
113
|
+
* * If no scheme is provided, `https` is assumed.
|
|
114
|
+
* * An HTTP GET on the URL must yield a [google.protobuf.Type][]
|
|
115
|
+
* value in binary format, or produce an error.
|
|
116
|
+
* * Applications are allowed to cache lookup results based on the
|
|
117
|
+
* URL, or have them precompiled into a binary to avoid any
|
|
118
|
+
* lookup. Therefore, binary compatibility needs to be preserved
|
|
119
|
+
* on changes to types. (Use versioned type names to manage
|
|
120
|
+
* breaking changes.)
|
|
121
|
+
*
|
|
122
|
+
* Note: this functionality is not currently available in the official
|
|
123
|
+
* protobuf release, and it is not used for type URLs beginning with
|
|
124
|
+
* type.googleapis.com. As of May 2023, there are no widely used type server
|
|
125
|
+
* implementations and no plans to implement one.
|
|
126
|
+
*
|
|
127
|
+
* Schemes other than `http`, `https` (or the empty scheme) might be
|
|
128
|
+
* used with implementation specific semantics.
|
|
129
|
+
*/
|
|
130
|
+
typeUrl: string;
|
|
131
|
+
/** Must be a valid serialized protocol buffer of the above specified type. */
|
|
132
|
+
value: Uint8Array;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function createBaseAny(): Any {
|
|
136
|
+
return { typeUrl: "", value: new Uint8Array(0) };
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export const Any: MessageFns<Any> = {
|
|
140
|
+
encode(message: Any, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
|
|
141
|
+
if (message.typeUrl !== "") {
|
|
142
|
+
writer.uint32(10).string(message.typeUrl);
|
|
143
|
+
}
|
|
144
|
+
if (message.value.length !== 0) {
|
|
145
|
+
writer.uint32(18).bytes(message.value);
|
|
146
|
+
}
|
|
147
|
+
return writer;
|
|
148
|
+
},
|
|
149
|
+
|
|
150
|
+
decode(input: BinaryReader | Uint8Array, length?: number): Any {
|
|
151
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
152
|
+
const end = length === undefined ? reader.len : reader.pos + length;
|
|
153
|
+
const message = createBaseAny();
|
|
154
|
+
while (reader.pos < end) {
|
|
155
|
+
const tag = reader.uint32();
|
|
156
|
+
switch (tag >>> 3) {
|
|
157
|
+
case 1: {
|
|
158
|
+
if (tag !== 10) {
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
message.typeUrl = reader.string();
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
case 2: {
|
|
166
|
+
if (tag !== 18) {
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
message.value = reader.bytes();
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
reader.skip(tag & 7);
|
|
178
|
+
}
|
|
179
|
+
return message;
|
|
180
|
+
},
|
|
181
|
+
|
|
182
|
+
fromJSON(object: any): Any {
|
|
183
|
+
return {
|
|
184
|
+
typeUrl: isSet(object.typeUrl) ? globalThis.String(object.typeUrl) : "",
|
|
185
|
+
value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array(0),
|
|
186
|
+
};
|
|
187
|
+
},
|
|
188
|
+
|
|
189
|
+
toJSON(message: Any): unknown {
|
|
190
|
+
const obj: any = {};
|
|
191
|
+
if (message.typeUrl !== "") {
|
|
192
|
+
obj.typeUrl = message.typeUrl;
|
|
193
|
+
}
|
|
194
|
+
if (message.value.length !== 0) {
|
|
195
|
+
obj.value = base64FromBytes(message.value);
|
|
196
|
+
}
|
|
197
|
+
return obj;
|
|
198
|
+
},
|
|
199
|
+
|
|
200
|
+
create<I extends Exact<DeepPartial<Any>, I>>(base?: I): Any {
|
|
201
|
+
return Any.fromPartial(base ?? ({} as any));
|
|
202
|
+
},
|
|
203
|
+
fromPartial<I extends Exact<DeepPartial<Any>, I>>(object: I): Any {
|
|
204
|
+
const message = createBaseAny();
|
|
205
|
+
message.typeUrl = object.typeUrl ?? "";
|
|
206
|
+
message.value = object.value ?? new Uint8Array(0);
|
|
207
|
+
return message;
|
|
208
|
+
},
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
function bytesFromBase64(b64: string): Uint8Array {
|
|
212
|
+
if ((globalThis as any).Buffer) {
|
|
213
|
+
return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
|
|
214
|
+
} else {
|
|
215
|
+
const bin = globalThis.atob(b64);
|
|
216
|
+
const arr = new Uint8Array(bin.length);
|
|
217
|
+
for (let i = 0; i < bin.length; ++i) {
|
|
218
|
+
arr[i] = bin.charCodeAt(i);
|
|
219
|
+
}
|
|
220
|
+
return arr;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function base64FromBytes(arr: Uint8Array): string {
|
|
225
|
+
if ((globalThis as any).Buffer) {
|
|
226
|
+
return globalThis.Buffer.from(arr).toString("base64");
|
|
227
|
+
} else {
|
|
228
|
+
const bin: string[] = [];
|
|
229
|
+
arr.forEach((byte) => {
|
|
230
|
+
bin.push(globalThis.String.fromCharCode(byte));
|
|
231
|
+
});
|
|
232
|
+
return globalThis.btoa(bin.join(""));
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
237
|
+
|
|
238
|
+
export type DeepPartial<T> = T extends Builtin ? T
|
|
239
|
+
: T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
|
|
240
|
+
: T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
|
|
241
|
+
: T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
|
|
242
|
+
: Partial<T>;
|
|
243
|
+
|
|
244
|
+
type KeysOfUnion<T> = T extends T ? keyof T : never;
|
|
245
|
+
export type Exact<P, I extends P> = P extends Builtin ? P
|
|
246
|
+
: P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };
|
|
247
|
+
|
|
248
|
+
function isSet(value: any): boolean {
|
|
249
|
+
return value !== null && value !== undefined;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export interface MessageFns<T> {
|
|
253
|
+
encode(message: T, writer?: BinaryWriter): BinaryWriter;
|
|
254
|
+
decode(input: BinaryReader | Uint8Array, length?: number): T;
|
|
255
|
+
fromJSON(object: any): T;
|
|
256
|
+
toJSON(message: T): unknown;
|
|
257
|
+
create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;
|
|
258
|
+
fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
|
|
259
|
+
}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
2
|
+
// versions:
|
|
3
|
+
// protoc-gen-ts_proto v2.10.1
|
|
4
|
+
// protoc v6.33.2
|
|
5
|
+
// source: google/protobuf/duration.proto
|
|
6
|
+
|
|
7
|
+
/* eslint-disable */
|
|
8
|
+
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
|
|
9
|
+
|
|
10
|
+
export const protobufPackage = "google.protobuf";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A Duration represents a signed, fixed-length span of time represented
|
|
14
|
+
* as a count of seconds and fractions of seconds at nanosecond
|
|
15
|
+
* resolution. It is independent of any calendar and concepts like "day"
|
|
16
|
+
* or "month". It is related to Timestamp in that the difference between
|
|
17
|
+
* two Timestamp values is a Duration and it can be added or subtracted
|
|
18
|
+
* from a Timestamp. Range is approximately +-10,000 years.
|
|
19
|
+
*
|
|
20
|
+
* # Examples
|
|
21
|
+
*
|
|
22
|
+
* Example 1: Compute Duration from two Timestamps in pseudo code.
|
|
23
|
+
*
|
|
24
|
+
* Timestamp start = ...;
|
|
25
|
+
* Timestamp end = ...;
|
|
26
|
+
* Duration duration = ...;
|
|
27
|
+
*
|
|
28
|
+
* duration.seconds = end.seconds - start.seconds;
|
|
29
|
+
* duration.nanos = end.nanos - start.nanos;
|
|
30
|
+
*
|
|
31
|
+
* if (duration.seconds < 0 && duration.nanos > 0) {
|
|
32
|
+
* duration.seconds += 1;
|
|
33
|
+
* duration.nanos -= 1000000000;
|
|
34
|
+
* } else if (duration.seconds > 0 && duration.nanos < 0) {
|
|
35
|
+
* duration.seconds -= 1;
|
|
36
|
+
* duration.nanos += 1000000000;
|
|
37
|
+
* }
|
|
38
|
+
*
|
|
39
|
+
* Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.
|
|
40
|
+
*
|
|
41
|
+
* Timestamp start = ...;
|
|
42
|
+
* Duration duration = ...;
|
|
43
|
+
* Timestamp end = ...;
|
|
44
|
+
*
|
|
45
|
+
* end.seconds = start.seconds + duration.seconds;
|
|
46
|
+
* end.nanos = start.nanos + duration.nanos;
|
|
47
|
+
*
|
|
48
|
+
* if (end.nanos < 0) {
|
|
49
|
+
* end.seconds -= 1;
|
|
50
|
+
* end.nanos += 1000000000;
|
|
51
|
+
* } else if (end.nanos >= 1000000000) {
|
|
52
|
+
* end.seconds += 1;
|
|
53
|
+
* end.nanos -= 1000000000;
|
|
54
|
+
* }
|
|
55
|
+
*
|
|
56
|
+
* Example 3: Compute Duration from datetime.timedelta in Python.
|
|
57
|
+
*
|
|
58
|
+
* td = datetime.timedelta(days=3, minutes=10)
|
|
59
|
+
* duration = Duration()
|
|
60
|
+
* duration.FromTimedelta(td)
|
|
61
|
+
*
|
|
62
|
+
* # JSON Mapping
|
|
63
|
+
*
|
|
64
|
+
* In JSON format, the Duration type is encoded as a string rather than an
|
|
65
|
+
* object, where the string ends in the suffix "s" (indicating seconds) and
|
|
66
|
+
* is preceded by the number of seconds, with nanoseconds expressed as
|
|
67
|
+
* fractional seconds. For example, 3 seconds with 0 nanoseconds should be
|
|
68
|
+
* encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should
|
|
69
|
+
* be expressed in JSON format as "3.000000001s", and 3 seconds and 1
|
|
70
|
+
* microsecond should be expressed in JSON format as "3.000001s".
|
|
71
|
+
*/
|
|
72
|
+
export interface Duration {
|
|
73
|
+
/**
|
|
74
|
+
* Signed seconds of the span of time. Must be from -315,576,000,000
|
|
75
|
+
* to +315,576,000,000 inclusive. Note: these bounds are computed from:
|
|
76
|
+
* 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
|
|
77
|
+
*/
|
|
78
|
+
seconds: number;
|
|
79
|
+
/**
|
|
80
|
+
* Signed fractions of a second at nanosecond resolution of the span
|
|
81
|
+
* of time. Durations less than one second are represented with a 0
|
|
82
|
+
* `seconds` field and a positive or negative `nanos` field. For durations
|
|
83
|
+
* of one second or more, a non-zero value for the `nanos` field must be
|
|
84
|
+
* of the same sign as the `seconds` field. Must be from -999,999,999
|
|
85
|
+
* to +999,999,999 inclusive.
|
|
86
|
+
*/
|
|
87
|
+
nanos: number;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function createBaseDuration(): Duration {
|
|
91
|
+
return { seconds: 0, nanos: 0 };
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export const Duration: MessageFns<Duration> = {
|
|
95
|
+
encode(message: Duration, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
|
|
96
|
+
if (message.seconds !== 0) {
|
|
97
|
+
writer.uint32(8).int64(message.seconds);
|
|
98
|
+
}
|
|
99
|
+
if (message.nanos !== 0) {
|
|
100
|
+
writer.uint32(16).int32(message.nanos);
|
|
101
|
+
}
|
|
102
|
+
return writer;
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
decode(input: BinaryReader | Uint8Array, length?: number): Duration {
|
|
106
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
107
|
+
const end = length === undefined ? reader.len : reader.pos + length;
|
|
108
|
+
const message = createBaseDuration();
|
|
109
|
+
while (reader.pos < end) {
|
|
110
|
+
const tag = reader.uint32();
|
|
111
|
+
switch (tag >>> 3) {
|
|
112
|
+
case 1: {
|
|
113
|
+
if (tag !== 8) {
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
message.seconds = longToNumber(reader.int64());
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
case 2: {
|
|
121
|
+
if (tag !== 16) {
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
message.nanos = reader.int32();
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
reader.skip(tag & 7);
|
|
133
|
+
}
|
|
134
|
+
return message;
|
|
135
|
+
},
|
|
136
|
+
|
|
137
|
+
fromJSON(object: any): Duration {
|
|
138
|
+
return {
|
|
139
|
+
seconds: isSet(object.seconds) ? globalThis.Number(object.seconds) : 0,
|
|
140
|
+
nanos: isSet(object.nanos) ? globalThis.Number(object.nanos) : 0,
|
|
141
|
+
};
|
|
142
|
+
},
|
|
143
|
+
|
|
144
|
+
toJSON(message: Duration): unknown {
|
|
145
|
+
const obj: any = {};
|
|
146
|
+
if (message.seconds !== 0) {
|
|
147
|
+
obj.seconds = Math.round(message.seconds);
|
|
148
|
+
}
|
|
149
|
+
if (message.nanos !== 0) {
|
|
150
|
+
obj.nanos = Math.round(message.nanos);
|
|
151
|
+
}
|
|
152
|
+
return obj;
|
|
153
|
+
},
|
|
154
|
+
|
|
155
|
+
create<I extends Exact<DeepPartial<Duration>, I>>(base?: I): Duration {
|
|
156
|
+
return Duration.fromPartial(base ?? ({} as any));
|
|
157
|
+
},
|
|
158
|
+
fromPartial<I extends Exact<DeepPartial<Duration>, I>>(object: I): Duration {
|
|
159
|
+
const message = createBaseDuration();
|
|
160
|
+
message.seconds = object.seconds ?? 0;
|
|
161
|
+
message.nanos = object.nanos ?? 0;
|
|
162
|
+
return message;
|
|
163
|
+
},
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
167
|
+
|
|
168
|
+
export type DeepPartial<T> = T extends Builtin ? T
|
|
169
|
+
: T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
|
|
170
|
+
: T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
|
|
171
|
+
: T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
|
|
172
|
+
: Partial<T>;
|
|
173
|
+
|
|
174
|
+
type KeysOfUnion<T> = T extends T ? keyof T : never;
|
|
175
|
+
export type Exact<P, I extends P> = P extends Builtin ? P
|
|
176
|
+
: P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };
|
|
177
|
+
|
|
178
|
+
function longToNumber(int64: { toString(): string }): number {
|
|
179
|
+
const num = globalThis.Number(int64.toString());
|
|
180
|
+
if (num > globalThis.Number.MAX_SAFE_INTEGER) {
|
|
181
|
+
throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
|
|
182
|
+
}
|
|
183
|
+
if (num < globalThis.Number.MIN_SAFE_INTEGER) {
|
|
184
|
+
throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");
|
|
185
|
+
}
|
|
186
|
+
return num;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function isSet(value: any): boolean {
|
|
190
|
+
return value !== null && value !== undefined;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export interface MessageFns<T> {
|
|
194
|
+
encode(message: T, writer?: BinaryWriter): BinaryWriter;
|
|
195
|
+
decode(input: BinaryReader | Uint8Array, length?: number): T;
|
|
196
|
+
fromJSON(object: any): T;
|
|
197
|
+
toJSON(message: T): unknown;
|
|
198
|
+
create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;
|
|
199
|
+
fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
|
|
200
|
+
}
|