@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
@@ -0,0 +1,121 @@
1
+ import type { BinaryWriteOptions } from "@protobuf-ts/runtime";
2
+ import type { IBinaryWriter } from "@protobuf-ts/runtime";
3
+ import type { BinaryReadOptions } from "@protobuf-ts/runtime";
4
+ import type { IBinaryReader } from "@protobuf-ts/runtime";
5
+ import type { PartialMessage } from "@protobuf-ts/runtime";
6
+ import { MessageType } from "@protobuf-ts/runtime";
7
+ /**
8
+ * Represents an HTTP request.
9
+ *
10
+ * @generated from protobuf message google.rpc.HttpRequest
11
+ */
12
+ export interface HttpRequest {
13
+ /**
14
+ * The HTTP request method.
15
+ *
16
+ * @generated from protobuf field: string method = 1
17
+ */
18
+ method: string;
19
+ /**
20
+ * The HTTP request URI.
21
+ *
22
+ * @generated from protobuf field: string uri = 2
23
+ */
24
+ uri: string;
25
+ /**
26
+ * The HTTP request headers. The ordering of the headers is significant.
27
+ * Multiple headers with the same key may present for the request.
28
+ *
29
+ * @generated from protobuf field: repeated google.rpc.HttpHeader headers = 3
30
+ */
31
+ headers: HttpHeader[];
32
+ /**
33
+ * The HTTP request body. If the body is not expected, it should be empty.
34
+ *
35
+ * @generated from protobuf field: bytes body = 4
36
+ */
37
+ body: Uint8Array;
38
+ }
39
+ /**
40
+ * Represents an HTTP response.
41
+ *
42
+ * @generated from protobuf message google.rpc.HttpResponse
43
+ */
44
+ export interface HttpResponse {
45
+ /**
46
+ * The HTTP status code, such as 200 or 404.
47
+ *
48
+ * @generated from protobuf field: int32 status = 1
49
+ */
50
+ status: number;
51
+ /**
52
+ * The HTTP reason phrase, such as "OK" or "Not Found".
53
+ *
54
+ * @generated from protobuf field: string reason = 2
55
+ */
56
+ reason: string;
57
+ /**
58
+ * The HTTP response headers. The ordering of the headers is significant.
59
+ * Multiple headers with the same key may present for the response.
60
+ *
61
+ * @generated from protobuf field: repeated google.rpc.HttpHeader headers = 3
62
+ */
63
+ headers: HttpHeader[];
64
+ /**
65
+ * The HTTP response body. If the body is not expected, it should be empty.
66
+ *
67
+ * @generated from protobuf field: bytes body = 4
68
+ */
69
+ body: Uint8Array;
70
+ }
71
+ /**
72
+ * Represents an HTTP header.
73
+ *
74
+ * @generated from protobuf message google.rpc.HttpHeader
75
+ */
76
+ export interface HttpHeader {
77
+ /**
78
+ * The HTTP header key. It is case insensitive.
79
+ *
80
+ * @generated from protobuf field: string key = 1
81
+ */
82
+ key: string;
83
+ /**
84
+ * The HTTP header value.
85
+ *
86
+ * @generated from protobuf field: string value = 2
87
+ */
88
+ value: string;
89
+ }
90
+ declare class HttpRequest$Type extends MessageType<HttpRequest> {
91
+ constructor();
92
+ create(value?: PartialMessage<HttpRequest>): HttpRequest;
93
+ internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: HttpRequest): HttpRequest;
94
+ internalBinaryWrite(message: HttpRequest, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter;
95
+ }
96
+ /**
97
+ * @generated MessageType for protobuf message google.rpc.HttpRequest
98
+ */
99
+ export declare const HttpRequest: HttpRequest$Type;
100
+ declare class HttpResponse$Type extends MessageType<HttpResponse> {
101
+ constructor();
102
+ create(value?: PartialMessage<HttpResponse>): HttpResponse;
103
+ internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: HttpResponse): HttpResponse;
104
+ internalBinaryWrite(message: HttpResponse, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter;
105
+ }
106
+ /**
107
+ * @generated MessageType for protobuf message google.rpc.HttpResponse
108
+ */
109
+ export declare const HttpResponse: HttpResponse$Type;
110
+ declare class HttpHeader$Type extends MessageType<HttpHeader> {
111
+ constructor();
112
+ create(value?: PartialMessage<HttpHeader>): HttpHeader;
113
+ internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: HttpHeader): HttpHeader;
114
+ internalBinaryWrite(message: HttpHeader, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter;
115
+ }
116
+ /**
117
+ * @generated MessageType for protobuf message google.rpc.HttpHeader
118
+ */
119
+ export declare const HttpHeader: HttpHeader$Type;
120
+ export {};
121
+ //# sourceMappingURL=http.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../../src/proto-grpc/google/rpc/http.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD;;;;GAIG;AACH,MAAM,WAAW,WAAW;IACxB;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;;;;OAKG;IACH,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB;;;;OAIG;IACH,IAAI,EAAE,UAAU,CAAC;CACpB;AACD;;;;GAIG;AACH,MAAM,WAAW,YAAY;IACzB;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB;;;;OAIG;IACH,IAAI,EAAE,UAAU,CAAC;CACpB;AACD;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACvB;;;;OAIG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;;;OAIG;IACH,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,cAAM,gBAAiB,SAAQ,WAAW,CAAC,WAAW,CAAC;;IASnD,MAAM,CAAC,KAAK,CAAC,EAAE,cAAc,CAAC,WAAW,CAAC,GAAG,WAAW;IAUxD,kBAAkB,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,WAAW;IA4BxH,mBAAmB,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,kBAAkB,GAAG,aAAa;CAkB/G;AACD;;GAEG;AACH,eAAO,MAAM,WAAW,kBAAyB,CAAC;AAElD,cAAM,iBAAkB,SAAQ,WAAW,CAAC,YAAY,CAAC;;IASrD,MAAM,CAAC,KAAK,CAAC,EAAE,cAAc,CAAC,YAAY,CAAC,GAAG,YAAY;IAU1D,kBAAkB,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,YAAY;IA4B1H,mBAAmB,CAAC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,kBAAkB,GAAG,aAAa;CAkBhH;AACD;;GAEG;AACH,eAAO,MAAM,YAAY,mBAA0B,CAAC;AAEpD,cAAM,eAAgB,SAAQ,WAAW,CAAC,UAAU,CAAC;;IAOjD,MAAM,CAAC,KAAK,CAAC,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,UAAU;IAQtD,kBAAkB,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,CAAC,EAAE,UAAU,GAAG,UAAU;IAsBtH,mBAAmB,CAAC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,kBAAkB,GAAG,aAAa;CAY9G;AACD;;GAEG;AACH,eAAO,MAAM,UAAU,iBAAwB,CAAC"}
@@ -0,0 +1,55 @@
1
+ import type { BinaryWriteOptions } from "@protobuf-ts/runtime";
2
+ import type { IBinaryWriter } from "@protobuf-ts/runtime";
3
+ import type { BinaryReadOptions } from "@protobuf-ts/runtime";
4
+ import type { IBinaryReader } from "@protobuf-ts/runtime";
5
+ import type { PartialMessage } from "@protobuf-ts/runtime";
6
+ import { MessageType } from "@protobuf-ts/runtime";
7
+ import { Any } from "../protobuf/any";
8
+ /**
9
+ * The `Status` type defines a logical error model that is suitable for
10
+ * different programming environments, including REST APIs and RPC APIs. It is
11
+ * used by [gRPC](https://github.com/grpc). Each `Status` message contains
12
+ * three pieces of data: error code, error message, and error details.
13
+ *
14
+ * You can find out more about this error model and how to work with it in the
15
+ * [API Design Guide](https://cloud.google.com/apis/design/errors).
16
+ *
17
+ * @generated from protobuf message google.rpc.Status
18
+ */
19
+ export interface Status {
20
+ /**
21
+ * The status code, which should be an enum value of
22
+ * [google.rpc.Code][google.rpc.Code].
23
+ *
24
+ * @generated from protobuf field: int32 code = 1
25
+ */
26
+ code: number;
27
+ /**
28
+ * A developer-facing error message, which should be in English. Any
29
+ * user-facing error message should be localized and sent in the
30
+ * [google.rpc.Status.details][google.rpc.Status.details] field, or localized
31
+ * by the client.
32
+ *
33
+ * @generated from protobuf field: string message = 2
34
+ */
35
+ message: string;
36
+ /**
37
+ * A list of messages that carry the error details. There is a common set of
38
+ * message types for APIs to use.
39
+ *
40
+ * @generated from protobuf field: repeated google.protobuf.Any details = 3
41
+ */
42
+ details: Any[];
43
+ }
44
+ declare class Status$Type extends MessageType<Status> {
45
+ constructor();
46
+ create(value?: PartialMessage<Status>): Status;
47
+ internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: Status): Status;
48
+ internalBinaryWrite(message: Status, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter;
49
+ }
50
+ /**
51
+ * @generated MessageType for protobuf message google.rpc.Status
52
+ */
53
+ export declare const Status: Status$Type;
54
+ export {};
55
+ //# sourceMappingURL=status.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../../src/proto-grpc/google/rpc/status.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACtC;;;;;;;;;;GAUG;AACH,MAAM,WAAW,MAAM;IACnB;;;;;OAKG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;;;;;;OAOG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,OAAO,EAAE,GAAG,EAAE,CAAC;CAClB;AAED,cAAM,WAAY,SAAQ,WAAW,CAAC,MAAM,CAAC;;IAQzC,MAAM,CAAC,KAAK,CAAC,EAAE,cAAc,CAAC,MAAM,CAAC,GAAG,MAAM;IAS9C,kBAAkB,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM;IAyB9G,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,kBAAkB,GAAG,aAAa;CAe1G;AACD;;GAEG;AACH,eAAO,MAAM,MAAM,aAAoB,CAAC"}
@@ -0,0 +1,64 @@
1
+ 'use strict';
2
+
3
+ var createOpenApiClient = require('openapi-fetch');
4
+ var undici = require('undici');
5
+ var errors = require('../core/errors.cjs');
6
+
7
+ //
8
+ // This file is NOT autogenerated!
9
+ //
10
+ // After generating new clients from openapi specifications, add client types here.
11
+ //
12
+ function createClient(opts) {
13
+ const scheme = opts.ssl ? 'https://' : 'http://';
14
+ const client = createOpenApiClient({
15
+ baseUrl: `${scheme}${opts.hostAndPort}`,
16
+ fetch: (input) => {
17
+ return undici.fetch(input.url, {
18
+ ...input,
19
+ dispatcher: opts.dispatcher,
20
+ });
21
+ },
22
+ });
23
+ client.use(errorHandlerMiddleware(), ...opts.middlewares);
24
+ return client;
25
+ }
26
+ async function parseResponseError(response) {
27
+ if (response.status < 400) {
28
+ return {};
29
+ }
30
+ let error = await response.clone().text();
31
+ const origBody = error;
32
+ try {
33
+ error = JSON.parse(error);
34
+ }
35
+ catch {
36
+ }
37
+ return {
38
+ error: error,
39
+ origBody
40
+ };
41
+ }
42
+ /**
43
+ * Parses all API responses and thrown error in case of error response.
44
+ * Allows all callers to not bother about .error response field checking.
45
+ */
46
+ function errorHandlerMiddleware() {
47
+ return {
48
+ onResponse: async ({ request: _request, response, options: _options }) => {
49
+ const respErr = await parseResponseError(response);
50
+ if (!respErr.error) {
51
+ const { body, ...resOptions } = response;
52
+ return new Response(body, { ...resOptions, status: response.status });
53
+ }
54
+ if (typeof respErr.error === 'string') {
55
+ throw new Error(respErr.error);
56
+ }
57
+ errors.rethrowMeaningfulError(respErr.error);
58
+ },
59
+ };
60
+ }
61
+
62
+ exports.createClient = createClient;
63
+ exports.parseResponseError = parseResponseError;
64
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../../src/proto-rest/index.ts"],"sourcesContent":["//\n// This file is NOT autogenerated!\n//\n// After generating new clients from openapi specifications, add client types here.\n//\n\nimport type { paths as PlApiPaths } from './plapi';\nimport { default as createOpenApiClient, type Middleware, type Client } from 'openapi-fetch';\nimport { Dispatcher, fetch as undiciFetch } from 'undici';\nimport { rethrowMeaningfulError } from '../core/errors';\nimport { Code } from '../proto-grpc/google/rpc/code';\n\nexport { PlApiPaths };\nexport type PlRestClientType = Client<PlApiPaths>;\n\nexport type RestClientConfig = {\n hostAndPort: string;\n ssl: boolean;\n dispatcher: Dispatcher;\n middlewares: Middleware[];\n}\n\nexport function createClient<Paths extends {}>(opts: RestClientConfig): Client<Paths> {\n const scheme = opts.ssl ? 'https://' : 'http://';\n const client = createOpenApiClient<Paths>({\n baseUrl: `${scheme}${opts.hostAndPort}`,\n fetch: (input: Request): Promise<Response> => {\n return undiciFetch(input.url, {\n ...input,\n dispatcher: opts.dispatcher,\n });\n },\n });\n client.use(errorHandlerMiddleware(), ...opts.middlewares);\n return client;\n}\n\nexport type ErrorResponse = {\n code: Code,\n message: string,\n details: any[],\n}\nexport async function parseResponseError(response: Response): Promise<{\n error?: ErrorResponse | string,\n origBody?: string,\n}>{\n if (response.status < 400) {\n return {};\n }\n\n let error: any = await response.clone().text();\n const origBody = error;\n try {\n error = JSON.parse(error) as ErrorResponse;\n } catch {\n }\n return {\n error: error,\n origBody\n };\n}\n\n/**\n * Parses all API responses and thrown error in case of error response.\n * Allows all callers to not bother about .error response field checking.\n */\nfunction errorHandlerMiddleware(): Middleware {\n return {\n onResponse: async ({ request: _request, response, options: _options }) => {\n const respErr = await parseResponseError(response);\n if (!respErr.error) {\n const { body, ...resOptions } = response;\n return new Response(body, { ...resOptions, status: response.status });\n }\n\n if (typeof respErr.error === 'string') {\n throw new Error(respErr.error);\n }\n\n rethrowMeaningfulError(respErr.error);\n },\n };\n}\n"],"names":["undiciFetch","rethrowMeaningfulError"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AAkBM,SAAU,YAAY,CAAmB,IAAsB,EAAA;AACnE,IAAA,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,GAAG,UAAU,GAAG,SAAS;IAChD,MAAM,MAAM,GAAG,mBAAmB,CAAQ;AACxC,QAAA,OAAO,EAAE,CAAA,EAAG,MAAM,GAAG,IAAI,CAAC,WAAW,CAAA,CAAE;AACvC,QAAA,KAAK,EAAE,CAAC,KAAc,KAAuB;AAC3C,YAAA,OAAOA,YAAW,CAAC,KAAK,CAAC,GAAG,EAAE;AAC5B,gBAAA,GAAG,KAAK;gBACR,UAAU,EAAE,IAAI,CAAC,UAAU;AAC5B,aAAA,CAAC;QACJ,CAAC;AACF,KAAA,CAAC;IACF,MAAM,CAAC,GAAG,CAAC,sBAAsB,EAAE,EAAE,GAAG,IAAI,CAAC,WAAW,CAAC;AACzD,IAAA,OAAO,MAAM;AACf;AAOO,eAAe,kBAAkB,CAAC,QAAkB,EAAA;AAIzD,IAAA,IAAI,QAAQ,CAAC,MAAM,GAAG,GAAG,EAAE;AACzB,QAAA,OAAO,EAAE;IACX;IAEA,IAAI,KAAK,GAAQ,MAAM,QAAQ,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE;IAC9C,MAAM,QAAQ,GAAG,KAAK;AACtB,IAAA,IAAI;AACF,QAAA,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAkB;IAC5C;AAAE,IAAA,MAAM;IACR;IACA,OAAO;AACL,QAAA,KAAK,EAAE,KAAK;QACZ;KACD;AACH;AAEA;;;AAGG;AACH,SAAS,sBAAsB,GAAA;IAC7B,OAAO;AACL,QAAA,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAI;AACvE,YAAA,MAAM,OAAO,GAAG,MAAM,kBAAkB,CAAC,QAAQ,CAAC;AAClD,YAAA,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE;gBAClB,MAAM,EAAE,IAAI,EAAE,GAAG,UAAU,EAAE,GAAG,QAAQ;AACxC,gBAAA,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE,EAAE,GAAG,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;YACvE;AAEA,YAAA,IAAI,OAAO,OAAO,CAAC,KAAK,KAAK,QAAQ,EAAE;AACrC,gBAAA,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;YAChC;AAEA,YAAAC,6BAAsB,CAAC,OAAO,CAAC,KAAK,CAAC;QACvC,CAAC;KACF;AACH;;;;;"}
@@ -0,0 +1,23 @@
1
+ import type { paths as PlApiPaths } from './plapi';
2
+ import { type Middleware, type Client } from 'openapi-fetch';
3
+ import { Dispatcher } from 'undici';
4
+ import { Code } from '../proto-grpc/google/rpc/code';
5
+ export { PlApiPaths };
6
+ export type PlRestClientType = Client<PlApiPaths>;
7
+ export type RestClientConfig = {
8
+ hostAndPort: string;
9
+ ssl: boolean;
10
+ dispatcher: Dispatcher;
11
+ middlewares: Middleware[];
12
+ };
13
+ export declare function createClient<Paths extends {}>(opts: RestClientConfig): Client<Paths>;
14
+ export type ErrorResponse = {
15
+ code: Code;
16
+ message: string;
17
+ details: any[];
18
+ };
19
+ export declare function parseResponseError(response: Response): Promise<{
20
+ error?: ErrorResponse | string;
21
+ origBody?: string;
22
+ }>;
23
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/proto-rest/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,KAAK,IAAI,UAAU,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAkC,KAAK,UAAU,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AAC7F,OAAO,EAAE,UAAU,EAAwB,MAAM,QAAQ,CAAC;AAE1D,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AAErD,OAAO,EAAE,UAAU,EAAE,CAAC;AACtB,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;AAElD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,OAAO,CAAC;IACb,UAAU,EAAE,UAAU,CAAC;IACvB,WAAW,EAAE,UAAU,EAAE,CAAC;CAC3B,CAAA;AAED,wBAAgB,YAAY,CAAC,KAAK,SAAS,EAAE,EAAE,IAAI,EAAE,gBAAgB,GAAG,MAAM,CAAC,KAAK,CAAC,CAapF;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,IAAI,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,GAAG,EAAE,CAAC;CAChB,CAAA;AACD,wBAAsB,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC;IACpE,KAAK,CAAC,EAAE,aAAa,GAAG,MAAM,CAAC;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC,CAeD"}
@@ -0,0 +1,61 @@
1
+ import createOpenApiClient from 'openapi-fetch';
2
+ import { fetch } from 'undici';
3
+ import { rethrowMeaningfulError } from '../core/errors.js';
4
+
5
+ //
6
+ // This file is NOT autogenerated!
7
+ //
8
+ // After generating new clients from openapi specifications, add client types here.
9
+ //
10
+ function createClient(opts) {
11
+ const scheme = opts.ssl ? 'https://' : 'http://';
12
+ const client = createOpenApiClient({
13
+ baseUrl: `${scheme}${opts.hostAndPort}`,
14
+ fetch: (input) => {
15
+ return fetch(input.url, {
16
+ ...input,
17
+ dispatcher: opts.dispatcher,
18
+ });
19
+ },
20
+ });
21
+ client.use(errorHandlerMiddleware(), ...opts.middlewares);
22
+ return client;
23
+ }
24
+ async function parseResponseError(response) {
25
+ if (response.status < 400) {
26
+ return {};
27
+ }
28
+ let error = await response.clone().text();
29
+ const origBody = error;
30
+ try {
31
+ error = JSON.parse(error);
32
+ }
33
+ catch {
34
+ }
35
+ return {
36
+ error: error,
37
+ origBody
38
+ };
39
+ }
40
+ /**
41
+ * Parses all API responses and thrown error in case of error response.
42
+ * Allows all callers to not bother about .error response field checking.
43
+ */
44
+ function errorHandlerMiddleware() {
45
+ return {
46
+ onResponse: async ({ request: _request, response, options: _options }) => {
47
+ const respErr = await parseResponseError(response);
48
+ if (!respErr.error) {
49
+ const { body, ...resOptions } = response;
50
+ return new Response(body, { ...resOptions, status: response.status });
51
+ }
52
+ if (typeof respErr.error === 'string') {
53
+ throw new Error(respErr.error);
54
+ }
55
+ rethrowMeaningfulError(respErr.error);
56
+ },
57
+ };
58
+ }
59
+
60
+ export { createClient, parseResponseError };
61
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../src/proto-rest/index.ts"],"sourcesContent":["//\n// This file is NOT autogenerated!\n//\n// After generating new clients from openapi specifications, add client types here.\n//\n\nimport type { paths as PlApiPaths } from './plapi';\nimport { default as createOpenApiClient, type Middleware, type Client } from 'openapi-fetch';\nimport { Dispatcher, fetch as undiciFetch } from 'undici';\nimport { rethrowMeaningfulError } from '../core/errors';\nimport { Code } from '../proto-grpc/google/rpc/code';\n\nexport { PlApiPaths };\nexport type PlRestClientType = Client<PlApiPaths>;\n\nexport type RestClientConfig = {\n hostAndPort: string;\n ssl: boolean;\n dispatcher: Dispatcher;\n middlewares: Middleware[];\n}\n\nexport function createClient<Paths extends {}>(opts: RestClientConfig): Client<Paths> {\n const scheme = opts.ssl ? 'https://' : 'http://';\n const client = createOpenApiClient<Paths>({\n baseUrl: `${scheme}${opts.hostAndPort}`,\n fetch: (input: Request): Promise<Response> => {\n return undiciFetch(input.url, {\n ...input,\n dispatcher: opts.dispatcher,\n });\n },\n });\n client.use(errorHandlerMiddleware(), ...opts.middlewares);\n return client;\n}\n\nexport type ErrorResponse = {\n code: Code,\n message: string,\n details: any[],\n}\nexport async function parseResponseError(response: Response): Promise<{\n error?: ErrorResponse | string,\n origBody?: string,\n}>{\n if (response.status < 400) {\n return {};\n }\n\n let error: any = await response.clone().text();\n const origBody = error;\n try {\n error = JSON.parse(error) as ErrorResponse;\n } catch {\n }\n return {\n error: error,\n origBody\n };\n}\n\n/**\n * Parses all API responses and thrown error in case of error response.\n * Allows all callers to not bother about .error response field checking.\n */\nfunction errorHandlerMiddleware(): Middleware {\n return {\n onResponse: async ({ request: _request, response, options: _options }) => {\n const respErr = await parseResponseError(response);\n if (!respErr.error) {\n const { body, ...resOptions } = response;\n return new Response(body, { ...resOptions, status: response.status });\n }\n\n if (typeof respErr.error === 'string') {\n throw new Error(respErr.error);\n }\n\n rethrowMeaningfulError(respErr.error);\n },\n };\n}\n"],"names":["undiciFetch"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AAkBM,SAAU,YAAY,CAAmB,IAAsB,EAAA;AACnE,IAAA,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,GAAG,UAAU,GAAG,SAAS;IAChD,MAAM,MAAM,GAAG,mBAAmB,CAAQ;AACxC,QAAA,OAAO,EAAE,CAAA,EAAG,MAAM,GAAG,IAAI,CAAC,WAAW,CAAA,CAAE;AACvC,QAAA,KAAK,EAAE,CAAC,KAAc,KAAuB;AAC3C,YAAA,OAAOA,KAAW,CAAC,KAAK,CAAC,GAAG,EAAE;AAC5B,gBAAA,GAAG,KAAK;gBACR,UAAU,EAAE,IAAI,CAAC,UAAU;AAC5B,aAAA,CAAC;QACJ,CAAC;AACF,KAAA,CAAC;IACF,MAAM,CAAC,GAAG,CAAC,sBAAsB,EAAE,EAAE,GAAG,IAAI,CAAC,WAAW,CAAC;AACzD,IAAA,OAAO,MAAM;AACf;AAOO,eAAe,kBAAkB,CAAC,QAAkB,EAAA;AAIzD,IAAA,IAAI,QAAQ,CAAC,MAAM,GAAG,GAAG,EAAE;AACzB,QAAA,OAAO,EAAE;IACX;IAEA,IAAI,KAAK,GAAQ,MAAM,QAAQ,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE;IAC9C,MAAM,QAAQ,GAAG,KAAK;AACtB,IAAA,IAAI;AACF,QAAA,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAkB;IAC5C;AAAE,IAAA,MAAM;IACR;IACA,OAAO;AACL,QAAA,KAAK,EAAE,KAAK;QACZ;KACD;AACH;AAEA;;;AAGG;AACH,SAAS,sBAAsB,GAAA;IAC7B,OAAO;AACL,QAAA,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAI;AACvE,YAAA,MAAM,OAAO,GAAG,MAAM,kBAAkB,CAAC,QAAQ,CAAC;AAClD,YAAA,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE;gBAClB,MAAM,EAAE,IAAI,EAAE,GAAG,UAAU,EAAE,GAAG,QAAQ;AACxC,gBAAA,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE,EAAE,GAAG,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;YACvE;AAEA,YAAA,IAAI,OAAO,OAAO,CAAC,KAAK,KAAK,QAAQ,EAAE;AACrC,gBAAA,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;YAChC;AAEA,YAAA,sBAAsB,CAAC,OAAO,CAAC,KAAK,CAAC;QACvC,CAAC;KACF;AACH;;;;"}