@milaboratories/pl-client 2.16.7 → 2.16.9

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 (253) hide show
  1. package/dist/__external/.pnpm/{@rollup_plugin-typescript@12.1.4_rollup@4.52.4_tslib@2.7.0_typescript@5.6.3 → @rollup_plugin-typescript@12.1.4_rollup@4.52.4_tslib@2.8.1_typescript@5.6.3}/__external/tslib/tslib.es6.cjs +2 -2
  2. package/dist/__external/.pnpm/{@rollup_plugin-typescript@12.1.4_rollup@4.52.4_tslib@2.7.0_typescript@5.6.3 → @rollup_plugin-typescript@12.1.4_rollup@4.52.4_tslib@2.8.1_typescript@5.6.3}/__external/tslib/tslib.es6.cjs.map +1 -1
  3. package/dist/__external/.pnpm/{@rollup_plugin-typescript@12.1.4_rollup@4.52.4_tslib@2.7.0_typescript@5.6.3 → @rollup_plugin-typescript@12.1.4_rollup@4.52.4_tslib@2.8.1_typescript@5.6.3}/__external/tslib/tslib.es6.js +2 -2
  4. package/dist/__external/.pnpm/{@rollup_plugin-typescript@12.1.4_rollup@4.52.4_tslib@2.7.0_typescript@5.6.3 → @rollup_plugin-typescript@12.1.4_rollup@4.52.4_tslib@2.8.1_typescript@5.6.3}/__external/tslib/tslib.es6.js.map +1 -1
  5. package/dist/core/abstract_stream.d.ts +18 -0
  6. package/dist/core/abstract_stream.d.ts.map +1 -0
  7. package/dist/core/client.cjs +6 -6
  8. package/dist/core/client.cjs.map +1 -1
  9. package/dist/core/client.d.ts +3 -3
  10. package/dist/core/client.d.ts.map +1 -1
  11. package/dist/core/client.js +6 -6
  12. package/dist/core/client.js.map +1 -1
  13. package/dist/core/config.cjs +3 -0
  14. package/dist/core/config.cjs.map +1 -1
  15. package/dist/core/config.d.ts +4 -0
  16. package/dist/core/config.d.ts.map +1 -1
  17. package/dist/core/config.js +3 -1
  18. package/dist/core/config.js.map +1 -1
  19. package/dist/core/driver.cjs +11 -0
  20. package/dist/core/driver.cjs.map +1 -1
  21. package/dist/core/driver.d.ts +8 -2
  22. package/dist/core/driver.d.ts.map +1 -1
  23. package/dist/core/driver.js +11 -1
  24. package/dist/core/driver.js.map +1 -1
  25. package/dist/core/errors.cjs +9 -0
  26. package/dist/core/errors.cjs.map +1 -1
  27. package/dist/core/errors.d.ts +1 -1
  28. package/dist/core/errors.d.ts.map +1 -1
  29. package/dist/core/errors.js +9 -0
  30. package/dist/core/errors.js.map +1 -1
  31. package/dist/core/ll_client.cjs +194 -39
  32. package/dist/core/ll_client.cjs.map +1 -1
  33. package/dist/core/ll_client.d.ts +36 -15
  34. package/dist/core/ll_client.d.ts.map +1 -1
  35. package/dist/core/ll_client.js +195 -40
  36. package/dist/core/ll_client.js.map +1 -1
  37. package/dist/core/ll_transaction.cjs.map +1 -1
  38. package/dist/core/ll_transaction.d.ts +3 -3
  39. package/dist/core/ll_transaction.d.ts.map +1 -1
  40. package/dist/core/ll_transaction.js.map +1 -1
  41. package/dist/core/transaction.cjs +2 -2
  42. package/dist/core/transaction.cjs.map +1 -1
  43. package/dist/core/transaction.js +2 -2
  44. package/dist/core/transaction.js.map +1 -1
  45. package/dist/core/type_conversion.cjs +2 -2
  46. package/dist/core/type_conversion.cjs.map +1 -1
  47. package/dist/core/type_conversion.d.ts +2 -2
  48. package/dist/core/type_conversion.d.ts.map +1 -1
  49. package/dist/core/type_conversion.js +2 -2
  50. package/dist/core/type_conversion.js.map +1 -1
  51. package/dist/core/unauth_client.cjs +4 -8
  52. package/dist/core/unauth_client.cjs.map +1 -1
  53. package/dist/core/unauth_client.d.ts +1 -1
  54. package/dist/core/unauth_client.d.ts.map +1 -1
  55. package/dist/core/unauth_client.js +4 -8
  56. package/dist/core/unauth_client.js.map +1 -1
  57. package/dist/core/wire.d.ts +34 -0
  58. package/dist/core/wire.d.ts.map +1 -0
  59. package/dist/index.cjs +4 -0
  60. package/dist/index.cjs.map +1 -1
  61. package/dist/index.d.ts +2 -1
  62. package/dist/index.d.ts.map +1 -1
  63. package/dist/index.js +4 -2
  64. package/dist/index.js.map +1 -1
  65. package/dist/proto-grpc/github.com/googleapis/googleapis/google/rpc/status.cjs.map +1 -0
  66. package/dist/{proto → proto-grpc}/github.com/googleapis/googleapis/google/rpc/status.d.ts +4 -2
  67. package/dist/proto-grpc/github.com/googleapis/googleapis/google/rpc/status.d.ts.map +1 -0
  68. package/dist/proto-grpc/github.com/googleapis/googleapis/google/rpc/status.js.map +1 -0
  69. package/dist/{proto → proto-grpc}/github.com/milaboratory/pl/plapi/plapiproto/api.cjs +25 -25
  70. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.cjs.map +1 -0
  71. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.cjs.map +1 -0
  72. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.d.ts.map +1 -0
  73. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.js.map +1 -0
  74. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.d.ts.map +1 -0
  75. package/dist/{proto → proto-grpc}/github.com/milaboratory/pl/plapi/plapiproto/api.js +25 -25
  76. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.js.map +1 -0
  77. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.cjs.map +1 -0
  78. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.d.ts.map +1 -0
  79. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.js.map +1 -0
  80. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.cjs.map +1 -0
  81. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.d.ts.map +1 -0
  82. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.js.map +1 -0
  83. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/import.d.ts.map +1 -0
  84. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/resource_types.cjs.map +1 -0
  85. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/resource_types.d.ts.map +1 -0
  86. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/resource_types.js.map +1 -0
  87. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/ws-test.d.ts +73 -0
  88. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/ws-test.d.ts.map +1 -0
  89. package/dist/{proto → proto-grpc}/google/api/http.d.ts +28 -32
  90. package/dist/proto-grpc/google/api/http.d.ts.map +1 -0
  91. package/dist/proto-grpc/google/protobuf/any.cjs.map +1 -0
  92. package/dist/proto-grpc/google/protobuf/any.d.ts.map +1 -0
  93. package/dist/proto-grpc/google/protobuf/any.js.map +1 -0
  94. package/dist/{proto → proto-grpc}/google/protobuf/descriptor.d.ts +6 -152
  95. package/dist/proto-grpc/google/protobuf/descriptor.d.ts.map +1 -0
  96. package/dist/proto-grpc/google/protobuf/duration.cjs.map +1 -0
  97. package/dist/proto-grpc/google/protobuf/duration.d.ts.map +1 -0
  98. package/dist/proto-grpc/google/protobuf/duration.js.map +1 -0
  99. package/dist/proto-grpc/google/protobuf/empty.d.ts.map +1 -0
  100. package/dist/proto-grpc/google/protobuf/struct.d.ts.map +1 -0
  101. package/dist/proto-grpc/google/protobuf/timestamp.cjs.map +1 -0
  102. package/dist/proto-grpc/google/protobuf/timestamp.d.ts.map +1 -0
  103. package/dist/proto-grpc/google/protobuf/timestamp.js.map +1 -0
  104. package/dist/{proto → proto-grpc}/google/protobuf/wrappers.d.ts +0 -27
  105. package/dist/proto-grpc/google/protobuf/wrappers.d.ts.map +1 -0
  106. package/dist/proto-grpc/google/rpc/code.cjs +240 -0
  107. package/dist/proto-grpc/google/rpc/code.cjs.map +1 -0
  108. package/dist/proto-grpc/google/rpc/code.d.ts +219 -0
  109. package/dist/proto-grpc/google/rpc/code.d.ts.map +1 -0
  110. package/dist/proto-grpc/google/rpc/code.js +240 -0
  111. package/dist/proto-grpc/google/rpc/code.js.map +1 -0
  112. package/dist/proto-grpc/google/rpc/error_details.d.ts +654 -0
  113. package/dist/proto-grpc/google/rpc/error_details.d.ts.map +1 -0
  114. package/dist/proto-grpc/google/rpc/http.d.ts +121 -0
  115. package/dist/proto-grpc/google/rpc/http.d.ts.map +1 -0
  116. package/dist/proto-grpc/google/rpc/status.d.ts +55 -0
  117. package/dist/proto-grpc/google/rpc/status.d.ts.map +1 -0
  118. package/dist/proto-rest/index.cjs +64 -0
  119. package/dist/proto-rest/index.cjs.map +1 -0
  120. package/dist/proto-rest/index.d.ts +23 -0
  121. package/dist/proto-rest/index.d.ts.map +1 -0
  122. package/dist/proto-rest/index.js +61 -0
  123. package/dist/proto-rest/index.js.map +1 -0
  124. package/dist/proto-rest/plapi.d.ts +1488 -0
  125. package/dist/proto-rest/plapi.d.ts.map +1 -0
  126. package/package.json +6 -3
  127. package/src/core/abstract_stream.ts +25 -0
  128. package/src/core/client.ts +8 -8
  129. package/src/core/config.ts +9 -0
  130. package/src/core/driver.ts +13 -2
  131. package/src/core/errors.ts +7 -1
  132. package/src/core/ll_client.test.ts +1 -1
  133. package/src/core/ll_client.ts +212 -42
  134. package/src/core/ll_transaction.test.ts +1 -1
  135. package/src/core/ll_transaction.ts +4 -4
  136. package/src/core/transaction.ts +1 -1
  137. package/src/core/type_conversion.ts +3 -3
  138. package/src/core/unauth_client.test.ts +6 -0
  139. package/src/core/unauth_client.ts +8 -12
  140. package/src/core/wire.ts +40 -0
  141. package/src/index.ts +3 -1
  142. package/src/{proto → proto-grpc}/github.com/googleapis/googleapis/google/rpc/status.ts +5 -3
  143. package/src/{proto → proto-grpc}/github.com/milaboratory/pl/plapi/plapiproto/api.ts +25 -25
  144. package/src/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/ws-test.ts +209 -0
  145. package/src/{proto → proto-grpc}/google/api/http.ts +29 -33
  146. package/src/{proto → proto-grpc}/google/protobuf/descriptor.ts +11 -221
  147. package/src/{proto → proto-grpc}/google/protobuf/wrappers.ts +4 -38
  148. package/src/proto-grpc/google/rpc/code.ts +236 -0
  149. package/src/proto-grpc/google/rpc/error_details.ts +1386 -0
  150. package/src/proto-grpc/google/rpc/http.ts +307 -0
  151. package/src/proto-grpc/google/rpc/status.ts +127 -0
  152. package/src/proto-rest/index.ts +83 -0
  153. package/src/proto-rest/plapi.ts +1488 -0
  154. package/dist/core/grpc.d.ts +0 -16
  155. package/dist/core/grpc.d.ts.map +0 -1
  156. package/dist/core/http.d.ts +0 -2
  157. package/dist/core/http.d.ts.map +0 -1
  158. package/dist/proto/github.com/googleapis/googleapis/google/rpc/status.cjs.map +0 -1
  159. package/dist/proto/github.com/googleapis/googleapis/google/rpc/status.d.ts.map +0 -1
  160. package/dist/proto/github.com/googleapis/googleapis/google/rpc/status.js.map +0 -1
  161. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.d.ts +0 -40
  162. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.d.ts.map +0 -1
  163. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.d.ts +0 -116
  164. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.d.ts.map +0 -1
  165. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.client.d.ts +0 -46
  166. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.client.d.ts.map +0 -1
  167. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.d.ts +0 -170
  168. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.d.ts.map +0 -1
  169. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.client.d.ts +0 -51
  170. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.client.d.ts.map +0 -1
  171. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.d.ts +0 -176
  172. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.d.ts.map +0 -1
  173. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client.d.ts +0 -131
  174. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client.d.ts.map +0 -1
  175. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.d.ts +0 -320
  176. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.d.ts.map +0 -1
  177. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.cjs.map +0 -1
  178. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.client.cjs.map +0 -1
  179. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.client.d.ts.map +0 -1
  180. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.client.js.map +0 -1
  181. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.d.ts.map +0 -1
  182. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.js.map +0 -1
  183. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api_types.cjs.map +0 -1
  184. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api_types.d.ts.map +0 -1
  185. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api_types.js.map +0 -1
  186. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/base_types.cjs.map +0 -1
  187. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/base_types.d.ts.map +0 -1
  188. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/base_types.js.map +0 -1
  189. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/import.d.ts.map +0 -1
  190. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/resource_types.cjs.map +0 -1
  191. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/resource_types.d.ts.map +0 -1
  192. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/resource_types.js.map +0 -1
  193. package/dist/proto/google/api/http.d.ts.map +0 -1
  194. package/dist/proto/google/protobuf/any.cjs.map +0 -1
  195. package/dist/proto/google/protobuf/any.d.ts.map +0 -1
  196. package/dist/proto/google/protobuf/any.js.map +0 -1
  197. package/dist/proto/google/protobuf/descriptor.d.ts.map +0 -1
  198. package/dist/proto/google/protobuf/duration.cjs.map +0 -1
  199. package/dist/proto/google/protobuf/duration.d.ts.map +0 -1
  200. package/dist/proto/google/protobuf/duration.js.map +0 -1
  201. package/dist/proto/google/protobuf/empty.d.ts.map +0 -1
  202. package/dist/proto/google/protobuf/struct.d.ts.map +0 -1
  203. package/dist/proto/google/protobuf/timestamp.cjs.map +0 -1
  204. package/dist/proto/google/protobuf/timestamp.d.ts.map +0 -1
  205. package/dist/proto/google/protobuf/timestamp.js.map +0 -1
  206. package/dist/proto/google/protobuf/wrappers.d.ts.map +0 -1
  207. package/src/core/grpc.ts +0 -17
  208. package/src/core/http.ts +0 -178
  209. package/src/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.ts +0 -45
  210. package/src/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.ts +0 -313
  211. package/src/proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.client.ts +0 -51
  212. package/src/proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.ts +0 -406
  213. package/src/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.client.ts +0 -59
  214. package/src/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.ts +0 -489
  215. package/src/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client.ts +0 -148
  216. package/src/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.ts +0 -719
  217. /package/dist/{proto → proto-grpc}/github.com/googleapis/googleapis/google/rpc/status.cjs +0 -0
  218. /package/dist/{proto → proto-grpc}/github.com/googleapis/googleapis/google/rpc/status.js +0 -0
  219. /package/dist/{proto → proto-grpc}/github.com/milaboratory/pl/plapi/plapiproto/api.client.cjs +0 -0
  220. /package/dist/{proto → proto-grpc}/github.com/milaboratory/pl/plapi/plapiproto/api.client.d.ts +0 -0
  221. /package/dist/{proto → proto-grpc}/github.com/milaboratory/pl/plapi/plapiproto/api.client.js +0 -0
  222. /package/dist/{proto → proto-grpc}/github.com/milaboratory/pl/plapi/plapiproto/api.d.ts +0 -0
  223. /package/dist/{proto → proto-grpc}/github.com/milaboratory/pl/plapi/plapiproto/api_types.cjs +0 -0
  224. /package/dist/{proto → proto-grpc}/github.com/milaboratory/pl/plapi/plapiproto/api_types.d.ts +0 -0
  225. /package/dist/{proto → proto-grpc}/github.com/milaboratory/pl/plapi/plapiproto/api_types.js +0 -0
  226. /package/dist/{proto → proto-grpc}/github.com/milaboratory/pl/plapi/plapiproto/base_types.cjs +0 -0
  227. /package/dist/{proto → proto-grpc}/github.com/milaboratory/pl/plapi/plapiproto/base_types.d.ts +0 -0
  228. /package/dist/{proto → proto-grpc}/github.com/milaboratory/pl/plapi/plapiproto/base_types.js +0 -0
  229. /package/dist/{proto → proto-grpc}/github.com/milaboratory/pl/plapi/plapiproto/import.d.ts +0 -0
  230. /package/dist/{proto → proto-grpc}/github.com/milaboratory/pl/plapi/plapiproto/resource_types.cjs +0 -0
  231. /package/dist/{proto → proto-grpc}/github.com/milaboratory/pl/plapi/plapiproto/resource_types.d.ts +0 -0
  232. /package/dist/{proto → proto-grpc}/github.com/milaboratory/pl/plapi/plapiproto/resource_types.js +0 -0
  233. /package/dist/{proto → proto-grpc}/google/protobuf/any.cjs +0 -0
  234. /package/dist/{proto → proto-grpc}/google/protobuf/any.d.ts +0 -0
  235. /package/dist/{proto → proto-grpc}/google/protobuf/any.js +0 -0
  236. /package/dist/{proto → proto-grpc}/google/protobuf/duration.cjs +0 -0
  237. /package/dist/{proto → proto-grpc}/google/protobuf/duration.d.ts +0 -0
  238. /package/dist/{proto → proto-grpc}/google/protobuf/duration.js +0 -0
  239. /package/dist/{proto → proto-grpc}/google/protobuf/empty.d.ts +0 -0
  240. /package/dist/{proto → proto-grpc}/google/protobuf/struct.d.ts +0 -0
  241. /package/dist/{proto → proto-grpc}/google/protobuf/timestamp.cjs +0 -0
  242. /package/dist/{proto → proto-grpc}/google/protobuf/timestamp.d.ts +0 -0
  243. /package/dist/{proto → proto-grpc}/google/protobuf/timestamp.js +0 -0
  244. /package/src/{proto → proto-grpc}/github.com/milaboratory/pl/plapi/plapiproto/api.client.ts +0 -0
  245. /package/src/{proto → proto-grpc}/github.com/milaboratory/pl/plapi/plapiproto/api_types.ts +0 -0
  246. /package/src/{proto → proto-grpc}/github.com/milaboratory/pl/plapi/plapiproto/base_types.ts +0 -0
  247. /package/src/{proto → proto-grpc}/github.com/milaboratory/pl/plapi/plapiproto/import.ts +0 -0
  248. /package/src/{proto → proto-grpc}/github.com/milaboratory/pl/plapi/plapiproto/resource_types.ts +0 -0
  249. /package/src/{proto → proto-grpc}/google/protobuf/any.ts +0 -0
  250. /package/src/{proto → proto-grpc}/google/protobuf/duration.ts +0 -0
  251. /package/src/{proto → proto-grpc}/google/protobuf/empty.ts +0 -0
  252. /package/src/{proto → proto-grpc}/google/protobuf/struct.ts +0 -0
  253. /package/src/{proto → proto-grpc}/google/protobuf/timestamp.ts +0 -0
@@ -1,4 +1,4 @@
1
- import { PlatformClient } from '../proto/github.com/milaboratory/pl/plapi/plapiproto/api.client';
1
+ import { PlatformClient as GrpcPlApiClient } from '../proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client';
2
2
  import type { ClientOptions, Interceptor } from '@grpc/grpc-js';
3
3
  import {
4
4
  ChannelCredentials,
@@ -13,26 +13,31 @@ import type {
13
13
  PlConnectionStatus,
14
14
  PlConnectionStatusListener,
15
15
  } from './config';
16
- import { plAddressToConfig } from './config';
16
+ import { plAddressToConfig, type wireProtocol, SUPPORTED_WIRE_PROTOCOLS } from './config';
17
17
  import type { GrpcOptions } from '@protobuf-ts/grpc-transport';
18
18
  import { GrpcTransport } from '@protobuf-ts/grpc-transport';
19
19
  import { LLPlTransaction } from './ll_transaction';
20
20
  import { parsePlJwt } from '../util/pl';
21
- import type { Dispatcher } from 'undici';
21
+ import { type Dispatcher, interceptors } from 'undici';
22
+ import type { Middleware } from 'openapi-fetch';
22
23
  import { inferAuthRefreshTime } from './auth';
23
24
  import { defaultHttpDispatcher } from '@milaboratories/pl-http';
24
- import type { GrpcClientProvider, GrpcClientProviderFactory } from './grpc';
25
+ import type { WireClientProvider, WireClientProviderFactory, WireConnection } from './wire';
25
26
  import { parseHttpAuth } from '@milaboratories/pl-model-common';
27
+ import type * as grpcTypes from '../proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api';
28
+ import { type PlApiPaths, type PlRestClientType, createClient, parseResponseError } from '../proto-rest';
29
+ import { notEmpty } from '@milaboratories/ts-helpers';
30
+ import { Code } from '../proto-grpc/google/rpc/code';
26
31
 
27
32
  export interface PlCallOps {
28
33
  timeout?: number;
29
34
  abortSignal?: AbortSignal;
30
35
  }
31
36
 
32
- class GrpcClientProviderImpl<Client> implements GrpcClientProvider<Client> {
37
+ class WireClientProviderImpl<Client> implements WireClientProvider<Client> {
33
38
  private client: Client | undefined = undefined;
34
39
 
35
- constructor(private readonly grpcTransport: () => GrpcTransport, private readonly clientConstructor: (transport: GrpcTransport) => Client) {}
40
+ constructor(private readonly wireOpts: () => WireConnection, private readonly clientConstructor: (wireOpts: WireConnection) => Client) {}
36
41
 
37
42
  public reset(): void {
38
43
  this.client = undefined;
@@ -40,13 +45,13 @@ class GrpcClientProviderImpl<Client> implements GrpcClientProvider<Client> {
40
45
 
41
46
  public get(): Client {
42
47
  if (this.client === undefined)
43
- this.client = this.clientConstructor(this.grpcTransport());
48
+ this.client = this.clientConstructor(this.wireOpts());
44
49
  return this.client;
45
50
  }
46
51
  }
47
52
 
48
53
  /** Abstract out low level networking and authorization details */
49
- export class LLPlClient implements GrpcClientProviderFactory {
54
+ export class LLPlClient implements WireClientProviderFactory {
50
55
  public readonly conf: PlClientConfig;
51
56
 
52
57
  /** Initial authorization information */
@@ -63,11 +68,15 @@ export class LLPlClient implements GrpcClientProviderFactory {
63
68
  private _status: PlConnectionStatus = 'OK';
64
69
  private readonly statusListener?: PlConnectionStatusListener;
65
70
 
66
- private readonly grpcInterceptors: Interceptor[];
67
- private _grpcTransport!: GrpcTransport;
68
- private readonly providers: WeakRef<GrpcClientProviderImpl<any>>[] = [];
71
+ private _wireProto: wireProtocol | undefined = undefined;
72
+ private _wireConn!: WireConnection;
69
73
 
70
- public readonly grpcPl: GrpcClientProvider<PlatformClient>;
74
+ private readonly _restInterceptors: Dispatcher.DispatcherComposeInterceptor[];
75
+ private readonly _restMiddlewares: Middleware[];
76
+ private readonly _grpcInterceptors: Interceptor[];
77
+ private readonly providers: WeakRef<WireClientProviderImpl<any>>[] = [];
78
+
79
+ public readonly clientProvider: WireClientProvider<PlRestClientType | GrpcPlApiClient>;
71
80
 
72
81
  public readonly httpDispatcher: Dispatcher;
73
82
 
@@ -83,45 +92,87 @@ export class LLPlClient implements GrpcClientProviderFactory {
83
92
  ? plAddressToConfig(configOrAddress)
84
93
  : configOrAddress;
85
94
 
86
- this.grpcInterceptors = [];
87
-
88
- const { auth, statusListener, shouldUseGzip } = ops;
95
+ const { auth, statusListener } = ops;
89
96
 
90
97
  if (auth !== undefined) {
91
98
  this.refreshTimestamp = inferAuthRefreshTime(
92
99
  auth.authInformation,
93
100
  this.conf.authMaxRefreshSeconds,
94
101
  );
95
- this.grpcInterceptors.push(this.createAuthInterceptor());
96
102
  this.authInformation = auth.authInformation;
97
103
  this.onAuthUpdate = auth.onUpdate;
98
104
  this.onAuthRefreshProblem = auth.onUpdateError;
99
105
  this.onAuthError = auth.onAuthError;
100
106
  }
101
107
 
102
- this.grpcInterceptors.push(this.createErrorInterceptor());
108
+ this._restInterceptors = [];
109
+ this._restMiddlewares = [];
110
+ this._grpcInterceptors = [];
103
111
 
104
- // initialize _grpcTransport and _grpcPl
105
- this.initGrpc(shouldUseGzip ?? false);
112
+ if (auth !== undefined) {
113
+ this._restInterceptors.push(this.createRestAuthInterceptor());
114
+ this._grpcInterceptors.push(this.createGrpcAuthInterceptor());
115
+ }
116
+ this._restInterceptors.push(interceptors.retry({ statusCodes: [] })); // Handle errors with openapi-fetch middleware.
117
+ this._restMiddlewares.push(this.createRestErrorMiddleware());
118
+ this._grpcInterceptors.push(this.createGrpcErrorInterceptor());
106
119
 
107
120
  this.httpDispatcher = defaultHttpDispatcher(this.conf.httpProxy);
108
121
 
122
+ this.initWireConnection();
123
+
109
124
  if (statusListener !== undefined) {
110
125
  this.statusListener = statusListener;
111
126
  statusListener(this._status);
112
127
  }
113
128
 
114
- this.grpcPl = this.createGrpcClientProvider((transport) => new PlatformClient(transport));
129
+ this.clientProvider = this.createWireClientProvider((wireConn) => {
130
+ if (wireConn.type === 'grpc') {
131
+ return new GrpcPlApiClient(wireConn.Transport);
132
+ } else {
133
+ return createClient<PlApiPaths>({
134
+ hostAndPort: wireConn.Config.hostAndPort,
135
+ ssl: wireConn.Config.ssl,
136
+ dispatcher: wireConn.Dispatcher,
137
+ middlewares: wireConn.Middlewares,
138
+ });
139
+ }
140
+ });
141
+ }
142
+
143
+ private initWireConnection() {
144
+ if (this._wireProto === undefined) {
145
+ // TODO: implement automatic server mode detection
146
+ this._wireProto = this.conf.wireProtocol ?? 'grpc';
147
+ }
148
+
149
+ switch (this._wireProto) {
150
+ case 'rest':
151
+ this.initRestConnection();
152
+ return;
153
+ case 'grpc':
154
+ this.initGrpcConnection(this.ops.shouldUseGzip ?? false);
155
+ return;
156
+ default:
157
+ ((v: never) => {
158
+ throw new Error(`Unsupported wire protocol '${v as string}'. Use one of: ${SUPPORTED_WIRE_PROTOCOLS.join(', ')}`);
159
+ })(this._wireProto);
160
+ }
161
+ }
162
+
163
+ private initRestConnection(): void {
164
+ const dispatcher = defaultHttpDispatcher(this.conf.httpProxy, this._restInterceptors);
165
+ this._replaceWireConnection({ type: 'rest', Config: this.conf, Dispatcher: dispatcher, Middlewares: this._restMiddlewares });
115
166
  }
116
167
 
117
168
  /**
118
- * Initializes (or reinitializes) _grpcTransport and _grpcPl
169
+ * Initializes (or reinitializes) _grpcTransport
119
170
  * @param gzip - whether to enable gzip compression
120
171
  */
121
- private initGrpc(gzip: boolean) {
172
+ private initGrpcConnection(gzip: boolean) {
122
173
  const clientOptions: ClientOptions = {
123
174
  'grpc.keepalive_time_ms': 30_000, // 30 seconds
124
- 'interceptors': this.grpcInterceptors,
175
+ 'interceptors': this._grpcInterceptors,
125
176
  };
126
177
 
127
178
  if (gzip) clientOptions['grpc.default_compression_algorithm'] = compressionAlgorithms.gzip;
@@ -161,9 +212,12 @@ export class LLPlClient implements GrpcClientProviderFactory {
161
212
  delete process.env.grpc_proxy;
162
213
  }
163
214
 
164
- const oldTransport = this._grpcTransport;
215
+ this._replaceWireConnection({ type: 'grpc', Transport: new GrpcTransport(grpcOptions) });
216
+ }
165
217
 
166
- this._grpcTransport = new GrpcTransport(grpcOptions);
218
+ private _replaceWireConnection(newConn: WireConnection): void {
219
+ const oldConn = this._wireConn;
220
+ this._wireConn = newConn;
167
221
 
168
222
  // Reset all providers to let them reinitialize their clients
169
223
  for (let i = 0; i < this.providers.length; i++) {
@@ -177,7 +231,7 @@ export class LLPlClient implements GrpcClientProviderFactory {
177
231
  }
178
232
  }
179
233
 
180
- if (oldTransport !== undefined) oldTransport.close();
234
+ if (oldConn !== undefined && oldConn.type === 'grpc') oldConn.Transport.close();
181
235
  }
182
236
 
183
237
  private providerCleanupCounter = 0;
@@ -187,7 +241,7 @@ export class LLPlClient implements GrpcClientProviderFactory {
187
241
  *
188
242
  * @param clientConstructor - a factory function that creates a grpc client
189
243
  */
190
- public createGrpcClientProvider<Client>(clientConstructor: (transport: GrpcTransport) => Client): GrpcClientProvider<Client> {
244
+ public createWireClientProvider<Client>(clientConstructor: (transport: WireConnection) => Client): WireClientProvider<Client> {
191
245
  // We need to cleanup providers periodically to avoid memory leaks.
192
246
  // This is a simple heuristic to avoid memory leaks.
193
247
  // We could use a more sophisticated algorithm, but this is good enough for now.
@@ -203,13 +257,13 @@ export class LLPlClient implements GrpcClientProviderFactory {
203
257
  this.providerCleanupCounter = 0;
204
258
  }
205
259
 
206
- const provider = new GrpcClientProviderImpl<Client>(() => this._grpcTransport, clientConstructor);
260
+ const provider = new WireClientProviderImpl<Client>(() => this._wireConn, clientConstructor);
207
261
  this.providers.push(new WeakRef(provider));
208
262
  return provider;
209
263
  }
210
264
 
211
- public get grpcTransport(): GrpcTransport {
212
- return this._grpcTransport;
265
+ public get wireConnection(): WireConnection {
266
+ return this._wireConn;
213
267
  }
214
268
 
215
269
  /** Returns true if client is authenticated. Even with anonymous auth information
@@ -256,13 +310,8 @@ export class LLPlClient implements GrpcClientProviderFactory {
256
310
  this.authRefreshInProgress = true;
257
311
  void (async () => {
258
312
  try {
259
- const response = await this.grpcPl.get().getJWTToken({
260
- expiration: {
261
- seconds: BigInt(this.conf.authTTLSeconds),
262
- nanos: 0,
263
- },
264
- }).response;
265
- this.authInformation = { jwtToken: response.token };
313
+ const token = await this.getJwtToken(BigInt(this.conf.authTTLSeconds));
314
+ this.authInformation = { jwtToken: token };
266
315
  this.refreshTimestamp = inferAuthRefreshTime(
267
316
  this.authInformation,
268
317
  this.conf.authMaxRefreshSeconds,
@@ -276,8 +325,45 @@ export class LLPlClient implements GrpcClientProviderFactory {
276
325
  })();
277
326
  }
278
327
 
279
- /** Detects certain errors and update client status accordingly */
280
- private createErrorInterceptor(): Interceptor {
328
+ /**
329
+ * Creates middleware that parses error responses and handles them centrally.
330
+ * This middleware runs before openapi-fetch parses the response, so we need to
331
+ * manually parse the response body for error responses.
332
+ */
333
+ private createRestErrorMiddleware(): Middleware {
334
+ return {
335
+ onResponse: async ({ request: _request, response, options: _options }) => {
336
+ const { body: body, ...resOptions } = response;
337
+
338
+ if ([502, 503, 504].includes(response.status)) {
339
+ // Service unavailable, bad gateway, gateway timeout
340
+ this.updateStatus('Disconnected');
341
+ return new Response(body, { ...resOptions, status: response.status });
342
+ }
343
+
344
+ const respErr = await parseResponseError(response);
345
+ if (!respErr.error) {
346
+ // No error: nice!
347
+ return new Response(respErr.origBody ?? body, { ...resOptions, status: response.status });
348
+ }
349
+
350
+ if (typeof respErr.error === 'string') {
351
+ // Non-standard error or normal response: let later middleware to deal wit it.
352
+ return new Response(respErr.error, { ...resOptions, status: response.status });
353
+ }
354
+
355
+ if (respErr.error.code === Code.UNAUTHENTICATED) {
356
+ this.updateStatus('Unauthenticated');
357
+ }
358
+
359
+ // Let later middleware to deal with standard gRPC error.
360
+ return new Response(respErr.origBody, { ...resOptions, status: response.status });
361
+ },
362
+ };
363
+ }
364
+
365
+ /** Detects certain errors and update client status accordingly when using GRPC wire connection */
366
+ private createGrpcErrorInterceptor(): Interceptor {
281
367
  return (options, nextCall) => {
282
368
  return new InterceptingCall(nextCall(options), {
283
369
  start: (metadata, listener, next) => {
@@ -297,8 +383,22 @@ export class LLPlClient implements GrpcClientProviderFactory {
297
383
  };
298
384
  }
299
385
 
386
+ private createRestAuthInterceptor(): Dispatcher.DispatcherComposeInterceptor {
387
+ return (dispatch) => {
388
+ return (options, handler) => {
389
+ if (this.authInformation?.jwtToken !== undefined) {
390
+ // TODO: check this magic really works and gets called
391
+ options.headers = { ...options.headers, authorization: 'Bearer ' + this.authInformation.jwtToken };
392
+ this.refreshAuthInformationIfNeeded();
393
+ }
394
+
395
+ return dispatch(options, handler);
396
+ };
397
+ };
398
+ }
399
+
300
400
  /** Injects authentication information if needed */
301
- private createAuthInterceptor(): Interceptor {
401
+ private createGrpcAuthInterceptor(): Interceptor {
302
402
  return (options, nextCall) => {
303
403
  return new InterceptingCall(nextCall(options), {
304
404
  start: (metadata, listener, next) => {
@@ -314,11 +414,77 @@ export class LLPlClient implements GrpcClientProviderFactory {
314
414
  };
315
415
  }
316
416
 
417
+ public async getJwtToken(ttlSeconds: bigint, options?: { authorization?: string }): Promise<string> {
418
+ const cl = this.clientProvider.get();
419
+
420
+ if (cl instanceof GrpcPlApiClient) {
421
+ const meta: Record<string, string> = {};
422
+ if (options?.authorization) meta.authorization = options.authorization;
423
+ return (await cl.getJWTToken({ expiration: { seconds: ttlSeconds, nanos: 0 } }, { meta }).response).token;
424
+ } else {
425
+ const headers: Record<string, string> = {};
426
+ if (options?.authorization) headers.authorization = options.authorization;
427
+ const resp = cl.POST('/v1/auth/jwt-token', {
428
+ body: { expiration: `${ttlSeconds}s` },
429
+ headers,
430
+ });
431
+ return notEmpty((await resp).data).token;
432
+ }
433
+ }
434
+
435
+ public async ping(): Promise<grpcTypes.MaintenanceAPI_Ping_Response> {
436
+ const cl = this.clientProvider.get();
437
+ if (cl instanceof GrpcPlApiClient) {
438
+ return (await cl.ping({})).response;
439
+ } else {
440
+ return notEmpty((await cl.GET('/v1/ping')).data);
441
+ }
442
+ }
443
+
444
+ public async license(): Promise<grpcTypes.MaintenanceAPI_License_Response> {
445
+ const cl = this.clientProvider.get();
446
+ if (cl instanceof GrpcPlApiClient) {
447
+ return (await cl.license({})).response;
448
+ } else {
449
+ const resp = notEmpty((await cl.GET('/v1/license')).data);
450
+ return {
451
+ status: resp.status,
452
+ isOk: resp.isOk,
453
+ responseBody: Uint8Array.from(Buffer.from(resp.responseBody)),
454
+ };
455
+ }
456
+ }
457
+
458
+ public async authMethods(): Promise<grpcTypes.AuthAPI_ListMethods_Response> {
459
+ const cl = this.clientProvider.get();
460
+ if (cl instanceof GrpcPlApiClient) {
461
+ return (await cl.authMethods({})).response;
462
+ } else {
463
+ return notEmpty((await cl.GET('/v1/auth/methods')).data);
464
+ }
465
+ }
466
+
467
+ public async txSync(txId: bigint): Promise<void> {
468
+ const cl = this.clientProvider.get();
469
+ if (cl instanceof GrpcPlApiClient) {
470
+ await cl.txSync({ txId: BigInt(txId) });
471
+ } else {
472
+ (await cl.POST('/v1/tx-sync', { body: { txId: txId.toString() } }));
473
+ }
474
+ }
475
+
317
476
  createTx(rw: boolean, ops: PlCallOps = {}): LLPlTransaction {
318
477
  return new LLPlTransaction((abortSignal) => {
319
478
  let totalAbortSignal = abortSignal;
320
479
  if (ops.abortSignal) totalAbortSignal = AbortSignal.any([totalAbortSignal, ops.abortSignal]);
321
- return this.grpcPl.get().tx({
480
+
481
+ const cl = this.clientProvider.get();
482
+ if (!(cl instanceof GrpcPlApiClient)) {
483
+ // TODO: add WebSockets
484
+ throw new Error('tx is not supported for REST client');
485
+ }
486
+
487
+ return cl.tx({
322
488
  abort: totalAbortSignal,
323
489
  timeout: ops.timeout
324
490
  ?? (rw ? this.conf.defaultRWTransactionTimeout : this.conf.defaultROTransactionTimeout),
@@ -328,7 +494,11 @@ export class LLPlClient implements GrpcClientProviderFactory {
328
494
 
329
495
  /** Closes underlying transport */
330
496
  public async close() {
331
- this.grpcTransport.close();
497
+ if (this.wireConnection.type === 'grpc') {
498
+ this.wireConnection.Transport.close();
499
+ } else {
500
+ // TODO: close all WS connections
501
+ }
332
502
  await this.httpDispatcher.destroy();
333
503
  }
334
504
  }
@@ -1,5 +1,5 @@
1
1
  import { getTestLLClient } from '../test/test_config';
2
- import { TxAPI_Open_Request_WritableTx } from '../proto/github.com/milaboratory/pl/plapi/plapiproto/api';
2
+ import { TxAPI_Open_Request_WritableTx } from '../proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api';
3
3
  import { createLocalResourceId } from './types';
4
4
  import { test, expect } from 'vitest';
5
5
 
@@ -1,10 +1,10 @@
1
1
  import type {
2
2
  TxAPI_ClientMessage,
3
3
  TxAPI_ServerMessage,
4
- } from '../proto/github.com/milaboratory/pl/plapi/plapiproto/api';
5
- import type { DuplexStreamingCall } from '@protobuf-ts/runtime-rpc';
4
+ } from '../proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api';
5
+ import type { BiDiStream } from './abstract_stream';
6
6
  import Denque from 'denque';
7
- import type { Status } from '../proto/github.com/googleapis/googleapis/google/rpc/status';
7
+ import type { Status } from '../proto-grpc/github.com/googleapis/googleapis/google/rpc/status';
8
8
  import {
9
9
  PlErrorCodeNotFound,
10
10
  RecoverablePlError,
@@ -17,7 +17,7 @@ export type ClientMessageRequest = TxAPI_ClientMessage['request'];
17
17
 
18
18
  export type ServerMessageResponse = TxAPI_ServerMessage['response'];
19
19
 
20
- type TxStream = DuplexStreamingCall<TxAPI_ClientMessage, TxAPI_ServerMessage>;
20
+ type TxStream = BiDiStream<TxAPI_ClientMessage, TxAPI_ServerMessage>;
21
21
 
22
22
  export type OneOfKind<T extends { oneofKind: unknown }, Kind extends T['oneofKind']> = Extract<
23
23
  T,
@@ -25,7 +25,7 @@ import type {
25
25
  OneOfKind,
26
26
  ServerMessageResponse,
27
27
  } from './ll_transaction';
28
- import { TxAPI_Open_Request_WritableTx } from '../proto/github.com/milaboratory/pl/plapi/plapiproto/api';
28
+ import { TxAPI_Open_Request_WritableTx } from '../proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api';
29
29
  import type { NonUndefined } from 'utility-types';
30
30
  import { toBytes } from '../util/util';
31
31
  import { fieldTypeToProto, protoToField, protoToResource } from './type_conversion';
@@ -1,11 +1,11 @@
1
1
  import type {
2
2
  Field,
3
- Resource } from '../proto/github.com/milaboratory/pl/plapi/plapiproto/api_types';
3
+ Resource } from '../proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types';
4
4
  import {
5
5
  Field_ValueStatus,
6
6
  Resource_Kind,
7
- } from '../proto/github.com/milaboratory/pl/plapi/plapiproto/api_types';
8
- import { FieldType as GrpcFieldType } from '../proto/github.com/milaboratory/pl/plapi/plapiproto/base_types';
7
+ } from '../proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types';
8
+ import { FieldType as GrpcFieldType } from '../proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types';
9
9
  import type {
10
10
  FieldData,
11
11
  FieldStatus,
@@ -9,6 +9,12 @@ test('ping test', async () => {
9
9
  expect(response).toHaveProperty('coreVersion');
10
10
  });
11
11
 
12
+ test('get auth methods', async () => {
13
+ const client = new UnauthenticatedPlClient(getTestConfig().address);
14
+ const response = await client.authMethods();
15
+ expect(response).toHaveProperty('methods');
16
+ });
17
+
12
18
  test('wrong login', async () => {
13
19
  const testConfig = getTestConfig();
14
20
  if (testConfig.test_user === undefined || testConfig.test_password === undefined) {
@@ -2,7 +2,7 @@ import type { AuthInformation, PlClientConfig } from './config';
2
2
  import type {
3
3
  AuthAPI_ListMethods_Response,
4
4
  MaintenanceAPI_Ping_Response,
5
- } from '../proto/github.com/milaboratory/pl/plapi/plapiproto/api';
5
+ } from '../proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api';
6
6
  import { LLPlClient } from './ll_client';
7
7
  import { notEmpty } from '@milaboratories/ts-helpers';
8
8
  import { UnauthenticatedError } from './errors';
@@ -16,11 +16,11 @@ export class UnauthenticatedPlClient {
16
16
  }
17
17
 
18
18
  public async ping(): Promise<MaintenanceAPI_Ping_Response> {
19
- return (await this.ll.grpcPl.get().ping({})).response;
19
+ return await this.ll.ping();
20
20
  }
21
21
 
22
22
  public async authMethods(): Promise<AuthAPI_ListMethods_Response> {
23
- return (await this.ll.grpcPl.get().authMethods({})).response;
23
+ return await this.ll.authMethods();
24
24
  }
25
25
 
26
26
  public async requireAuth(): Promise<boolean> {
@@ -29,15 +29,11 @@ export class UnauthenticatedPlClient {
29
29
 
30
30
  public async login(user: string, password: string): Promise<AuthInformation> {
31
31
  try {
32
- const response = await this.ll.grpcPl.get().getJWTToken(
33
- { expiration: { seconds: BigInt(this.ll.conf.authTTLSeconds), nanos: 0 } },
34
- {
35
- meta: {
36
- authorization: 'Basic ' + Buffer.from(user + ':' + password).toString('base64'),
37
- },
38
- },
39
- ).response;
40
- const jwtToken = notEmpty(response.token);
32
+ const token = await this.ll.getJwtToken(
33
+ BigInt(this.ll.conf.authTTLSeconds),
34
+ { authorization: 'Basic ' + Buffer.from(user + ':' + password).toString('base64') },
35
+ );
36
+ const jwtToken = notEmpty(token);
41
37
  if (jwtToken === '') throw new Error('empty token');
42
38
  return { jwtToken };
43
39
  } catch (e: any) {
@@ -0,0 +1,40 @@
1
+ import type { GrpcTransport } from '@protobuf-ts/grpc-transport';
2
+ import type { Dispatcher } from 'undici';
3
+ import type { PlClientConfig, wireProtocol } from './config';
4
+ import type { Middleware } from 'openapi-fetch';
5
+
6
+ /**
7
+ * Options for the HTTP client to properly reach the PL server API when
8
+ * it works in WebSocket + REST mode.
9
+ */
10
+ export type RestConnection = {
11
+ type: 'rest';
12
+ Config: PlClientConfig;
13
+ Dispatcher: Dispatcher;
14
+ Middlewares: Middleware[];
15
+ };
16
+
17
+ export type GrpcConnection = {
18
+ type: 'grpc';
19
+ Transport: GrpcTransport;
20
+ };
21
+
22
+ export type WireConnection = RestConnection | GrpcConnection;
23
+ // type compatibility check: types used in WireConnection should match known wire protocols.
24
+ const _ct: Extract<WireConnection, { type: string }>['type'] = 'rest' as wireProtocol;
25
+
26
+ /**
27
+ * A provider for a wire (gRPC, HTTP, etc.) client.
28
+ * The client is created on demand, and is reset when the transport is reset.
29
+ * This is useful for cases where the client is used in a loop, and the transport is reset after each iteration.
30
+ */
31
+ export interface WireClientProvider<Client> {
32
+ get(): Client;
33
+ }
34
+
35
+ /**
36
+ * A factory for wire client providers.
37
+ */
38
+ export interface WireClientProviderFactory {
39
+ createWireClientProvider<Client>(clientConstructor: (transport: WireConnection) => Client): WireClientProvider<Client>;
40
+ }
package/src/index.ts CHANGED
@@ -9,8 +9,10 @@ export * from './core/default_client';
9
9
  export * from './core/unauth_client';
10
10
  export * from './core/auth';
11
11
  export * from './core/final';
12
- export * from './core/grpc';
12
+ export * from './core/wire';
13
13
  export * from './helpers/tx_helpers';
14
14
  export * from './helpers/poll';
15
15
 
16
16
  export * as TestHelpers from './test/test_config';
17
+
18
+ export * as RestAPI from './proto-rest';
@@ -2,7 +2,7 @@
2
2
  // @generated from protobuf file "github.com/googleapis/googleapis/google/rpc/status.proto" (package "google.rpc", syntax proto3)
3
3
  // tslint:disable
4
4
  //
5
- // Copyright 2020 Google LLC
5
+ // Copyright 2025 Google LLC
6
6
  //
7
7
  // Licensed under the Apache License, Version 2.0 (the "License");
8
8
  // you may not use this file except in compliance with the License.
@@ -39,7 +39,8 @@ import { Any } from "../../../../../google/protobuf/any";
39
39
  */
40
40
  export interface Status {
41
41
  /**
42
- * The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code].
42
+ * The status code, which should be an enum value of
43
+ * [google.rpc.Code][google.rpc.Code].
43
44
  *
44
45
  * @generated from protobuf field: int32 code = 1
45
46
  */
@@ -47,7 +48,8 @@ export interface Status {
47
48
  /**
48
49
  * A developer-facing error message, which should be in English. Any
49
50
  * user-facing error message should be localized and sent in the
50
- * [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client.
51
+ * [google.rpc.Status.details][google.rpc.Status.details] field, or localized
52
+ * by the client.
51
53
  *
52
54
  * @generated from protobuf field: string message = 2
53
55
  */