@streamr/dht 102.0.0-beta.0 → 102.0.0-beta.2

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.
Files changed (264) hide show
  1. package/dist/generated/packages/dht/protos/DhtRpc.d.ts +16 -8
  2. package/dist/generated/packages/dht/protos/DhtRpc.js +7 -5
  3. package/dist/generated/packages/dht/protos/DhtRpc.js.map +1 -1
  4. package/dist/package.json +15 -16
  5. package/dist/src/connection/ConnectionManager.js +18 -8
  6. package/dist/src/connection/ConnectionManager.js.map +1 -1
  7. package/dist/src/connection/Handshaker.d.ts +1 -1
  8. package/dist/src/connection/Handshaker.js +9 -5
  9. package/dist/src/connection/Handshaker.js.map +1 -1
  10. package/dist/src/connection/ManagedConnection.js +17 -7
  11. package/dist/src/connection/ManagedConnection.js.map +1 -1
  12. package/dist/src/connection/connectivityChecker.js +20 -10
  13. package/dist/src/connection/connectivityChecker.js.map +1 -1
  14. package/dist/src/connection/connectivityRequestHandler.js +3 -3
  15. package/dist/src/connection/connectivityRequestHandler.js.map +1 -1
  16. package/dist/src/connection/simulator/Simulator.js +3 -2
  17. package/dist/src/connection/simulator/Simulator.js.map +1 -1
  18. package/dist/src/connection/simulator/pings.d.ts +1 -1
  19. package/dist/src/connection/simulator/pings.js +3 -3
  20. package/dist/src/connection/simulator/pings.js.map +1 -1
  21. package/dist/src/connection/webrtc/NodeWebrtcConnection.js +0 -2
  22. package/dist/src/connection/webrtc/NodeWebrtcConnection.js.map +1 -1
  23. package/dist/src/connection/webrtc/WebrtcConnector.js +19 -9
  24. package/dist/src/connection/webrtc/WebrtcConnector.js.map +1 -1
  25. package/dist/src/connection/webrtc/iceServerAsString.js +1 -2
  26. package/dist/src/connection/webrtc/iceServerAsString.js.map +1 -1
  27. package/dist/src/connection/websocket/AbstractWebsocketClientConnection.d.ts +0 -2
  28. package/dist/src/connection/websocket/WebsocketClientConnectorRpcLocal.d.ts +0 -1
  29. package/dist/src/connection/websocket/WebsocketServerConnection.d.ts +0 -1
  30. package/dist/src/connection/websocket/WebsocketServerConnector.js +28 -18
  31. package/dist/src/connection/websocket/WebsocketServerConnector.js.map +1 -1
  32. package/dist/src/dht/DhtNode.d.ts +1 -0
  33. package/dist/src/dht/DhtNode.js +3 -2
  34. package/dist/src/dht/DhtNode.js.map +1 -1
  35. package/dist/src/dht/DhtNodeRpcLocal.d.ts +1 -1
  36. package/dist/src/dht/PeerManager.d.ts +2 -1
  37. package/dist/src/dht/PeerManager.js +2 -1
  38. package/dist/src/dht/PeerManager.js.map +1 -1
  39. package/dist/src/dht/contact/SortedContactList.js +1 -1
  40. package/dist/src/dht/contact/SortedContactList.js.map +1 -1
  41. package/dist/src/dht/discovery/DiscoverySession.d.ts +0 -1
  42. package/dist/src/dht/discovery/PeerDiscovery.d.ts +0 -1
  43. package/dist/src/dht/discovery/RingDiscoverySession.d.ts +0 -1
  44. package/dist/src/dht/recursive-operation/RecursiveOperationManager.d.ts +2 -2
  45. package/dist/src/dht/routing/DuplicateDetector.js.map +1 -1
  46. package/dist/src/dht/routing/RoutingSession.js +2 -2
  47. package/dist/src/dht/routing/RoutingSession.js.map +1 -1
  48. package/dist/src/dht/routing/RoutingTablesCache.d.ts +1 -1
  49. package/dist/src/dht/store/LocalDataStore.js +1 -1
  50. package/dist/src/dht/store/LocalDataStore.js.map +1 -1
  51. package/dist/src/dht/store/StoreManager.d.ts +1 -1
  52. package/dist/src/dht/store/StoreRpcLocal.d.ts +1 -1
  53. package/dist/src/helpers/AddressTools.js +2 -3
  54. package/dist/src/helpers/AddressTools.js.map +1 -1
  55. package/dist/src/helpers/debugHelpers.js +2 -2
  56. package/dist/src/helpers/debugHelpers.js.map +1 -1
  57. package/dist/src/helpers/protoClasses.d.ts +1 -1
  58. package/dist/src/helpers/protoClasses.js.map +1 -1
  59. package/dist/src/helpers/protoToString.js +1 -2
  60. package/dist/src/helpers/protoToString.js.map +1 -1
  61. package/dist/src/helpers/version.d.ts +1 -1
  62. package/dist/src/helpers/version.js +4 -4
  63. package/dist/src/helpers/version.js.map +1 -1
  64. package/eslint.config.mjs +12 -0
  65. package/jest.config.ts +12 -0
  66. package/package.json +15 -16
  67. package/protos/DhtRpc.proto +6 -4
  68. package/.eslintignore +0 -5
  69. package/.eslintrc +0 -3
  70. package/generated/google/protobuf/any.ts +0 -326
  71. package/generated/google/protobuf/empty.ts +0 -81
  72. package/generated/google/protobuf/timestamp.ts +0 -287
  73. package/generated/packages/dht/protos/DhtRpc.client.ts +0 -419
  74. package/generated/packages/dht/protos/DhtRpc.server.ts +0 -165
  75. package/generated/packages/dht/protos/DhtRpc.ts +0 -1266
  76. package/generated/packages/proto-rpc/protos/ProtoRpc.ts +0 -108
  77. package/jest.config.js +0 -5
  78. package/src/connection/Connection.ts +0 -28
  79. package/src/connection/ConnectionLockRpcLocal.ts +0 -78
  80. package/src/connection/ConnectionLockRpcRemote.ts +0 -64
  81. package/src/connection/ConnectionLockStates.ts +0 -131
  82. package/src/connection/ConnectionManager.ts +0 -661
  83. package/src/connection/ConnectionsView.ts +0 -8
  84. package/src/connection/ConnectorFacade.ts +0 -217
  85. package/src/connection/Handshaker.ts +0 -205
  86. package/src/connection/IConnection.ts +0 -40
  87. package/src/connection/ManagedConnection.ts +0 -113
  88. package/src/connection/OutputBuffer.ts +0 -28
  89. package/src/connection/PendingConnection.ts +0 -68
  90. package/src/connection/connectivityChecker.ts +0 -108
  91. package/src/connection/connectivityRequestHandler.ts +0 -116
  92. package/src/connection/simulator/Simulator.ts +0 -368
  93. package/src/connection/simulator/SimulatorConnection.ts +0 -137
  94. package/src/connection/simulator/SimulatorConnector.ts +0 -98
  95. package/src/connection/simulator/SimulatorTransport.ts +0 -15
  96. package/src/connection/simulator/pings.ts +0 -42
  97. package/src/connection/webrtc/BrowserWebrtcConnection.ts +0 -242
  98. package/src/connection/webrtc/IWebrtcConnection.ts +0 -24
  99. package/src/connection/webrtc/NodeWebrtcConnection.ts +0 -247
  100. package/src/connection/webrtc/WebrtcConnector.ts +0 -234
  101. package/src/connection/webrtc/WebrtcConnectorRpcLocal.ts +0 -108
  102. package/src/connection/webrtc/WebrtcConnectorRpcRemote.ts +0 -60
  103. package/src/connection/webrtc/iceServerAsString.ts +0 -15
  104. package/src/connection/websocket/AbstractWebsocketClientConnection.ts +0 -122
  105. package/src/connection/websocket/AutoCertifierClientFacade.ts +0 -89
  106. package/src/connection/websocket/BrowserWebsocketClientConnection.ts +0 -44
  107. package/src/connection/websocket/NodeWebsocketClientConnection.ts +0 -39
  108. package/src/connection/websocket/WebsocketClientConnector.ts +0 -119
  109. package/src/connection/websocket/WebsocketClientConnectorRpcLocal.ts +0 -38
  110. package/src/connection/websocket/WebsocketClientConnectorRpcRemote.ts +0 -19
  111. package/src/connection/websocket/WebsocketServer.ts +0 -164
  112. package/src/connection/websocket/WebsocketServerConnection.ts +0 -109
  113. package/src/connection/websocket/WebsocketServerConnector.ts +0 -286
  114. package/src/dht/DhtNode.ts +0 -678
  115. package/src/dht/DhtNodeRpcLocal.ts +0 -84
  116. package/src/dht/DhtNodeRpcRemote.ts +0 -107
  117. package/src/dht/ExternalApiRpcLocal.ts +0 -58
  118. package/src/dht/ExternalApiRpcRemote.ts +0 -41
  119. package/src/dht/PeerManager.ts +0 -303
  120. package/src/dht/contact/Contact.ts +0 -19
  121. package/src/dht/contact/ContactList.ts +0 -43
  122. package/src/dht/contact/RandomContactList.ts +0 -56
  123. package/src/dht/contact/RingContactList.ts +0 -143
  124. package/src/dht/contact/RpcRemote.ts +0 -72
  125. package/src/dht/contact/SortedContactList.ts +0 -173
  126. package/src/dht/contact/getClosestNodes.ts +0 -24
  127. package/src/dht/contact/ringIdentifiers.ts +0 -62
  128. package/src/dht/discovery/DiscoverySession.ts +0 -129
  129. package/src/dht/discovery/PeerDiscovery.ts +0 -244
  130. package/src/dht/discovery/RingDiscoverySession.ts +0 -148
  131. package/src/dht/recursive-operation/RecursiveOperationManager.ts +0 -251
  132. package/src/dht/recursive-operation/RecursiveOperationRpcLocal.ts +0 -34
  133. package/src/dht/recursive-operation/RecursiveOperationRpcRemote.ts +0 -43
  134. package/src/dht/recursive-operation/RecursiveOperationSession.ts +0 -231
  135. package/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.ts +0 -35
  136. package/src/dht/recursive-operation/RecursiveOperationSessionRpcRemote.ts +0 -30
  137. package/src/dht/routing/DuplicateDetector.ts +0 -34
  138. package/src/dht/routing/Router.ts +0 -246
  139. package/src/dht/routing/RouterRpcLocal.ts +0 -78
  140. package/src/dht/routing/RouterRpcRemote.ts +0 -80
  141. package/src/dht/routing/RoutingSession.ts +0 -243
  142. package/src/dht/routing/RoutingTablesCache.ts +0 -60
  143. package/src/dht/routing/getPreviousPeer.ts +0 -6
  144. package/src/dht/store/LocalDataStore.ts +0 -84
  145. package/src/dht/store/StoreManager.ts +0 -170
  146. package/src/dht/store/StoreRpcLocal.ts +0 -89
  147. package/src/dht/store/StoreRpcRemote.ts +0 -32
  148. package/src/exports.ts +0 -33
  149. package/src/helpers/AddressTools.ts +0 -28
  150. package/src/helpers/Connectivity.ts +0 -19
  151. package/src/helpers/browser/isBrowserEnvironment.ts +0 -1
  152. package/src/helpers/browser/isBrowserEnvironment_override.ts +0 -3
  153. package/src/helpers/createPeerDescriptor.ts +0 -57
  154. package/src/helpers/createPeerDescriptorSignaturePayload.ts +0 -28
  155. package/src/helpers/debugHelpers.ts +0 -9
  156. package/src/helpers/errors.ts +0 -49
  157. package/src/helpers/offering.ts +0 -15
  158. package/src/helpers/protoClasses.ts +0 -57
  159. package/src/helpers/protoToString.ts +0 -21
  160. package/src/helpers/version.ts +0 -32
  161. package/src/identifiers.ts +0 -29
  162. package/src/rpc-protocol/DhtCallContext.ts +0 -14
  163. package/src/rpc-protocol/DhtRpcOptions.ts +0 -10
  164. package/src/transport/ITransport.ts +0 -37
  165. package/src/transport/ListeningRpcCommunicator.ts +0 -32
  166. package/src/transport/RoutingRpcCommunicator.ts +0 -66
  167. package/src/types/ServiceID.ts +0 -1
  168. package/src/types/textencoding.d.ts +0 -6
  169. package/test/benchmark/Find.test.ts +0 -72
  170. package/test/benchmark/KademliaCorrectness.test.ts +0 -114
  171. package/test/benchmark/RingCorrectness.test.ts +0 -157
  172. package/test/benchmark/SortedContactListBenchmark.test.ts +0 -108
  173. package/test/benchmark/WebsocketServerMemoryLeak.test.ts +0 -41
  174. package/test/benchmark/hybrid-network-simulation/RingContactList.test.ts +0 -71
  175. package/test/end-to-end/GeoIpLayer0.test.ts +0 -55
  176. package/test/end-to-end/Layer0-Layer1.test.ts +0 -93
  177. package/test/end-to-end/Layer0.test.ts +0 -76
  178. package/test/end-to-end/Layer0MixedConnectionTypes.test.ts +0 -110
  179. package/test/end-to-end/Layer0Webrtc-Layer1.test.ts +0 -137
  180. package/test/end-to-end/Layer0Webrtc.test.ts +0 -85
  181. package/test/end-to-end/Layer1-Scale-WebSocket.test.ts +0 -82
  182. package/test/end-to-end/Layer1-Scale-Webrtc.test.ts +0 -76
  183. package/test/end-to-end/RecoveryFromFailedAutoCertification.test.ts +0 -52
  184. package/test/end-to-end/WebsocketConnectionRequest.test.ts +0 -69
  185. package/test/end-to-end/memory-leak.test.ts +0 -80
  186. package/test/integration/ConnectionLocking.test.ts +0 -182
  187. package/test/integration/ConnectionManager.test.ts +0 -528
  188. package/test/integration/ConnectivityChecking.test.ts +0 -53
  189. package/test/integration/DhtJoinPeerDiscovery.test.ts +0 -49
  190. package/test/integration/DhtNode.test.ts +0 -66
  191. package/test/integration/DhtNodeExternalAPI.test.ts +0 -48
  192. package/test/integration/DhtNodeRpcRemote.test.ts +0 -66
  193. package/test/integration/DhtRpc.test.ts +0 -121
  194. package/test/integration/Find.test.ts +0 -45
  195. package/test/integration/GeoIpConnectivityChecking.test.ts +0 -72
  196. package/test/integration/Layer1-scale.test.ts +0 -189
  197. package/test/integration/Mock-Layer1-Layer0.test.ts +0 -85
  198. package/test/integration/MultipleEntryPointJoining.test.ts +0 -105
  199. package/test/integration/ReplicateData.test.ts +0 -104
  200. package/test/integration/RouteMessage.test.ts +0 -230
  201. package/test/integration/RouterRpcRemote.test.ts +0 -77
  202. package/test/integration/SimultaneousConnections.test.ts +0 -316
  203. package/test/integration/Store.test.ts +0 -85
  204. package/test/integration/StoreAndDelete.test.ts +0 -77
  205. package/test/integration/StoreOnDhtWithThreeNodes.test.ts +0 -59
  206. package/test/integration/StoreOnDhtWithTwoNodes.test.ts +0 -51
  207. package/test/integration/StoreRpcRemote.test.ts +0 -54
  208. package/test/integration/WebrtcConnectionManagement.test.ts +0 -219
  209. package/test/integration/WebrtcConnectorRpc.test.ts +0 -125
  210. package/test/integration/Websocket.test.ts +0 -65
  211. package/test/integration/WebsocketClientConnectorRpc.test.ts +0 -69
  212. package/test/integration/WebsocketConnectionManagement.test.ts +0 -191
  213. package/test/integration/rpc-connections-over-webrtc.test.ts +0 -158
  214. package/test/kademlia-simulation/data/nodeids.json +0 -13002
  215. package/test/kademlia-simulation/data/orderedneighbors.json +0 -1001
  216. package/test/types/global.d.ts +0 -1
  217. package/test/unit/AddressTools.test.ts +0 -44
  218. package/test/unit/AutoCertifierClientFacade.test.ts +0 -58
  219. package/test/unit/ConnectionManager.test.ts +0 -65
  220. package/test/unit/ConnectivityHelpers.test.ts +0 -61
  221. package/test/unit/DiscoverySession.test.ts +0 -87
  222. package/test/unit/DuplicateDetector.test.ts +0 -31
  223. package/test/unit/Handshaker.test.ts +0 -169
  224. package/test/unit/ListeningRpcCommunicator.test.ts +0 -52
  225. package/test/unit/LocalDataStore.test.ts +0 -108
  226. package/test/unit/ManagedConnection.test.ts +0 -58
  227. package/test/unit/PeerManager.test.ts +0 -93
  228. package/test/unit/PendingConnection.test.ts +0 -57
  229. package/test/unit/ProtobufMessage.test.ts +0 -21
  230. package/test/unit/RandomContactList.test.ts +0 -58
  231. package/test/unit/RecursiveOperationManager.test.ts +0 -161
  232. package/test/unit/RecursiveOperationSession.test.ts +0 -68
  233. package/test/unit/Router.test.ts +0 -137
  234. package/test/unit/RoutingSession.test.ts +0 -79
  235. package/test/unit/SortedContactList.test.ts +0 -115
  236. package/test/unit/StoreManager.test.ts +0 -146
  237. package/test/unit/StoreRpcLocal.test.ts +0 -167
  238. package/test/unit/WebrtcConnection.test.ts +0 -29
  239. package/test/unit/WebrtcConnector.test.ts +0 -56
  240. package/test/unit/WebsocketClientConnector.test.ts +0 -101
  241. package/test/unit/WebsocketServer.test.ts +0 -66
  242. package/test/unit/WebsocketServerConnector.test.ts +0 -102
  243. package/test/unit/connectivityRequestHandler.test.ts +0 -104
  244. package/test/unit/createPeerDescriptor.test.ts +0 -69
  245. package/test/unit/customMatchers.test.ts +0 -16
  246. package/test/unit/getClosestNodes.test.ts +0 -30
  247. package/test/unit/version.test.ts +0 -18
  248. package/test/unit/webrtcReplaceInternalIpWithExternalIp.test.ts +0 -18
  249. package/test/utils/FakeConnectorFacade.ts +0 -41
  250. package/test/utils/FakeRpcCommunicator.ts +0 -23
  251. package/test/utils/FakeTransport.ts +0 -79
  252. package/test/utils/customMatchers.ts +0 -71
  253. package/test/utils/mock/MockConnection.ts +0 -26
  254. package/test/utils/mock/MockConnectionsView.ts +0 -18
  255. package/test/utils/mock/MockRouter.ts +0 -62
  256. package/test/utils/mock/MockRpcCommunicator.ts +0 -7
  257. package/test/utils/mock/MockTransport.ts +0 -26
  258. package/test/utils/mock/mockDataEntry.ts +0 -38
  259. package/test/utils/topology.ts +0 -80
  260. package/test/utils/utils.ts +0 -268
  261. package/tsconfig.browser.json +0 -17
  262. package/tsconfig.jest.json +0 -25
  263. package/tsconfig.json +0 -3
  264. package/tsconfig.node.json +0 -24
@@ -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();