@streamr/dht 102.0.0-beta.0 → 102.0.0-beta.1
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/dist/package.json +15 -16
- package/dist/src/connection/ConnectionManager.js +18 -8
- package/dist/src/connection/ConnectionManager.js.map +1 -1
- package/dist/src/connection/Handshaker.d.ts +1 -1
- package/dist/src/connection/Handshaker.js +9 -5
- package/dist/src/connection/Handshaker.js.map +1 -1
- package/dist/src/connection/ManagedConnection.js +17 -7
- package/dist/src/connection/ManagedConnection.js.map +1 -1
- package/dist/src/connection/connectivityChecker.js +20 -10
- package/dist/src/connection/connectivityChecker.js.map +1 -1
- package/dist/src/connection/connectivityRequestHandler.js +3 -3
- package/dist/src/connection/connectivityRequestHandler.js.map +1 -1
- package/dist/src/connection/simulator/Simulator.js +3 -2
- package/dist/src/connection/simulator/Simulator.js.map +1 -1
- package/dist/src/connection/simulator/pings.d.ts +1 -1
- package/dist/src/connection/simulator/pings.js +3 -3
- package/dist/src/connection/simulator/pings.js.map +1 -1
- package/dist/src/connection/webrtc/NodeWebrtcConnection.js +0 -2
- package/dist/src/connection/webrtc/NodeWebrtcConnection.js.map +1 -1
- package/dist/src/connection/webrtc/WebrtcConnector.js +19 -9
- package/dist/src/connection/webrtc/WebrtcConnector.js.map +1 -1
- package/dist/src/connection/webrtc/iceServerAsString.js +1 -2
- package/dist/src/connection/webrtc/iceServerAsString.js.map +1 -1
- package/dist/src/connection/websocket/AbstractWebsocketClientConnection.d.ts +0 -2
- package/dist/src/connection/websocket/WebsocketClientConnectorRpcLocal.d.ts +0 -1
- package/dist/src/connection/websocket/WebsocketServerConnection.d.ts +0 -1
- package/dist/src/connection/websocket/WebsocketServerConnector.js +28 -18
- package/dist/src/connection/websocket/WebsocketServerConnector.js.map +1 -1
- package/dist/src/dht/DhtNode.d.ts +1 -0
- package/dist/src/dht/DhtNode.js +3 -2
- package/dist/src/dht/DhtNode.js.map +1 -1
- package/dist/src/dht/DhtNodeRpcLocal.d.ts +1 -1
- package/dist/src/dht/PeerManager.d.ts +2 -1
- package/dist/src/dht/PeerManager.js +2 -1
- package/dist/src/dht/PeerManager.js.map +1 -1
- package/dist/src/dht/contact/SortedContactList.js +1 -1
- package/dist/src/dht/contact/SortedContactList.js.map +1 -1
- package/dist/src/dht/discovery/DiscoverySession.d.ts +0 -1
- package/dist/src/dht/discovery/PeerDiscovery.d.ts +0 -1
- package/dist/src/dht/discovery/RingDiscoverySession.d.ts +0 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationManager.d.ts +2 -2
- package/dist/src/dht/routing/DuplicateDetector.js.map +1 -1
- package/dist/src/dht/routing/RoutingSession.js +2 -2
- package/dist/src/dht/routing/RoutingSession.js.map +1 -1
- package/dist/src/dht/routing/RoutingTablesCache.d.ts +1 -1
- package/dist/src/dht/store/LocalDataStore.js +1 -1
- package/dist/src/dht/store/LocalDataStore.js.map +1 -1
- package/dist/src/dht/store/StoreManager.d.ts +1 -1
- package/dist/src/dht/store/StoreRpcLocal.d.ts +1 -1
- package/dist/src/helpers/AddressTools.js +2 -3
- package/dist/src/helpers/AddressTools.js.map +1 -1
- package/dist/src/helpers/debugHelpers.js +2 -2
- package/dist/src/helpers/debugHelpers.js.map +1 -1
- package/dist/src/helpers/protoClasses.d.ts +1 -1
- package/dist/src/helpers/protoClasses.js.map +1 -1
- package/dist/src/helpers/protoToString.js +1 -2
- package/dist/src/helpers/protoToString.js.map +1 -1
- package/dist/src/helpers/version.d.ts +1 -1
- package/dist/src/helpers/version.js +4 -4
- package/dist/src/helpers/version.js.map +1 -1
- package/eslint.config.mjs +12 -0
- package/jest.config.ts +12 -0
- package/package.json +15 -16
- package/protos/DhtRpc.proto +6 -4
- package/src/connection/ConnectionManager.ts +2 -2
- package/src/connection/Handshaker.ts +15 -11
- package/src/connection/connectivityChecker.ts +4 -4
- package/src/connection/connectivityRequestHandler.ts +3 -3
- package/src/connection/simulator/Simulator.ts +4 -3
- package/src/connection/simulator/pings.ts +1 -1
- package/src/connection/webrtc/NodeWebrtcConnection.ts +0 -2
- package/src/connection/webrtc/WebrtcConnector.ts +3 -3
- package/src/connection/websocket/WebsocketServerConnector.ts +17 -13
- package/src/dht/DhtNode.ts +8 -3
- package/src/dht/DhtNodeRpcLocal.ts +1 -1
- package/src/dht/PeerManager.ts +4 -2
- package/src/dht/contact/SortedContactList.ts +1 -1
- package/src/dht/recursive-operation/RecursiveOperationManager.ts +1 -1
- package/src/dht/routing/DuplicateDetector.ts +1 -1
- package/src/dht/routing/RoutingSession.ts +2 -2
- package/src/dht/routing/RoutingTablesCache.ts +1 -1
- package/src/dht/store/LocalDataStore.ts +1 -1
- package/src/dht/store/StoreManager.ts +1 -1
- package/src/dht/store/StoreRpcLocal.ts +1 -1
- package/src/helpers/protoClasses.ts +1 -1
- package/src/helpers/version.ts +2 -2
- package/test/benchmark/Find.test.ts +3 -3
- package/test/benchmark/KademliaCorrectness.test.ts +2 -2
- package/test/benchmark/RingCorrectness.test.ts +3 -3
- package/test/benchmark/hybrid-network-simulation/RingContactList.test.ts +2 -2
- package/test/end-to-end/WebsocketConnectionRequest.test.ts +2 -2
- package/test/end-to-end/memory-leak.test.ts +2 -2
- package/test/integration/ConnectionLocking.test.ts +32 -22
- package/test/integration/ConnectionManager.test.ts +3 -3
- package/test/integration/ConnectivityChecking.test.ts +1 -1
- package/test/integration/DhtNode.test.ts +2 -2
- package/test/integration/GeoIpConnectivityChecking.test.ts +6 -6
- package/test/integration/Layer1-scale.test.ts +1 -1
- package/test/integration/RouteMessage.test.ts +4 -4
- package/test/integration/SimultaneousConnections.test.ts +9 -9
- package/test/integration/StoreOnDhtWithThreeNodes.test.ts +1 -1
- package/test/integration/StoreOnDhtWithTwoNodes.test.ts +3 -3
- package/test/integration/StoreRpcRemote.test.ts +1 -1
- package/test/integration/WebrtcConnectionManagement.test.ts +0 -28
- package/test/integration/WebrtcConnectorRpc.test.ts +5 -5
- package/test/integration/WebsocketConnectionManagement.test.ts +3 -3
- package/test/integration/rpc-connections-over-webrtc.test.ts +8 -43
- package/test/unit/AutoCertifierClientFacade.test.ts +6 -6
- package/test/unit/Handshaker.test.ts +1 -1
- package/test/unit/ListeningRpcCommunicator.test.ts +3 -3
- package/test/unit/PeerManager.test.ts +2 -2
- package/test/unit/RecursiveOperationSession.test.ts +2 -2
- package/test/unit/RoutingSession.test.ts +7 -0
- package/test/unit/SortedContactList.test.ts +3 -3
- package/test/unit/StoreManager.test.ts +2 -2
- package/test/unit/connectivityRequestHandler.test.ts +5 -5
- package/test/unit/customMatchers.test.ts +18 -0
- package/test/unit/getClosestNodes.test.ts +1 -1
- package/test/unit/version.test.ts +9 -9
- package/test/utils/customMatchers.ts +6 -6
- package/test/utils/topology.ts +0 -1
- package/test/utils/utils.ts +2 -2
- package/.eslintignore +0 -5
- package/.eslintrc +0 -3
- package/dist/generated/google/protobuf/any.d.ts +0 -180
- package/dist/generated/google/protobuf/any.js +0 -155
- package/dist/generated/google/protobuf/any.js.map +0 -1
- package/dist/generated/google/protobuf/empty.d.ts +0 -31
- package/dist/generated/google/protobuf/empty.js +0 -32
- package/dist/generated/google/protobuf/empty.js.map +0 -1
- package/dist/generated/google/protobuf/timestamp.d.ts +0 -155
- package/dist/generated/google/protobuf/timestamp.js +0 -136
- package/dist/generated/google/protobuf/timestamp.js.map +0 -1
- package/dist/generated/packages/dht/protos/DhtRpc.client.d.ts +0 -361
- package/dist/generated/packages/dht/protos/DhtRpc.client.js +0 -285
- package/dist/generated/packages/dht/protos/DhtRpc.client.js.map +0 -1
- package/dist/generated/packages/dht/protos/DhtRpc.d.ts +0 -991
- package/dist/generated/packages/dht/protos/DhtRpc.js +0 -675
- package/dist/generated/packages/dht/protos/DhtRpc.js.map +0 -1
- package/dist/generated/packages/dht/protos/DhtRpc.server.d.ts +0 -162
- package/dist/generated/packages/dht/protos/DhtRpc.server.js +0 -3
- package/dist/generated/packages/dht/protos/DhtRpc.server.js.map +0 -1
- package/dist/generated/packages/proto-rpc/protos/ProtoRpc.d.ts +0 -87
- package/dist/generated/packages/proto-rpc/protos/ProtoRpc.js +0 -66
- package/dist/generated/packages/proto-rpc/protos/ProtoRpc.js.map +0 -1
- package/generated/google/protobuf/any.ts +0 -326
- package/generated/google/protobuf/empty.ts +0 -81
- package/generated/google/protobuf/timestamp.ts +0 -287
- package/generated/packages/dht/protos/DhtRpc.client.ts +0 -419
- package/generated/packages/dht/protos/DhtRpc.server.ts +0 -165
- package/generated/packages/dht/protos/DhtRpc.ts +0 -1266
- package/generated/packages/proto-rpc/protos/ProtoRpc.ts +0 -108
- package/jest.config.js +0 -5
|
@@ -1,326 +0,0 @@
|
|
|
1
|
-
// @generated by protobuf-ts 2.9.4 with parameter server_generic,generate_dependencies,long_type_number
|
|
2
|
-
// @generated from protobuf file "google/protobuf/any.proto" (package "google.protobuf", syntax proto3)
|
|
3
|
-
// tslint:disable
|
|
4
|
-
//
|
|
5
|
-
// Protocol Buffers - Google's data interchange format
|
|
6
|
-
// Copyright 2008 Google Inc. All rights reserved.
|
|
7
|
-
// https://developers.google.com/protocol-buffers/
|
|
8
|
-
//
|
|
9
|
-
// Redistribution and use in source and binary forms, with or without
|
|
10
|
-
// modification, are permitted provided that the following conditions are
|
|
11
|
-
// met:
|
|
12
|
-
//
|
|
13
|
-
// * Redistributions of source code must retain the above copyright
|
|
14
|
-
// notice, this list of conditions and the following disclaimer.
|
|
15
|
-
// * Redistributions in binary form must reproduce the above
|
|
16
|
-
// copyright notice, this list of conditions and the following disclaimer
|
|
17
|
-
// in the documentation and/or other materials provided with the
|
|
18
|
-
// distribution.
|
|
19
|
-
// * Neither the name of Google Inc. nor the names of its
|
|
20
|
-
// contributors may be used to endorse or promote products derived from
|
|
21
|
-
// this software without specific prior written permission.
|
|
22
|
-
//
|
|
23
|
-
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
24
|
-
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
25
|
-
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
26
|
-
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
27
|
-
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
28
|
-
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
29
|
-
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
30
|
-
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
31
|
-
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
32
|
-
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
33
|
-
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
34
|
-
//
|
|
35
|
-
import type { BinaryWriteOptions } from "@protobuf-ts/runtime";
|
|
36
|
-
import type { IBinaryWriter } from "@protobuf-ts/runtime";
|
|
37
|
-
import { WireType } from "@protobuf-ts/runtime";
|
|
38
|
-
import type { IBinaryReader } from "@protobuf-ts/runtime";
|
|
39
|
-
import { UnknownFieldHandler } from "@protobuf-ts/runtime";
|
|
40
|
-
import type { PartialMessage } from "@protobuf-ts/runtime";
|
|
41
|
-
import { reflectionMergePartial } from "@protobuf-ts/runtime";
|
|
42
|
-
import { isJsonObject } from "@protobuf-ts/runtime";
|
|
43
|
-
import { typeofJsonValue } from "@protobuf-ts/runtime";
|
|
44
|
-
import type { JsonValue } from "@protobuf-ts/runtime";
|
|
45
|
-
import { jsonWriteOptions } from "@protobuf-ts/runtime";
|
|
46
|
-
import type { JsonReadOptions } from "@protobuf-ts/runtime";
|
|
47
|
-
import type { JsonWriteOptions } from "@protobuf-ts/runtime";
|
|
48
|
-
import type { BinaryReadOptions } from "@protobuf-ts/runtime";
|
|
49
|
-
import type { IMessageType } from "@protobuf-ts/runtime";
|
|
50
|
-
import { MessageType } from "@protobuf-ts/runtime";
|
|
51
|
-
/**
|
|
52
|
-
* `Any` contains an arbitrary serialized protocol buffer message along with a
|
|
53
|
-
* URL that describes the type of the serialized message.
|
|
54
|
-
*
|
|
55
|
-
* Protobuf library provides support to pack/unpack Any values in the form
|
|
56
|
-
* of utility functions or additional generated methods of the Any type.
|
|
57
|
-
*
|
|
58
|
-
* Example 1: Pack and unpack a message in C++.
|
|
59
|
-
*
|
|
60
|
-
* Foo foo = ...;
|
|
61
|
-
* Any any;
|
|
62
|
-
* any.PackFrom(foo);
|
|
63
|
-
* ...
|
|
64
|
-
* if (any.UnpackTo(&foo)) {
|
|
65
|
-
* ...
|
|
66
|
-
* }
|
|
67
|
-
*
|
|
68
|
-
* Example 2: Pack and unpack a message in Java.
|
|
69
|
-
*
|
|
70
|
-
* Foo foo = ...;
|
|
71
|
-
* Any any = Any.pack(foo);
|
|
72
|
-
* ...
|
|
73
|
-
* if (any.is(Foo.class)) {
|
|
74
|
-
* foo = any.unpack(Foo.class);
|
|
75
|
-
* }
|
|
76
|
-
* // or ...
|
|
77
|
-
* if (any.isSameTypeAs(Foo.getDefaultInstance())) {
|
|
78
|
-
* foo = any.unpack(Foo.getDefaultInstance());
|
|
79
|
-
* }
|
|
80
|
-
*
|
|
81
|
-
* Example 3: Pack and unpack a message in Python.
|
|
82
|
-
*
|
|
83
|
-
* foo = Foo(...)
|
|
84
|
-
* any = Any()
|
|
85
|
-
* any.Pack(foo)
|
|
86
|
-
* ...
|
|
87
|
-
* if any.Is(Foo.DESCRIPTOR):
|
|
88
|
-
* any.Unpack(foo)
|
|
89
|
-
* ...
|
|
90
|
-
*
|
|
91
|
-
* Example 4: Pack and unpack a message in Go
|
|
92
|
-
*
|
|
93
|
-
* foo := &pb.Foo{...}
|
|
94
|
-
* any, err := anypb.New(foo)
|
|
95
|
-
* if err != nil {
|
|
96
|
-
* ...
|
|
97
|
-
* }
|
|
98
|
-
* ...
|
|
99
|
-
* foo := &pb.Foo{}
|
|
100
|
-
* if err := any.UnmarshalTo(foo); err != nil {
|
|
101
|
-
* ...
|
|
102
|
-
* }
|
|
103
|
-
*
|
|
104
|
-
* The pack methods provided by protobuf library will by default use
|
|
105
|
-
* 'type.googleapis.com/full.type.name' as the type URL and the unpack
|
|
106
|
-
* methods only use the fully qualified type name after the last '/'
|
|
107
|
-
* in the type URL, for example "foo.bar.com/x/y.z" will yield type
|
|
108
|
-
* name "y.z".
|
|
109
|
-
*
|
|
110
|
-
* JSON
|
|
111
|
-
* ====
|
|
112
|
-
* The JSON representation of an `Any` value uses the regular
|
|
113
|
-
* representation of the deserialized, embedded message, with an
|
|
114
|
-
* additional field `@type` which contains the type URL. Example:
|
|
115
|
-
*
|
|
116
|
-
* package google.profile;
|
|
117
|
-
* message Person {
|
|
118
|
-
* string first_name = 1;
|
|
119
|
-
* string last_name = 2;
|
|
120
|
-
* }
|
|
121
|
-
*
|
|
122
|
-
* {
|
|
123
|
-
* "@type": "type.googleapis.com/google.profile.Person",
|
|
124
|
-
* "firstName": <string>,
|
|
125
|
-
* "lastName": <string>
|
|
126
|
-
* }
|
|
127
|
-
*
|
|
128
|
-
* If the embedded message type is well-known and has a custom JSON
|
|
129
|
-
* representation, that representation will be embedded adding a field
|
|
130
|
-
* `value` which holds the custom JSON in addition to the `@type`
|
|
131
|
-
* field. Example (for message [google.protobuf.Duration][]):
|
|
132
|
-
*
|
|
133
|
-
* {
|
|
134
|
-
* "@type": "type.googleapis.com/google.protobuf.Duration",
|
|
135
|
-
* "value": "1.212s"
|
|
136
|
-
* }
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
* @generated from protobuf message google.protobuf.Any
|
|
140
|
-
*/
|
|
141
|
-
export interface Any {
|
|
142
|
-
/**
|
|
143
|
-
* A URL/resource name that uniquely identifies the type of the serialized
|
|
144
|
-
* protocol buffer message. This string must contain at least
|
|
145
|
-
* one "/" character. The last segment of the URL's path must represent
|
|
146
|
-
* the fully qualified name of the type (as in
|
|
147
|
-
* `path/google.protobuf.Duration`). The name should be in a canonical form
|
|
148
|
-
* (e.g., leading "." is not accepted).
|
|
149
|
-
*
|
|
150
|
-
* In practice, teams usually precompile into the binary all types that they
|
|
151
|
-
* expect it to use in the context of Any. However, for URLs which use the
|
|
152
|
-
* scheme `http`, `https`, or no scheme, one can optionally set up a type
|
|
153
|
-
* server that maps type URLs to message definitions as follows:
|
|
154
|
-
*
|
|
155
|
-
* * If no scheme is provided, `https` is assumed.
|
|
156
|
-
* * An HTTP GET on the URL must yield a [google.protobuf.Type][]
|
|
157
|
-
* value in binary format, or produce an error.
|
|
158
|
-
* * Applications are allowed to cache lookup results based on the
|
|
159
|
-
* URL, or have them precompiled into a binary to avoid any
|
|
160
|
-
* lookup. Therefore, binary compatibility needs to be preserved
|
|
161
|
-
* on changes to types. (Use versioned type names to manage
|
|
162
|
-
* breaking changes.)
|
|
163
|
-
*
|
|
164
|
-
* Note: this functionality is not currently available in the official
|
|
165
|
-
* protobuf release, and it is not used for type URLs beginning with
|
|
166
|
-
* type.googleapis.com. As of May 2023, there are no widely used type server
|
|
167
|
-
* implementations and no plans to implement one.
|
|
168
|
-
*
|
|
169
|
-
* Schemes other than `http`, `https` (or the empty scheme) might be
|
|
170
|
-
* used with implementation specific semantics.
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
* @generated from protobuf field: string type_url = 1;
|
|
174
|
-
*/
|
|
175
|
-
typeUrl: string;
|
|
176
|
-
/**
|
|
177
|
-
* Must be a valid serialized protocol buffer of the above specified type.
|
|
178
|
-
*
|
|
179
|
-
* @generated from protobuf field: bytes value = 2;
|
|
180
|
-
*/
|
|
181
|
-
value: Uint8Array;
|
|
182
|
-
}
|
|
183
|
-
// @generated message type with reflection information, may provide speed optimized methods
|
|
184
|
-
class Any$Type extends MessageType<Any> {
|
|
185
|
-
constructor() {
|
|
186
|
-
super("google.protobuf.Any", [
|
|
187
|
-
{ no: 1, name: "type_url", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
|
188
|
-
{ no: 2, name: "value", kind: "scalar", T: 12 /*ScalarType.BYTES*/ }
|
|
189
|
-
]);
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* Pack the message into a new `Any`.
|
|
193
|
-
*
|
|
194
|
-
* Uses 'type.googleapis.com/full.type.name' as the type URL.
|
|
195
|
-
*/
|
|
196
|
-
pack<T extends object>(message: T, type: IMessageType<T>): Any {
|
|
197
|
-
return {
|
|
198
|
-
typeUrl: this.typeNameToUrl(type.typeName), value: type.toBinary(message),
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* Unpack the message from the `Any`.
|
|
203
|
-
*/
|
|
204
|
-
unpack<T extends object>(any: Any, type: IMessageType<T>, options?: Partial<BinaryReadOptions>): T {
|
|
205
|
-
if (!this.contains(any, type))
|
|
206
|
-
throw new Error("Cannot unpack google.protobuf.Any with typeUrl '" + any.typeUrl + "' as " + type.typeName + ".");
|
|
207
|
-
return type.fromBinary(any.value, options);
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Does the given `Any` contain a packed message of the given type?
|
|
211
|
-
*/
|
|
212
|
-
contains(any: Any, type: IMessageType<any> | string): boolean {
|
|
213
|
-
if (!any.typeUrl.length)
|
|
214
|
-
return false;
|
|
215
|
-
let wants = typeof type == "string" ? type : type.typeName;
|
|
216
|
-
let has = this.typeUrlToName(any.typeUrl);
|
|
217
|
-
return wants === has;
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
* Convert the message to canonical JSON value.
|
|
221
|
-
*
|
|
222
|
-
* You have to provide the `typeRegistry` option so that the
|
|
223
|
-
* packed message can be converted to JSON.
|
|
224
|
-
*
|
|
225
|
-
* The `typeRegistry` option is also required to read
|
|
226
|
-
* `google.protobuf.Any` from JSON format.
|
|
227
|
-
*/
|
|
228
|
-
internalJsonWrite(any: Any, options: JsonWriteOptions): JsonValue {
|
|
229
|
-
if (any.typeUrl === "")
|
|
230
|
-
return {};
|
|
231
|
-
let typeName = this.typeUrlToName(any.typeUrl);
|
|
232
|
-
let opt = jsonWriteOptions(options);
|
|
233
|
-
let type = opt.typeRegistry?.find(t => t.typeName === typeName);
|
|
234
|
-
if (!type)
|
|
235
|
-
throw new globalThis.Error("Unable to convert google.protobuf.Any with typeUrl '" + any.typeUrl + "' to JSON. The specified type " + typeName + " is not available in the type registry.");
|
|
236
|
-
let value = type.fromBinary(any.value, { readUnknownField: false });
|
|
237
|
-
let json = type.internalJsonWrite(value, opt);
|
|
238
|
-
if (typeName.startsWith("google.protobuf.") || !isJsonObject(json))
|
|
239
|
-
json = { value: json };
|
|
240
|
-
json["@type"] = any.typeUrl;
|
|
241
|
-
return json;
|
|
242
|
-
}
|
|
243
|
-
internalJsonRead(json: JsonValue, options: JsonReadOptions, target?: Any): Any {
|
|
244
|
-
if (!isJsonObject(json))
|
|
245
|
-
throw new globalThis.Error("Unable to parse google.protobuf.Any from JSON " + typeofJsonValue(json) + ".");
|
|
246
|
-
if (typeof json["@type"] != "string" || json["@type"] == "")
|
|
247
|
-
return this.create();
|
|
248
|
-
let typeName = this.typeUrlToName(json["@type"]);
|
|
249
|
-
let type = options?.typeRegistry?.find(t => t.typeName == typeName);
|
|
250
|
-
if (!type)
|
|
251
|
-
throw new globalThis.Error("Unable to parse google.protobuf.Any from JSON. The specified type " + typeName + " is not available in the type registry.");
|
|
252
|
-
let value;
|
|
253
|
-
if (typeName.startsWith("google.protobuf.") && json.hasOwnProperty("value"))
|
|
254
|
-
value = type.fromJson(json["value"], options);
|
|
255
|
-
else {
|
|
256
|
-
let copy = Object.assign({}, json);
|
|
257
|
-
delete copy["@type"];
|
|
258
|
-
value = type.fromJson(copy, options);
|
|
259
|
-
}
|
|
260
|
-
if (target === undefined)
|
|
261
|
-
target = this.create();
|
|
262
|
-
target.typeUrl = json["@type"];
|
|
263
|
-
target.value = type.toBinary(value);
|
|
264
|
-
return target;
|
|
265
|
-
}
|
|
266
|
-
typeNameToUrl(name: string): string {
|
|
267
|
-
if (!name.length)
|
|
268
|
-
throw new Error("invalid type name: " + name);
|
|
269
|
-
return "type.googleapis.com/" + name;
|
|
270
|
-
}
|
|
271
|
-
typeUrlToName(url: string): string {
|
|
272
|
-
if (!url.length)
|
|
273
|
-
throw new Error("invalid type url: " + url);
|
|
274
|
-
let slash = url.lastIndexOf("/");
|
|
275
|
-
let name = slash > 0 ? url.substring(slash + 1) : url;
|
|
276
|
-
if (!name.length)
|
|
277
|
-
throw new Error("invalid type url: " + url);
|
|
278
|
-
return name;
|
|
279
|
-
}
|
|
280
|
-
create(value?: PartialMessage<Any>): Any {
|
|
281
|
-
const message = globalThis.Object.create((this.messagePrototype!));
|
|
282
|
-
message.typeUrl = "";
|
|
283
|
-
message.value = new Uint8Array(0);
|
|
284
|
-
if (value !== undefined)
|
|
285
|
-
reflectionMergePartial<Any>(this, message, value);
|
|
286
|
-
return message;
|
|
287
|
-
}
|
|
288
|
-
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: Any): Any {
|
|
289
|
-
let message = target ?? this.create(), end = reader.pos + length;
|
|
290
|
-
while (reader.pos < end) {
|
|
291
|
-
let [fieldNo, wireType] = reader.tag();
|
|
292
|
-
switch (fieldNo) {
|
|
293
|
-
case /* string type_url */ 1:
|
|
294
|
-
message.typeUrl = reader.string();
|
|
295
|
-
break;
|
|
296
|
-
case /* bytes value */ 2:
|
|
297
|
-
message.value = reader.bytes();
|
|
298
|
-
break;
|
|
299
|
-
default:
|
|
300
|
-
let u = options.readUnknownField;
|
|
301
|
-
if (u === "throw")
|
|
302
|
-
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
|
303
|
-
let d = reader.skip(wireType);
|
|
304
|
-
if (u !== false)
|
|
305
|
-
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
return message;
|
|
309
|
-
}
|
|
310
|
-
internalBinaryWrite(message: Any, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
|
|
311
|
-
/* string type_url = 1; */
|
|
312
|
-
if (message.typeUrl !== "")
|
|
313
|
-
writer.tag(1, WireType.LengthDelimited).string(message.typeUrl);
|
|
314
|
-
/* bytes value = 2; */
|
|
315
|
-
if (message.value.length)
|
|
316
|
-
writer.tag(2, WireType.LengthDelimited).bytes(message.value);
|
|
317
|
-
let u = options.writeUnknownFields;
|
|
318
|
-
if (u !== false)
|
|
319
|
-
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
|
320
|
-
return writer;
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
/**
|
|
324
|
-
* @generated MessageType for protobuf message google.protobuf.Any
|
|
325
|
-
*/
|
|
326
|
-
export const Any = new Any$Type();
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
// @generated by protobuf-ts 2.9.4 with parameter server_generic,generate_dependencies,long_type_number
|
|
2
|
-
// @generated from protobuf file "google/protobuf/empty.proto" (package "google.protobuf", syntax proto3)
|
|
3
|
-
// tslint:disable
|
|
4
|
-
//
|
|
5
|
-
// Protocol Buffers - Google's data interchange format
|
|
6
|
-
// Copyright 2008 Google Inc. All rights reserved.
|
|
7
|
-
// https://developers.google.com/protocol-buffers/
|
|
8
|
-
//
|
|
9
|
-
// Redistribution and use in source and binary forms, with or without
|
|
10
|
-
// modification, are permitted provided that the following conditions are
|
|
11
|
-
// met:
|
|
12
|
-
//
|
|
13
|
-
// * Redistributions of source code must retain the above copyright
|
|
14
|
-
// notice, this list of conditions and the following disclaimer.
|
|
15
|
-
// * Redistributions in binary form must reproduce the above
|
|
16
|
-
// copyright notice, this list of conditions and the following disclaimer
|
|
17
|
-
// in the documentation and/or other materials provided with the
|
|
18
|
-
// distribution.
|
|
19
|
-
// * Neither the name of Google Inc. nor the names of its
|
|
20
|
-
// contributors may be used to endorse or promote products derived from
|
|
21
|
-
// this software without specific prior written permission.
|
|
22
|
-
//
|
|
23
|
-
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
24
|
-
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
25
|
-
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
26
|
-
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
27
|
-
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
28
|
-
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
29
|
-
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
30
|
-
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
31
|
-
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
32
|
-
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
33
|
-
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
34
|
-
//
|
|
35
|
-
import type { BinaryWriteOptions } from "@protobuf-ts/runtime";
|
|
36
|
-
import type { IBinaryWriter } from "@protobuf-ts/runtime";
|
|
37
|
-
import { UnknownFieldHandler } from "@protobuf-ts/runtime";
|
|
38
|
-
import type { BinaryReadOptions } from "@protobuf-ts/runtime";
|
|
39
|
-
import type { IBinaryReader } from "@protobuf-ts/runtime";
|
|
40
|
-
import type { PartialMessage } from "@protobuf-ts/runtime";
|
|
41
|
-
import { reflectionMergePartial } from "@protobuf-ts/runtime";
|
|
42
|
-
import { MessageType } from "@protobuf-ts/runtime";
|
|
43
|
-
/**
|
|
44
|
-
* A generic empty message that you can re-use to avoid defining duplicated
|
|
45
|
-
* empty messages in your APIs. A typical example is to use it as the request
|
|
46
|
-
* or the response type of an API method. For instance:
|
|
47
|
-
*
|
|
48
|
-
* service Foo {
|
|
49
|
-
* rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
|
|
50
|
-
* }
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* @generated from protobuf message google.protobuf.Empty
|
|
54
|
-
*/
|
|
55
|
-
export interface Empty {
|
|
56
|
-
}
|
|
57
|
-
// @generated message type with reflection information, may provide speed optimized methods
|
|
58
|
-
class Empty$Type extends MessageType<Empty> {
|
|
59
|
-
constructor() {
|
|
60
|
-
super("google.protobuf.Empty", []);
|
|
61
|
-
}
|
|
62
|
-
create(value?: PartialMessage<Empty>): Empty {
|
|
63
|
-
const message = globalThis.Object.create((this.messagePrototype!));
|
|
64
|
-
if (value !== undefined)
|
|
65
|
-
reflectionMergePartial<Empty>(this, message, value);
|
|
66
|
-
return message;
|
|
67
|
-
}
|
|
68
|
-
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: Empty): Empty {
|
|
69
|
-
return target ?? this.create();
|
|
70
|
-
}
|
|
71
|
-
internalBinaryWrite(message: Empty, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
|
|
72
|
-
let u = options.writeUnknownFields;
|
|
73
|
-
if (u !== false)
|
|
74
|
-
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
|
75
|
-
return writer;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* @generated MessageType for protobuf message google.protobuf.Empty
|
|
80
|
-
*/
|
|
81
|
-
export const Empty = new Empty$Type();
|