@milaboratories/pl-client 2.17.7 → 2.17.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 (276) hide show
  1. package/dist/_virtual/_rolldown/runtime.cjs +43 -0
  2. package/dist/_virtual/_rolldown/runtime.js +18 -0
  3. package/dist/core/PromiseTracker.cjs +33 -33
  4. package/dist/core/PromiseTracker.cjs.map +1 -1
  5. package/dist/core/PromiseTracker.d.ts +10 -7
  6. package/dist/core/PromiseTracker.js +33 -31
  7. package/dist/core/PromiseTracker.js.map +1 -1
  8. package/dist/core/StatefulPromise.cjs +60 -61
  9. package/dist/core/StatefulPromise.cjs.map +1 -1
  10. package/dist/core/StatefulPromise.js +60 -60
  11. package/dist/core/StatefulPromise.js.map +1 -1
  12. package/dist/core/abstract_stream.d.ts +18 -15
  13. package/dist/core/advisory_locks.cjs +42 -49
  14. package/dist/core/advisory_locks.cjs.map +1 -1
  15. package/dist/core/advisory_locks.js +42 -48
  16. package/dist/core/advisory_locks.js.map +1 -1
  17. package/dist/core/auth.cjs +10 -15
  18. package/dist/core/auth.cjs.map +1 -1
  19. package/dist/core/auth.d.ts +7 -3
  20. package/dist/core/auth.js +10 -13
  21. package/dist/core/auth.js.map +1 -1
  22. package/dist/core/cache.d.ts +11 -7
  23. package/dist/core/client.cjs +255 -306
  24. package/dist/core/client.cjs.map +1 -1
  25. package/dist/core/client.d.ts +72 -68
  26. package/dist/core/client.js +253 -285
  27. package/dist/core/client.js.map +1 -1
  28. package/dist/core/config.cjs +81 -99
  29. package/dist/core/config.cjs.map +1 -1
  30. package/dist/core/config.d.ts +93 -90
  31. package/dist/core/config.js +81 -98
  32. package/dist/core/config.js.map +1 -1
  33. package/dist/core/default_client.cjs +84 -125
  34. package/dist/core/default_client.cjs.map +1 -1
  35. package/dist/core/default_client.d.ts +9 -6
  36. package/dist/core/default_client.js +78 -103
  37. package/dist/core/default_client.js.map +1 -1
  38. package/dist/core/driver.cjs +12 -16
  39. package/dist/core/driver.cjs.map +1 -1
  40. package/dist/core/driver.d.ts +18 -14
  41. package/dist/core/driver.js +12 -15
  42. package/dist/core/driver.js.map +1 -1
  43. package/dist/core/error_resource.cjs +5 -4
  44. package/dist/core/error_resource.cjs.map +1 -1
  45. package/dist/core/error_resource.js +5 -3
  46. package/dist/core/error_resource.js.map +1 -1
  47. package/dist/core/errors.cjs +104 -140
  48. package/dist/core/errors.cjs.map +1 -1
  49. package/dist/core/errors.d.ts +34 -30
  50. package/dist/core/errors.js +102 -137
  51. package/dist/core/errors.js.map +1 -1
  52. package/dist/core/final.cjs +63 -89
  53. package/dist/core/final.cjs.map +1 -1
  54. package/dist/core/final.d.ts +8 -4
  55. package/dist/core/final.js +63 -87
  56. package/dist/core/final.js.map +1 -1
  57. package/dist/core/ll_client.cjs +416 -521
  58. package/dist/core/ll_client.cjs.map +1 -1
  59. package/dist/core/ll_client.d.ts +100 -97
  60. package/dist/core/ll_client.js +415 -519
  61. package/dist/core/ll_client.js.map +1 -1
  62. package/dist/core/ll_transaction.cjs +206 -240
  63. package/dist/core/ll_transaction.cjs.map +1 -1
  64. package/dist/core/ll_transaction.d.ts +50 -52
  65. package/dist/core/ll_transaction.js +205 -238
  66. package/dist/core/ll_transaction.js.map +1 -1
  67. package/dist/core/stat.cjs +64 -63
  68. package/dist/core/stat.cjs.map +1 -1
  69. package/dist/core/stat.d.ts +35 -36
  70. package/dist/core/stat.js +64 -62
  71. package/dist/core/stat.js.map +1 -1
  72. package/dist/core/transaction.cjs +613 -650
  73. package/dist/core/transaction.cjs.map +1 -1
  74. package/dist/core/transaction.d.ts +165 -162
  75. package/dist/core/transaction.js +612 -648
  76. package/dist/core/transaction.js.map +1 -1
  77. package/dist/core/type_conversion.cjs +62 -83
  78. package/dist/core/type_conversion.cjs.map +1 -1
  79. package/dist/core/type_conversion.js +61 -81
  80. package/dist/core/type_conversion.js.map +1 -1
  81. package/dist/core/types.cjs +56 -86
  82. package/dist/core/types.cjs.map +1 -1
  83. package/dist/core/types.d.ts +63 -62
  84. package/dist/core/types.js +54 -83
  85. package/dist/core/types.js.map +1 -1
  86. package/dist/core/unauth_client.cjs +35 -41
  87. package/dist/core/unauth_client.cjs.map +1 -1
  88. package/dist/core/unauth_client.d.ts +18 -14
  89. package/dist/core/unauth_client.js +34 -39
  90. package/dist/core/unauth_client.js.map +1 -1
  91. package/dist/core/websocket_stream.cjs +280 -349
  92. package/dist/core/websocket_stream.cjs.map +1 -1
  93. package/dist/core/websocket_stream.js +278 -347
  94. package/dist/core/websocket_stream.js.map +1 -1
  95. package/dist/core/wire.d.ts +21 -17
  96. package/dist/helpers/pl.cjs +71 -73
  97. package/dist/helpers/pl.cjs.map +1 -1
  98. package/dist/helpers/pl.d.ts +40 -41
  99. package/dist/helpers/pl.js +66 -46
  100. package/dist/helpers/pl.js.map +1 -1
  101. package/dist/helpers/poll.cjs +99 -134
  102. package/dist/helpers/poll.cjs.map +1 -1
  103. package/dist/helpers/poll.d.ts +37 -34
  104. package/dist/helpers/poll.js +97 -113
  105. package/dist/helpers/poll.js.map +1 -1
  106. package/dist/helpers/retry_strategy.cjs +82 -87
  107. package/dist/helpers/retry_strategy.cjs.map +1 -1
  108. package/dist/helpers/retry_strategy.js +83 -86
  109. package/dist/helpers/retry_strategy.js.map +1 -1
  110. package/dist/helpers/tx_helpers.cjs +21 -20
  111. package/dist/helpers/tx_helpers.cjs.map +1 -1
  112. package/dist/helpers/tx_helpers.d.ts +11 -7
  113. package/dist/helpers/tx_helpers.js +20 -18
  114. package/dist/helpers/tx_helpers.js.map +1 -1
  115. package/dist/index.cjs +117 -106
  116. package/dist/index.d.ts +17 -17
  117. package/dist/index.js +17 -19
  118. package/dist/proto-grpc/github.com/googleapis/googleapis/google/rpc/status.cjs +72 -66
  119. package/dist/proto-grpc/github.com/googleapis/googleapis/google/rpc/status.cjs.map +1 -1
  120. package/dist/proto-grpc/github.com/googleapis/googleapis/google/rpc/status.d.ts +35 -37
  121. package/dist/proto-grpc/github.com/googleapis/googleapis/google/rpc/status.js +71 -64
  122. package/dist/proto-grpc/github.com/googleapis/googleapis/google/rpc/status.js.map +1 -1
  123. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.cjs +12611 -12866
  124. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.cjs.map +1 -1
  125. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.cjs +226 -226
  126. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.cjs.map +1 -1
  127. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.d.ts +281 -330
  128. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.js +225 -224
  129. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.js.map +1 -1
  130. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.d.ts +2640 -4294
  131. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.js +12608 -12706
  132. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.js.map +1 -1
  133. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.cjs +1230 -1089
  134. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.cjs.map +1 -1
  135. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.d.ts +393 -420
  136. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.js +1228 -1083
  137. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.js.map +1 -1
  138. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.cjs +142 -143
  139. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.cjs.map +1 -1
  140. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.d.ts +62 -64
  141. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.js +140 -141
  142. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.js.map +1 -1
  143. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/resource_types.cjs +572 -487
  144. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/resource_types.cjs.map +1 -1
  145. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/resource_types.d.ts +125 -228
  146. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/resource_types.js +572 -485
  147. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/resource_types.js.map +1 -1
  148. package/dist/proto-grpc/google/protobuf/any.cjs +131 -146
  149. package/dist/proto-grpc/google/protobuf/any.cjs.map +1 -1
  150. package/dist/proto-grpc/google/protobuf/any.d.ts +78 -84
  151. package/dist/proto-grpc/google/protobuf/any.js +130 -144
  152. package/dist/proto-grpc/google/protobuf/any.js.map +1 -1
  153. package/dist/proto-grpc/google/protobuf/duration.cjs +92 -100
  154. package/dist/proto-grpc/google/protobuf/duration.cjs.map +1 -1
  155. package/dist/proto-grpc/google/protobuf/duration.d.ts +38 -43
  156. package/dist/proto-grpc/google/protobuf/duration.js +91 -98
  157. package/dist/proto-grpc/google/protobuf/duration.js.map +1 -1
  158. package/dist/proto-grpc/google/protobuf/timestamp.cjs +117 -128
  159. package/dist/proto-grpc/google/protobuf/timestamp.cjs.map +1 -1
  160. package/dist/proto-grpc/google/protobuf/timestamp.d.ts +50 -55
  161. package/dist/proto-grpc/google/protobuf/timestamp.js +116 -126
  162. package/dist/proto-grpc/google/protobuf/timestamp.js.map +1 -1
  163. package/dist/proto-grpc/google/rpc/code.cjs +223 -238
  164. package/dist/proto-grpc/google/rpc/code.cjs.map +1 -1
  165. package/dist/proto-grpc/google/rpc/code.d.ts +209 -206
  166. package/dist/proto-grpc/google/rpc/code.js +221 -237
  167. package/dist/proto-grpc/google/rpc/code.js.map +1 -1
  168. package/dist/proto-rest/index.cjs +67 -66
  169. package/dist/proto-rest/index.cjs.map +1 -1
  170. package/dist/proto-rest/index.d.ts +24 -18
  171. package/dist/proto-rest/index.js +61 -65
  172. package/dist/proto-rest/index.js.map +1 -1
  173. package/dist/proto-rest/plapi.d.ts +1400 -1477
  174. package/dist/test/tcp-proxy.cjs +100 -126
  175. package/dist/test/tcp-proxy.cjs.map +1 -1
  176. package/dist/test/tcp-proxy.d.ts +17 -13
  177. package/dist/test/tcp-proxy.js +97 -104
  178. package/dist/test/tcp-proxy.js.map +1 -1
  179. package/dist/test/test_config.cjs +145 -194
  180. package/dist/test/test_config.cjs.map +1 -1
  181. package/dist/test/test_config.d.ts +34 -30
  182. package/dist/test/test_config.js +138 -166
  183. package/dist/test/test_config.js.map +1 -1
  184. package/dist/util/pl.cjs +4 -3
  185. package/dist/util/pl.cjs.map +1 -1
  186. package/dist/util/pl.js +4 -2
  187. package/dist/util/pl.js.map +1 -1
  188. package/dist/util/util.cjs +7 -10
  189. package/dist/util/util.cjs.map +1 -1
  190. package/dist/util/util.js +7 -9
  191. package/dist/util/util.js.map +1 -1
  192. package/package.json +8 -8
  193. package/src/core/errors.ts +1 -1
  194. package/src/core/transaction.ts +123 -133
  195. package/src/core/websocket_stream.ts +10 -1
  196. package/dist/__external/.pnpm/@rollup_plugin-typescript@12.3.0_rollup@4.52.4_tslib@2.8.1_typescript@5.6.3/__external/tslib/tslib.es6.cjs +0 -61
  197. package/dist/__external/.pnpm/@rollup_plugin-typescript@12.3.0_rollup@4.52.4_tslib@2.8.1_typescript@5.6.3/__external/tslib/tslib.es6.cjs.map +0 -1
  198. package/dist/__external/.pnpm/@rollup_plugin-typescript@12.3.0_rollup@4.52.4_tslib@2.8.1_typescript@5.6.3/__external/tslib/tslib.es6.js +0 -58
  199. package/dist/__external/.pnpm/@rollup_plugin-typescript@12.3.0_rollup@4.52.4_tslib@2.8.1_typescript@5.6.3/__external/tslib/tslib.es6.js.map +0 -1
  200. package/dist/core/PromiseTracker.d.ts.map +0 -1
  201. package/dist/core/StatefulPromise.d.ts +0 -39
  202. package/dist/core/StatefulPromise.d.ts.map +0 -1
  203. package/dist/core/abstract_stream.d.ts.map +0 -1
  204. package/dist/core/advisory_locks.d.ts +0 -10
  205. package/dist/core/advisory_locks.d.ts.map +0 -1
  206. package/dist/core/auth.d.ts.map +0 -1
  207. package/dist/core/cache.d.ts.map +0 -1
  208. package/dist/core/client.d.ts.map +0 -1
  209. package/dist/core/config.d.ts.map +0 -1
  210. package/dist/core/default_client.d.ts.map +0 -1
  211. package/dist/core/driver.d.ts.map +0 -1
  212. package/dist/core/error_resource.d.ts +0 -6
  213. package/dist/core/error_resource.d.ts.map +0 -1
  214. package/dist/core/errors.d.ts.map +0 -1
  215. package/dist/core/final.d.ts.map +0 -1
  216. package/dist/core/ll_client.d.ts.map +0 -1
  217. package/dist/core/ll_transaction.d.ts.map +0 -1
  218. package/dist/core/stat.d.ts.map +0 -1
  219. package/dist/core/transaction.d.ts.map +0 -1
  220. package/dist/core/type_conversion.d.ts +0 -8
  221. package/dist/core/type_conversion.d.ts.map +0 -1
  222. package/dist/core/types.d.ts.map +0 -1
  223. package/dist/core/unauth_client.d.ts.map +0 -1
  224. package/dist/core/websocket_stream.d.ts +0 -67
  225. package/dist/core/websocket_stream.d.ts.map +0 -1
  226. package/dist/core/wire.d.ts.map +0 -1
  227. package/dist/helpers/pl.d.ts.map +0 -1
  228. package/dist/helpers/poll.d.ts.map +0 -1
  229. package/dist/helpers/retry_strategy.d.ts +0 -24
  230. package/dist/helpers/retry_strategy.d.ts.map +0 -1
  231. package/dist/helpers/state_helpers.d.ts +0 -3
  232. package/dist/helpers/state_helpers.d.ts.map +0 -1
  233. package/dist/helpers/tx_helpers.d.ts.map +0 -1
  234. package/dist/index.cjs.map +0 -1
  235. package/dist/index.d.ts.map +0 -1
  236. package/dist/index.js.map +0 -1
  237. package/dist/proto-grpc/github.com/googleapis/googleapis/google/rpc/status.d.ts.map +0 -1
  238. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.d.ts.map +0 -1
  239. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.d.ts.map +0 -1
  240. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.d.ts.map +0 -1
  241. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.d.ts.map +0 -1
  242. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/import.d.ts +0 -106
  243. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/import.d.ts.map +0 -1
  244. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/resource_types.d.ts.map +0 -1
  245. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/ws-test.d.ts +0 -73
  246. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/ws-test.d.ts.map +0 -1
  247. package/dist/proto-grpc/google/api/http.d.ts +0 -456
  248. package/dist/proto-grpc/google/api/http.d.ts.map +0 -1
  249. package/dist/proto-grpc/google/protobuf/any.d.ts.map +0 -1
  250. package/dist/proto-grpc/google/protobuf/descriptor.d.ts +0 -2340
  251. package/dist/proto-grpc/google/protobuf/descriptor.d.ts.map +0 -1
  252. package/dist/proto-grpc/google/protobuf/duration.d.ts.map +0 -1
  253. package/dist/proto-grpc/google/protobuf/empty.d.ts +0 -32
  254. package/dist/proto-grpc/google/protobuf/empty.d.ts.map +0 -1
  255. package/dist/proto-grpc/google/protobuf/struct.d.ts +0 -187
  256. package/dist/proto-grpc/google/protobuf/struct.d.ts.map +0 -1
  257. package/dist/proto-grpc/google/protobuf/timestamp.d.ts.map +0 -1
  258. package/dist/proto-grpc/google/protobuf/wrappers.d.ts +0 -308
  259. package/dist/proto-grpc/google/protobuf/wrappers.d.ts.map +0 -1
  260. package/dist/proto-grpc/google/rpc/code.d.ts.map +0 -1
  261. package/dist/proto-grpc/google/rpc/error_details.d.ts +0 -654
  262. package/dist/proto-grpc/google/rpc/error_details.d.ts.map +0 -1
  263. package/dist/proto-grpc/google/rpc/http.d.ts +0 -121
  264. package/dist/proto-grpc/google/rpc/http.d.ts.map +0 -1
  265. package/dist/proto-grpc/google/rpc/status.d.ts +0 -55
  266. package/dist/proto-grpc/google/rpc/status.d.ts.map +0 -1
  267. package/dist/proto-rest/index.d.ts.map +0 -1
  268. package/dist/proto-rest/plapi.d.ts.map +0 -1
  269. package/dist/test/tcp-proxy.d.ts.map +0 -1
  270. package/dist/test/test_config.d.ts.map +0 -1
  271. package/dist/util/branding.d.ts +0 -7
  272. package/dist/util/branding.d.ts.map +0 -1
  273. package/dist/util/pl.d.ts +0 -9
  274. package/dist/util/pl.d.ts.map +0 -1
  275. package/dist/util/util.d.ts +0 -2
  276. package/dist/util/util.d.ts.map +0 -1
@@ -1,219 +1,170 @@
1
- 'use strict';
2
-
3
- var fs = require('node:fs');
4
- var ll_client = require('../core/ll_client.cjs');
5
- var config = require('../core/config.cjs');
6
- var unauth_client = require('../core/unauth_client.cjs');
7
- var client = require('../core/client.cjs');
8
- var node_crypto = require('node:crypto');
9
- var types = require('../core/types.cjs');
10
- var auth = require('../core/auth.cjs');
11
- var path = require('node:path');
12
- var tcpProxy = require('./tcp-proxy.cjs');
13
-
14
- function _interopNamespaceDefault(e) {
15
- var n = Object.create(null);
16
- if (e) {
17
- Object.keys(e).forEach(function (k) {
18
- if (k !== 'default') {
19
- var d = Object.getOwnPropertyDescriptor(e, k);
20
- Object.defineProperty(n, k, d.get ? d : {
21
- enumerable: true,
22
- get: function () { return e[k]; }
23
- });
24
- }
25
- });
26
- }
27
- n.default = e;
28
- return Object.freeze(n);
29
- }
30
-
31
- var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
32
- var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
1
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
+ const require_types = require('../core/types.cjs');
3
+ const require_config = require('../core/config.cjs');
4
+ const require_auth = require('../core/auth.cjs');
5
+ const require_ll_client = require('../core/ll_client.cjs');
6
+ const require_client = require('../core/client.cjs');
7
+ const require_unauth_client = require('../core/unauth_client.cjs');
8
+ const require_tcp_proxy = require('./tcp-proxy.cjs');
9
+ let node_crypto = require("node:crypto");
10
+ let node_fs = require("node:fs");
11
+ node_fs = require_runtime.__toESM(node_fs);
12
+ let node_path = require("node:path");
13
+ node_path = require_runtime.__toESM(node_path);
33
14
 
15
+ //#region src/test/test_config.ts
16
+ var test_config_exports = /* @__PURE__ */ require_runtime.__exportAll({
17
+ TEST_REQUEST_TIMEOUT: () => TEST_REQUEST_TIMEOUT,
18
+ getTestClient: () => getTestClient,
19
+ getTestClientConf: () => getTestClientConf,
20
+ getTestConfig: () => getTestConfig,
21
+ getTestLLClient: () => getTestLLClient,
22
+ plAddressToTestConfig: () => plAddressToTestConfig,
23
+ withTempRoot: () => withTempRoot
24
+ });
34
25
  const CONFIG_FILE = "test_config.json";
35
- // const AUTH_DATA_FILE = '.test_auth.json';
36
26
  let authDataFilePath;
37
27
  function getFullAuthDataFilePath() {
38
- if (authDataFilePath === undefined)
39
- authDataFilePath = path__namespace.resolve(".test_auth.json");
40
- return authDataFilePath;
28
+ if (authDataFilePath === void 0) authDataFilePath = node_path.resolve(".test_auth.json");
29
+ return authDataFilePath;
41
30
  }
42
31
  function getTestConfig() {
43
- let conf = {};
44
- if (fs__namespace.existsSync(CONFIG_FILE))
45
- conf = JSON.parse(fs__namespace.readFileSync(CONFIG_FILE, { encoding: "utf-8" }));
46
- if (process.env.PL_ADDRESS !== undefined)
47
- conf.address = process.env.PL_ADDRESS;
48
- if (process.env.PL_TEST_USER !== undefined)
49
- conf.test_user = process.env.PL_TEST_USER;
50
- if (process.env.PL_TEST_PASSWORD !== undefined)
51
- conf.test_password = process.env.PL_TEST_PASSWORD;
52
- if (process.env.PL_TEST_PROXY !== undefined)
53
- conf.test_proxy = process.env.PL_TEST_PROXY;
54
- if (conf.address === undefined)
55
- throw new Error(`can't resolve platform address (checked ${CONFIG_FILE} file and PL_ADDRESS environment var)`);
56
- return conf;
32
+ let conf = {};
33
+ if (node_fs.existsSync(CONFIG_FILE)) conf = JSON.parse(node_fs.readFileSync(CONFIG_FILE, { encoding: "utf-8" }));
34
+ if (process.env.PL_ADDRESS !== void 0) conf.address = process.env.PL_ADDRESS;
35
+ if (process.env.PL_TEST_USER !== void 0) conf.test_user = process.env.PL_TEST_USER;
36
+ if (process.env.PL_TEST_PASSWORD !== void 0) conf.test_password = process.env.PL_TEST_PASSWORD;
37
+ if (process.env.PL_TEST_PROXY !== void 0) conf.test_proxy = process.env.PL_TEST_PROXY;
38
+ if (conf.address === void 0) throw new Error(`can't resolve platform address (checked ${CONFIG_FILE} file and PL_ADDRESS environment var)`);
39
+ return conf;
57
40
  }
58
41
  /** Default request timeout for tests (ms) */
59
42
  const TEST_REQUEST_TIMEOUT = 500;
60
43
  /** Returns PlClientConfig with reduced timeout for tests */
61
44
  function plAddressToTestConfig(address) {
62
- const plConf = config.plAddressToConfig(address);
63
- plConf.defaultRequestTimeout = TEST_REQUEST_TIMEOUT;
64
- return plConf;
45
+ const plConf = require_config.plAddressToConfig(address);
46
+ plConf.defaultRequestTimeout = TEST_REQUEST_TIMEOUT;
47
+ return plConf;
65
48
  }
66
49
  function saveAuthInfoCallback(tConf) {
67
- return (authInformation) => {
68
- const dst = getFullAuthDataFilePath();
69
- const tmpDst = getFullAuthDataFilePath() + node_crypto.randomUUID();
70
- fs__namespace.writeFileSync(tmpDst, Buffer.from(JSON.stringify({
71
- conf: tConf,
72
- authInformation,
73
- expiration: auth.inferAuthRefreshTime(authInformation, 24 * 60 * 60),
74
- })), "utf8");
75
- fs__namespace.renameSync(tmpDst, dst);
76
- };
50
+ return (authInformation) => {
51
+ const dst = getFullAuthDataFilePath();
52
+ const tmpDst = getFullAuthDataFilePath() + (0, node_crypto.randomUUID)();
53
+ node_fs.writeFileSync(tmpDst, Buffer.from(JSON.stringify({
54
+ conf: tConf,
55
+ authInformation,
56
+ expiration: require_auth.inferAuthRefreshTime(authInformation, 1440 * 60)
57
+ })), "utf8");
58
+ node_fs.renameSync(tmpDst, dst);
59
+ };
77
60
  }
78
61
  const cleanAuthInfoCallback = () => {
79
- console.warn(`Removing: ${getFullAuthDataFilePath()}`);
80
- fs__namespace.rmSync(getFullAuthDataFilePath());
62
+ console.warn(`Removing: ${getFullAuthDataFilePath()}`);
63
+ node_fs.rmSync(getFullAuthDataFilePath());
81
64
  };
82
65
  async function getTestClientConf() {
83
- const tConf = getTestConfig();
84
- let authInformation = undefined;
85
- // try recover from cache
86
- if (fs__namespace.existsSync(getFullAuthDataFilePath())) {
87
- try {
88
- const cache = JSON.parse(fs__namespace.readFileSync(getFullAuthDataFilePath(), { encoding: "utf-8" })); // TODO runtime validation
89
- if (cache.conf.address === tConf.address &&
90
- cache.conf.test_user === tConf.test_user &&
91
- cache.conf.test_password === tConf.test_password &&
92
- cache.expiration > Date.now())
93
- authInformation = cache.authInformation;
94
- }
95
- catch {
96
- // removing cache file on any error
97
- fs__namespace.rmSync(getFullAuthDataFilePath());
98
- }
99
- }
100
- const plConf = plAddressToTestConfig(tConf.address);
101
- const uClient = await unauth_client.UnauthenticatedPlClient.build(plConf);
102
- const requireAuth = await uClient.requireAuth();
103
- if (!requireAuth && (tConf.test_user !== undefined || tConf.test_password !== undefined))
104
- throw new Error(`Server require no auth, but test user name or test password are provided via (${CONFIG_FILE}) or env variables: PL_TEST_USER and PL_TEST_PASSWORD`);
105
- if (requireAuth && (tConf.test_user === undefined || tConf.test_password === undefined))
106
- throw new Error(`No auth information found in config (${CONFIG_FILE}) or env variables: PL_TEST_USER and PL_TEST_PASSWORD`);
107
- if (authInformation === undefined) {
108
- if (requireAuth)
109
- authInformation = await uClient.login(tConf.test_user, tConf.test_password);
110
- // No authorization is required
111
- else
112
- authInformation = {};
113
- // saving cache
114
- saveAuthInfoCallback(tConf)(authInformation);
115
- }
116
- return {
117
- conf: plConf,
118
- auth: {
119
- authInformation,
120
- onUpdate: saveAuthInfoCallback(tConf),
121
- onAuthError: cleanAuthInfoCallback,
122
- onUpdateError: cleanAuthInfoCallback,
123
- },
124
- };
66
+ const tConf = getTestConfig();
67
+ let authInformation = void 0;
68
+ if (node_fs.existsSync(getFullAuthDataFilePath())) try {
69
+ const cache = JSON.parse(node_fs.readFileSync(getFullAuthDataFilePath(), { encoding: "utf-8" }));
70
+ if (cache.conf.address === tConf.address && cache.conf.test_user === tConf.test_user && cache.conf.test_password === tConf.test_password && cache.expiration > Date.now()) authInformation = cache.authInformation;
71
+ } catch {
72
+ node_fs.rmSync(getFullAuthDataFilePath());
73
+ }
74
+ const plConf = plAddressToTestConfig(tConf.address);
75
+ const uClient = await require_unauth_client.UnauthenticatedPlClient.build(plConf);
76
+ const requireAuth = await uClient.requireAuth();
77
+ if (!requireAuth && (tConf.test_user !== void 0 || tConf.test_password !== void 0)) throw new Error(`Server require no auth, but test user name or test password are provided via (${CONFIG_FILE}) or env variables: PL_TEST_USER and PL_TEST_PASSWORD`);
78
+ if (requireAuth && (tConf.test_user === void 0 || tConf.test_password === void 0)) throw new Error(`No auth information found in config (${CONFIG_FILE}) or env variables: PL_TEST_USER and PL_TEST_PASSWORD`);
79
+ if (authInformation === void 0) {
80
+ if (requireAuth) authInformation = await uClient.login(tConf.test_user, tConf.test_password);
81
+ else authInformation = {};
82
+ saveAuthInfoCallback(tConf)(authInformation);
83
+ }
84
+ return {
85
+ conf: plConf,
86
+ auth: {
87
+ authInformation,
88
+ onUpdate: saveAuthInfoCallback(tConf),
89
+ onAuthError: cleanAuthInfoCallback,
90
+ onUpdateError: cleanAuthInfoCallback
91
+ }
92
+ };
125
93
  }
126
94
  async function getTestLLClient(confOverrides = {}) {
127
- const { conf, auth } = await getTestClientConf();
128
- return await ll_client.LLPlClient.build({ ...conf, ...confOverrides }, { auth });
95
+ const { conf, auth } = await getTestClientConf();
96
+ return await require_ll_client.LLPlClient.build({
97
+ ...conf,
98
+ ...confOverrides
99
+ }, { auth });
129
100
  }
130
101
  async function getTestClient(alternativeRoot, confOverrides = {}) {
131
- const { conf, auth } = await getTestClientConf();
132
- if (alternativeRoot !== undefined && conf.alternativeRoot !== undefined)
133
- throw new Error("test pl address configured with alternative root");
134
- return await client.PlClient.init({ ...conf, ...confOverrides, alternativeRoot }, auth);
102
+ const { conf, auth } = await getTestClientConf();
103
+ if (alternativeRoot !== void 0 && conf.alternativeRoot !== void 0) throw new Error("test pl address configured with alternative root");
104
+ return await require_client.PlClient.init({
105
+ ...conf,
106
+ ...confOverrides,
107
+ alternativeRoot
108
+ }, auth);
135
109
  }
136
110
  async function withTempRoot(body, options = {}) {
137
- const alternativeRoot = `test_${Date.now()}_${node_crypto.randomUUID()}`;
138
- let altRootId = types.NullResourceId;
139
- // Proxy management
140
- let proxy;
141
- let confOverrides = {};
142
- try {
143
- // Optionally start TCP proxy and rewrite PL_ADDRESS to point to proxy
144
- if (options.viaTcpProxy === true && process.env.PL_ADDRESS) {
145
- try {
146
- const url = new URL(process.env.PL_ADDRESS);
147
- const isHttp = url.protocol === "http:";
148
- const isLocal = url.hostname === "127.0.0.1" || url.hostname === "localhost";
149
- const port = parseInt(url.port);
150
- if (isHttp && isLocal && Number.isFinite(port)) {
151
- proxy = await tcpProxy.startTcpProxy({ targetPort: port, latency: options.proxyLatencyMs ?? 0 });
152
- // Override client connection host:port to proxy
153
- confOverrides = { hostAndPort: `127.0.0.1:${proxy.port}` };
154
- }
155
- else {
156
- console.warn("*** skipping proxy-based test, PL_ADDRESS is not localhost", process.env.PL_ADDRESS);
157
- return;
158
- }
159
- }
160
- catch {
161
- // ignore proxy setup errors; tests will run against original address
162
- }
163
- }
164
- const client = await getTestClient(alternativeRoot, confOverrides);
165
- altRootId = client.clientRoot;
166
- try {
167
- const value = await body(client, proxy);
168
- const rawClient = await getTestClient();
169
- try {
170
- await rawClient.deleteAlternativeRoot(alternativeRoot);
171
- }
172
- catch (cleanupErr) {
173
- // Cleanup may fail if test intentionally deleted resources
174
- console.warn(`Failed to clean up alternative root ${alternativeRoot}:`, cleanupErr.message);
175
- }
176
- finally {
177
- // Close the cleanup client to avoid dangling gRPC channels that can cause
178
- // segfaults during process exit
179
- await rawClient.close();
180
- }
181
- return value;
182
- }
183
- finally {
184
- // Close the test client to avoid dangling gRPC channels
185
- await client.close();
186
- }
187
- }
188
- catch (err) {
189
- console.log(`ALTERNATIVE ROOT: ${alternativeRoot} (${types.resourceIdToString(altRootId)})`);
190
- throw err;
191
- // throw new Error('withTempRoot error: ' + err.message, { cause: err });
192
- }
193
- finally {
194
- // Stop proxy if started
195
- if (proxy) {
196
- try {
197
- await proxy.disconnectAll();
198
- }
199
- catch {
200
- /* ignore */
201
- }
202
- try {
203
- await new Promise((resolve) => proxy.server.close(() => resolve()));
204
- }
205
- catch {
206
- /* ignore */
207
- }
208
- }
209
- }
111
+ const alternativeRoot = `test_${Date.now()}_${(0, node_crypto.randomUUID)()}`;
112
+ let altRootId = require_types.NullResourceId;
113
+ let proxy;
114
+ let confOverrides = {};
115
+ try {
116
+ if (options.viaTcpProxy === true && process.env.PL_ADDRESS) try {
117
+ const url = new URL(process.env.PL_ADDRESS);
118
+ const isHttp = url.protocol === "http:";
119
+ const isLocal = url.hostname === "127.0.0.1" || url.hostname === "localhost";
120
+ const port = parseInt(url.port);
121
+ if (isHttp && isLocal && Number.isFinite(port)) {
122
+ proxy = await require_tcp_proxy.startTcpProxy({
123
+ targetPort: port,
124
+ latency: options.proxyLatencyMs ?? 0
125
+ });
126
+ confOverrides = { hostAndPort: `127.0.0.1:${proxy.port}` };
127
+ } else {
128
+ console.warn("*** skipping proxy-based test, PL_ADDRESS is not localhost", process.env.PL_ADDRESS);
129
+ return;
130
+ }
131
+ } catch {}
132
+ const client = await getTestClient(alternativeRoot, confOverrides);
133
+ altRootId = client.clientRoot;
134
+ try {
135
+ const value = await body(client, proxy);
136
+ const rawClient = await getTestClient();
137
+ try {
138
+ await rawClient.deleteAlternativeRoot(alternativeRoot);
139
+ } catch (cleanupErr) {
140
+ console.warn(`Failed to clean up alternative root ${alternativeRoot}:`, cleanupErr.message);
141
+ } finally {
142
+ await rawClient.close();
143
+ }
144
+ return value;
145
+ } finally {
146
+ await client.close();
147
+ }
148
+ } catch (err) {
149
+ console.log(`ALTERNATIVE ROOT: ${alternativeRoot} (${require_types.resourceIdToString(altRootId)})`);
150
+ throw err;
151
+ } finally {
152
+ if (proxy) {
153
+ try {
154
+ await proxy.disconnectAll();
155
+ } catch {}
156
+ try {
157
+ await new Promise((resolve) => proxy.server.close(() => resolve()));
158
+ } catch {}
159
+ }
160
+ }
210
161
  }
211
162
 
212
- exports.TEST_REQUEST_TIMEOUT = TEST_REQUEST_TIMEOUT;
213
- exports.getTestClient = getTestClient;
214
- exports.getTestClientConf = getTestClientConf;
215
- exports.getTestConfig = getTestConfig;
216
- exports.getTestLLClient = getTestLLClient;
217
- exports.plAddressToTestConfig = plAddressToTestConfig;
218
- exports.withTempRoot = withTempRoot;
219
- //# sourceMappingURL=test_config.cjs.map
163
+ //#endregion
164
+ Object.defineProperty(exports, 'test_config_exports', {
165
+ enumerable: true,
166
+ get: function () {
167
+ return test_config_exports;
168
+ }
169
+ });
170
+ //# sourceMappingURL=test_config.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"test_config.cjs","sources":["../../src/test/test_config.ts"],"sourcesContent":["import * as fs from \"node:fs\";\nimport { LLPlClient } from \"../core/ll_client\";\nimport type { AuthInformation, AuthOps, PlClientConfig } from \"../core/config\";\nimport { plAddressToConfig } from \"../core/config\";\nimport { UnauthenticatedPlClient } from \"../core/unauth_client\";\nimport { PlClient } from \"../core/client\";\nimport { randomUUID } from \"node:crypto\";\nimport type { OptionalResourceId } from \"../core/types\";\nimport { NullResourceId, resourceIdToString } from \"../core/types\";\nimport { inferAuthRefreshTime } from \"../core/auth\";\nimport * as path from \"node:path\";\nimport type { TestTcpProxy } from \"./tcp-proxy\";\nimport { startTcpProxy } from \"./tcp-proxy\";\n\nexport { TestTcpProxy };\n\nexport interface TestConfig {\n address: string;\n test_proxy?: string;\n test_user?: string;\n test_password?: string;\n}\n\nconst CONFIG_FILE = \"test_config.json\";\n// const AUTH_DATA_FILE = '.test_auth.json';\n\nlet authDataFilePath: string | undefined;\n\nfunction getFullAuthDataFilePath() {\n if (authDataFilePath === undefined) authDataFilePath = path.resolve(\".test_auth.json\");\n return authDataFilePath;\n}\n\nexport function getTestConfig(): TestConfig {\n let conf: Partial<TestConfig> = {};\n if (fs.existsSync(CONFIG_FILE))\n conf = JSON.parse(fs.readFileSync(CONFIG_FILE, { encoding: \"utf-8\" })) as TestConfig;\n\n if (process.env.PL_ADDRESS !== undefined) conf.address = process.env.PL_ADDRESS;\n\n if (process.env.PL_TEST_USER !== undefined) conf.test_user = process.env.PL_TEST_USER;\n\n if (process.env.PL_TEST_PASSWORD !== undefined) conf.test_password = process.env.PL_TEST_PASSWORD;\n\n if (process.env.PL_TEST_PROXY !== undefined) conf.test_proxy = process.env.PL_TEST_PROXY;\n\n if (conf.address === undefined)\n throw new Error(\n `can't resolve platform address (checked ${CONFIG_FILE} file and PL_ADDRESS environment var)`,\n );\n\n return conf as TestConfig;\n}\n\n/** Default request timeout for tests (ms) */\nexport const TEST_REQUEST_TIMEOUT = 500;\n\n/** Returns PlClientConfig with reduced timeout for tests */\nexport function plAddressToTestConfig(address: string): PlClientConfig {\n const plConf = plAddressToConfig(address);\n plConf.defaultRequestTimeout = TEST_REQUEST_TIMEOUT;\n return plConf;\n}\n\ninterface AuthCache {\n /** To check if config changed */\n conf: TestConfig;\n expiration: number;\n authInformation: AuthInformation;\n}\n\nfunction saveAuthInfoCallback(tConf: TestConfig): (authInformation: AuthInformation) => void {\n return (authInformation) => {\n const dst = getFullAuthDataFilePath();\n const tmpDst = getFullAuthDataFilePath() + randomUUID();\n fs.writeFileSync(\n tmpDst,\n Buffer.from(\n JSON.stringify({\n conf: tConf,\n authInformation,\n expiration: inferAuthRefreshTime(authInformation, 24 * 60 * 60),\n } as AuthCache),\n ),\n \"utf8\",\n );\n fs.renameSync(tmpDst, dst);\n };\n}\n\nconst cleanAuthInfoCallback = () => {\n console.warn(`Removing: ${getFullAuthDataFilePath()}`);\n fs.rmSync(getFullAuthDataFilePath());\n};\n\nexport async function getTestClientConf(): Promise<{ conf: PlClientConfig; auth: AuthOps }> {\n const tConf = getTestConfig();\n\n let authInformation: AuthInformation | undefined = undefined;\n\n // try recover from cache\n if (fs.existsSync(getFullAuthDataFilePath())) {\n try {\n const cache: AuthCache = JSON.parse(\n fs.readFileSync(getFullAuthDataFilePath(), { encoding: \"utf-8\" }),\n ) as AuthCache; // TODO runtime validation\n if (\n cache.conf.address === tConf.address &&\n cache.conf.test_user === tConf.test_user &&\n cache.conf.test_password === tConf.test_password &&\n cache.expiration > Date.now()\n )\n authInformation = cache.authInformation;\n } catch {\n // removing cache file on any error\n fs.rmSync(getFullAuthDataFilePath());\n }\n }\n\n const plConf = plAddressToTestConfig(tConf.address);\n const uClient = await UnauthenticatedPlClient.build(plConf);\n\n const requireAuth = await uClient.requireAuth();\n\n if (!requireAuth && (tConf.test_user !== undefined || tConf.test_password !== undefined))\n throw new Error(\n `Server require no auth, but test user name or test password are provided via (${CONFIG_FILE}) or env variables: PL_TEST_USER and PL_TEST_PASSWORD`,\n );\n\n if (requireAuth && (tConf.test_user === undefined || tConf.test_password === undefined))\n throw new Error(\n `No auth information found in config (${CONFIG_FILE}) or env variables: PL_TEST_USER and PL_TEST_PASSWORD`,\n );\n\n if (authInformation === undefined) {\n if (requireAuth) authInformation = await uClient.login(tConf.test_user!, tConf.test_password!);\n // No authorization is required\n else authInformation = {};\n\n // saving cache\n saveAuthInfoCallback(tConf)(authInformation);\n }\n\n return {\n conf: plConf,\n auth: {\n authInformation,\n onUpdate: saveAuthInfoCallback(tConf),\n onAuthError: cleanAuthInfoCallback,\n onUpdateError: cleanAuthInfoCallback,\n },\n };\n}\n\nexport async function getTestLLClient(confOverrides: Partial<PlClientConfig> = {}) {\n const { conf, auth } = await getTestClientConf();\n return await LLPlClient.build({ ...conf, ...confOverrides }, { auth });\n}\n\nexport async function getTestClient(\n alternativeRoot?: string,\n confOverrides: Partial<PlClientConfig> = {},\n) {\n const { conf, auth } = await getTestClientConf();\n if (alternativeRoot !== undefined && conf.alternativeRoot !== undefined)\n throw new Error(\"test pl address configured with alternative root\");\n return await PlClient.init({ ...conf, ...confOverrides, alternativeRoot }, auth);\n}\n\nexport type WithTempRootOptions =\n | {\n /** If true and PL_ADDRESS is http://localhost or http://127.0.0.1:<port>,\n * a TCP proxy will be started and PL client will connect through it. */\n viaTcpProxy: true;\n /** Artificial latency for proxy (ms). Default 0 */\n proxyLatencyMs?: number;\n }\n | {\n viaTcpProxy?: undefined;\n };\n\nexport async function withTempRoot<T>(body: (pl: PlClient) => Promise<T>): Promise<T | void>;\n\nexport async function withTempRoot<T>(\n body: (pl: PlClient, proxy: Awaited<ReturnType<typeof startTcpProxy>>) => Promise<T>,\n options: {\n viaTcpProxy: true;\n proxyLatencyMs?: number;\n },\n): Promise<T>;\n\nexport async function withTempRoot<T>(\n body: (pl: PlClient, proxy: any) => Promise<T>,\n options: WithTempRootOptions = {},\n): Promise<T | undefined> {\n const alternativeRoot = `test_${Date.now()}_${randomUUID()}`;\n let altRootId: OptionalResourceId = NullResourceId;\n // Proxy management\n let proxy: Awaited<ReturnType<typeof startTcpProxy>> | undefined;\n let confOverrides: Partial<PlClientConfig> = {};\n try {\n // Optionally start TCP proxy and rewrite PL_ADDRESS to point to proxy\n if (options.viaTcpProxy === true && process.env.PL_ADDRESS) {\n try {\n const url = new URL(process.env.PL_ADDRESS);\n const isHttp = url.protocol === \"http:\";\n const isLocal = url.hostname === \"127.0.0.1\" || url.hostname === \"localhost\";\n const port = parseInt(url.port);\n if (isHttp && isLocal && Number.isFinite(port)) {\n proxy = await startTcpProxy({ targetPort: port, latency: options.proxyLatencyMs ?? 0 });\n // Override client connection host:port to proxy\n confOverrides = { hostAndPort: `127.0.0.1:${proxy.port}` } as Partial<PlClientConfig>;\n } else {\n console.warn(\n \"*** skipping proxy-based test, PL_ADDRESS is not localhost\",\n process.env.PL_ADDRESS,\n );\n return;\n }\n } catch {\n // ignore proxy setup errors; tests will run against original address\n }\n }\n\n const client = await getTestClient(alternativeRoot, confOverrides);\n altRootId = client.clientRoot;\n try {\n const value = await body(client, proxy);\n const rawClient = await getTestClient();\n try {\n await rawClient.deleteAlternativeRoot(alternativeRoot);\n } catch (cleanupErr: any) {\n // Cleanup may fail if test intentionally deleted resources\n console.warn(`Failed to clean up alternative root ${alternativeRoot}:`, cleanupErr.message);\n } finally {\n // Close the cleanup client to avoid dangling gRPC channels that can cause\n // segfaults during process exit\n await rawClient.close();\n }\n return value;\n } finally {\n // Close the test client to avoid dangling gRPC channels\n await client.close();\n }\n } catch (err: any) {\n console.log(`ALTERNATIVE ROOT: ${alternativeRoot} (${resourceIdToString(altRootId)})`);\n throw err;\n // throw new Error('withTempRoot error: ' + err.message, { cause: err });\n } finally {\n // Stop proxy if started\n if (proxy) {\n try {\n await proxy.disconnectAll();\n } catch {\n /* ignore */\n }\n try {\n await new Promise<void>((resolve) => proxy!.server.close(() => resolve()));\n } catch {\n /* ignore */\n }\n }\n }\n}\n"],"names":["path","fs","plAddressToConfig","randomUUID","inferAuthRefreshTime","UnauthenticatedPlClient","LLPlClient","PlClient","NullResourceId","startTcpProxy","resourceIdToString"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAM,WAAW,GAAG,kBAAkB;AACtC;AAEA,IAAI,gBAAoC;AAExC,SAAS,uBAAuB,GAAA;IAC9B,IAAI,gBAAgB,KAAK,SAAS;AAAE,QAAA,gBAAgB,GAAGA,eAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC;AACtF,IAAA,OAAO,gBAAgB;AACzB;SAEgB,aAAa,GAAA;IAC3B,IAAI,IAAI,GAAwB,EAAE;AAClC,IAAA,IAAIC,aAAE,CAAC,UAAU,CAAC,WAAW,CAAC;AAC5B,QAAA,IAAI,GAAG,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OAAO,KAAK,KAAM,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,OAAO,EAAE,CAAC,CAAC;YAC5E;AAAE,YAAA,MAAM;;YAER;QACF;IACF;AACF;;;;;;;;;;"}
1
+ {"version":3,"file":"test_config.cjs","names":["path","fs","plAddressToConfig","inferAuthRefreshTime","UnauthenticatedPlClient","LLPlClient","PlClient","NullResourceId","startTcpProxy","resourceIdToString"],"sources":["../../src/test/test_config.ts"],"sourcesContent":["import * as fs from \"node:fs\";\nimport { LLPlClient } from \"../core/ll_client\";\nimport type { AuthInformation, AuthOps, PlClientConfig } from \"../core/config\";\nimport { plAddressToConfig } from \"../core/config\";\nimport { UnauthenticatedPlClient } from \"../core/unauth_client\";\nimport { PlClient } from \"../core/client\";\nimport { randomUUID } from \"node:crypto\";\nimport type { OptionalResourceId } from \"../core/types\";\nimport { NullResourceId, resourceIdToString } from \"../core/types\";\nimport { inferAuthRefreshTime } from \"../core/auth\";\nimport * as path from \"node:path\";\nimport type { TestTcpProxy } from \"./tcp-proxy\";\nimport { startTcpProxy } from \"./tcp-proxy\";\n\nexport { TestTcpProxy };\n\nexport interface TestConfig {\n address: string;\n test_proxy?: string;\n test_user?: string;\n test_password?: string;\n}\n\nconst CONFIG_FILE = \"test_config.json\";\n// const AUTH_DATA_FILE = '.test_auth.json';\n\nlet authDataFilePath: string | undefined;\n\nfunction getFullAuthDataFilePath() {\n if (authDataFilePath === undefined) authDataFilePath = path.resolve(\".test_auth.json\");\n return authDataFilePath;\n}\n\nexport function getTestConfig(): TestConfig {\n let conf: Partial<TestConfig> = {};\n if (fs.existsSync(CONFIG_FILE))\n conf = JSON.parse(fs.readFileSync(CONFIG_FILE, { encoding: \"utf-8\" })) as TestConfig;\n\n if (process.env.PL_ADDRESS !== undefined) conf.address = process.env.PL_ADDRESS;\n\n if (process.env.PL_TEST_USER !== undefined) conf.test_user = process.env.PL_TEST_USER;\n\n if (process.env.PL_TEST_PASSWORD !== undefined) conf.test_password = process.env.PL_TEST_PASSWORD;\n\n if (process.env.PL_TEST_PROXY !== undefined) conf.test_proxy = process.env.PL_TEST_PROXY;\n\n if (conf.address === undefined)\n throw new Error(\n `can't resolve platform address (checked ${CONFIG_FILE} file and PL_ADDRESS environment var)`,\n );\n\n return conf as TestConfig;\n}\n\n/** Default request timeout for tests (ms) */\nexport const TEST_REQUEST_TIMEOUT = 500;\n\n/** Returns PlClientConfig with reduced timeout for tests */\nexport function plAddressToTestConfig(address: string): PlClientConfig {\n const plConf = plAddressToConfig(address);\n plConf.defaultRequestTimeout = TEST_REQUEST_TIMEOUT;\n return plConf;\n}\n\ninterface AuthCache {\n /** To check if config changed */\n conf: TestConfig;\n expiration: number;\n authInformation: AuthInformation;\n}\n\nfunction saveAuthInfoCallback(tConf: TestConfig): (authInformation: AuthInformation) => void {\n return (authInformation) => {\n const dst = getFullAuthDataFilePath();\n const tmpDst = getFullAuthDataFilePath() + randomUUID();\n fs.writeFileSync(\n tmpDst,\n Buffer.from(\n JSON.stringify({\n conf: tConf,\n authInformation,\n expiration: inferAuthRefreshTime(authInformation, 24 * 60 * 60),\n } as AuthCache),\n ),\n \"utf8\",\n );\n fs.renameSync(tmpDst, dst);\n };\n}\n\nconst cleanAuthInfoCallback = () => {\n console.warn(`Removing: ${getFullAuthDataFilePath()}`);\n fs.rmSync(getFullAuthDataFilePath());\n};\n\nexport async function getTestClientConf(): Promise<{ conf: PlClientConfig; auth: AuthOps }> {\n const tConf = getTestConfig();\n\n let authInformation: AuthInformation | undefined = undefined;\n\n // try recover from cache\n if (fs.existsSync(getFullAuthDataFilePath())) {\n try {\n const cache: AuthCache = JSON.parse(\n fs.readFileSync(getFullAuthDataFilePath(), { encoding: \"utf-8\" }),\n ) as AuthCache; // TODO runtime validation\n if (\n cache.conf.address === tConf.address &&\n cache.conf.test_user === tConf.test_user &&\n cache.conf.test_password === tConf.test_password &&\n cache.expiration > Date.now()\n )\n authInformation = cache.authInformation;\n } catch {\n // removing cache file on any error\n fs.rmSync(getFullAuthDataFilePath());\n }\n }\n\n const plConf = plAddressToTestConfig(tConf.address);\n const uClient = await UnauthenticatedPlClient.build(plConf);\n\n const requireAuth = await uClient.requireAuth();\n\n if (!requireAuth && (tConf.test_user !== undefined || tConf.test_password !== undefined))\n throw new Error(\n `Server require no auth, but test user name or test password are provided via (${CONFIG_FILE}) or env variables: PL_TEST_USER and PL_TEST_PASSWORD`,\n );\n\n if (requireAuth && (tConf.test_user === undefined || tConf.test_password === undefined))\n throw new Error(\n `No auth information found in config (${CONFIG_FILE}) or env variables: PL_TEST_USER and PL_TEST_PASSWORD`,\n );\n\n if (authInformation === undefined) {\n if (requireAuth) authInformation = await uClient.login(tConf.test_user!, tConf.test_password!);\n // No authorization is required\n else authInformation = {};\n\n // saving cache\n saveAuthInfoCallback(tConf)(authInformation);\n }\n\n return {\n conf: plConf,\n auth: {\n authInformation,\n onUpdate: saveAuthInfoCallback(tConf),\n onAuthError: cleanAuthInfoCallback,\n onUpdateError: cleanAuthInfoCallback,\n },\n };\n}\n\nexport async function getTestLLClient(confOverrides: Partial<PlClientConfig> = {}) {\n const { conf, auth } = await getTestClientConf();\n return await LLPlClient.build({ ...conf, ...confOverrides }, { auth });\n}\n\nexport async function getTestClient(\n alternativeRoot?: string,\n confOverrides: Partial<PlClientConfig> = {},\n) {\n const { conf, auth } = await getTestClientConf();\n if (alternativeRoot !== undefined && conf.alternativeRoot !== undefined)\n throw new Error(\"test pl address configured with alternative root\");\n return await PlClient.init({ ...conf, ...confOverrides, alternativeRoot }, auth);\n}\n\nexport type WithTempRootOptions =\n | {\n /** If true and PL_ADDRESS is http://localhost or http://127.0.0.1:<port>,\n * a TCP proxy will be started and PL client will connect through it. */\n viaTcpProxy: true;\n /** Artificial latency for proxy (ms). Default 0 */\n proxyLatencyMs?: number;\n }\n | {\n viaTcpProxy?: undefined;\n };\n\nexport async function withTempRoot<T>(body: (pl: PlClient) => Promise<T>): Promise<T | void>;\n\nexport async function withTempRoot<T>(\n body: (pl: PlClient, proxy: Awaited<ReturnType<typeof startTcpProxy>>) => Promise<T>,\n options: {\n viaTcpProxy: true;\n proxyLatencyMs?: number;\n },\n): Promise<T>;\n\nexport async function withTempRoot<T>(\n body: (pl: PlClient, proxy: any) => Promise<T>,\n options: WithTempRootOptions = {},\n): Promise<T | undefined> {\n const alternativeRoot = `test_${Date.now()}_${randomUUID()}`;\n let altRootId: OptionalResourceId = NullResourceId;\n // Proxy management\n let proxy: Awaited<ReturnType<typeof startTcpProxy>> | undefined;\n let confOverrides: Partial<PlClientConfig> = {};\n try {\n // Optionally start TCP proxy and rewrite PL_ADDRESS to point to proxy\n if (options.viaTcpProxy === true && process.env.PL_ADDRESS) {\n try {\n const url = new URL(process.env.PL_ADDRESS);\n const isHttp = url.protocol === \"http:\";\n const isLocal = url.hostname === \"127.0.0.1\" || url.hostname === \"localhost\";\n const port = parseInt(url.port);\n if (isHttp && isLocal && Number.isFinite(port)) {\n proxy = await startTcpProxy({ targetPort: port, latency: options.proxyLatencyMs ?? 0 });\n // Override client connection host:port to proxy\n confOverrides = { hostAndPort: `127.0.0.1:${proxy.port}` } as Partial<PlClientConfig>;\n } else {\n console.warn(\n \"*** skipping proxy-based test, PL_ADDRESS is not localhost\",\n process.env.PL_ADDRESS,\n );\n return;\n }\n } catch {\n // ignore proxy setup errors; tests will run against original address\n }\n }\n\n const client = await getTestClient(alternativeRoot, confOverrides);\n altRootId = client.clientRoot;\n try {\n const value = await body(client, proxy);\n const rawClient = await getTestClient();\n try {\n await rawClient.deleteAlternativeRoot(alternativeRoot);\n } catch (cleanupErr: any) {\n // Cleanup may fail if test intentionally deleted resources\n console.warn(`Failed to clean up alternative root ${alternativeRoot}:`, cleanupErr.message);\n } finally {\n // Close the cleanup client to avoid dangling gRPC channels that can cause\n // segfaults during process exit\n await rawClient.close();\n }\n return value;\n } finally {\n // Close the test client to avoid dangling gRPC channels\n await client.close();\n }\n } catch (err: any) {\n console.log(`ALTERNATIVE ROOT: ${alternativeRoot} (${resourceIdToString(altRootId)})`);\n throw err;\n // throw new Error('withTempRoot error: ' + err.message, { cause: err });\n } finally {\n // Stop proxy if started\n if (proxy) {\n try {\n await proxy.disconnectAll();\n } catch {\n /* ignore */\n }\n try {\n await new Promise<void>((resolve) => proxy!.server.close(() => resolve()));\n } catch {\n /* ignore */\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAM,cAAc;AAGpB,IAAI;AAEJ,SAAS,0BAA0B;AACjC,KAAI,qBAAqB,OAAW,oBAAmBA,UAAK,QAAQ,kBAAkB;AACtF,QAAO;;AAGT,SAAgB,gBAA4B;CAC1C,IAAI,OAA4B,EAAE;AAClC,KAAIC,QAAG,WAAW,YAAY,CAC5B,QAAO,KAAK,MAAMA,QAAG,aAAa,aAAa,EAAE,UAAU,SAAS,CAAC,CAAC;AAExE,KAAI,QAAQ,IAAI,eAAe,OAAW,MAAK,UAAU,QAAQ,IAAI;AAErE,KAAI,QAAQ,IAAI,iBAAiB,OAAW,MAAK,YAAY,QAAQ,IAAI;AAEzE,KAAI,QAAQ,IAAI,qBAAqB,OAAW,MAAK,gBAAgB,QAAQ,IAAI;AAEjF,KAAI,QAAQ,IAAI,kBAAkB,OAAW,MAAK,aAAa,QAAQ,IAAI;AAE3E,KAAI,KAAK,YAAY,OACnB,OAAM,IAAI,MACR,2CAA2C,YAAY,uCACxD;AAEH,QAAO;;;AAIT,MAAa,uBAAuB;;AAGpC,SAAgB,sBAAsB,SAAiC;CACrE,MAAM,SAASC,iCAAkB,QAAQ;AACzC,QAAO,wBAAwB;AAC/B,QAAO;;AAUT,SAAS,qBAAqB,OAA+D;AAC3F,SAAQ,oBAAoB;EAC1B,MAAM,MAAM,yBAAyB;EACrC,MAAM,SAAS,yBAAyB,gCAAe;AACvD,UAAG,cACD,QACA,OAAO,KACL,KAAK,UAAU;GACb,MAAM;GACN;GACA,YAAYC,kCAAqB,iBAAiB,OAAU,GAAG;GAChE,CAAc,CAChB,EACD,OACD;AACD,U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;AAEzB,UAAO;YACC;AAER,SAAM,OAAO,OAAO;;UAEf,KAAU;AACjB,UAAQ,IAAI,qBAAqB,gBAAgB,IAAIC,iCAAmB,UAAU,CAAC,GAAG;AACtF,QAAM;WAEE;AAER,MAAI,OAAO;AACT,OAAI;AACF,UAAM,MAAM,eAAe;WACrB;AAGR,OAAI;AACF,UAAM,IAAI,SAAe,YAAY,MAAO,OAAO,YAAY,SAAS,CAAC,CAAC;WACpE"}
@@ -1,38 +1,42 @@
1
- import { LLPlClient } from "../core/ll_client";
2
- import type { AuthOps, PlClientConfig } from "../core/config";
3
- import { PlClient } from "../core/client";
4
- import type { TestTcpProxy } from "./tcp-proxy";
5
- import { startTcpProxy } from "./tcp-proxy";
6
- export { TestTcpProxy };
7
- export interface TestConfig {
8
- address: string;
9
- test_proxy?: string;
10
- test_user?: string;
11
- test_password?: string;
1
+ import { AuthOps, PlClientConfig } from "../core/config.js";
2
+ import { LLPlClient } from "../core/ll_client.js";
3
+ import { PlClient } from "../core/client.js";
4
+ import { TestTcpProxy, startTcpProxy } from "./tcp-proxy.js";
5
+
6
+ //#region src/test/test_config.d.ts
7
+ declare namespace test_config_d_exports {
8
+ export { TEST_REQUEST_TIMEOUT, TestConfig, TestTcpProxy, WithTempRootOptions, getTestClient, getTestClientConf, getTestConfig, getTestLLClient, plAddressToTestConfig, withTempRoot };
12
9
  }
13
- export declare function getTestConfig(): TestConfig;
10
+ interface TestConfig {
11
+ address: string;
12
+ test_proxy?: string;
13
+ test_user?: string;
14
+ test_password?: string;
15
+ }
16
+ declare function getTestConfig(): TestConfig;
14
17
  /** Default request timeout for tests (ms) */
15
- export declare const TEST_REQUEST_TIMEOUT = 500;
18
+ declare const TEST_REQUEST_TIMEOUT = 500;
16
19
  /** Returns PlClientConfig with reduced timeout for tests */
17
- export declare function plAddressToTestConfig(address: string): PlClientConfig;
18
- export declare function getTestClientConf(): Promise<{
19
- conf: PlClientConfig;
20
- auth: AuthOps;
20
+ declare function plAddressToTestConfig(address: string): PlClientConfig;
21
+ declare function getTestClientConf(): Promise<{
22
+ conf: PlClientConfig;
23
+ auth: AuthOps;
21
24
  }>;
22
- export declare function getTestLLClient(confOverrides?: Partial<PlClientConfig>): Promise<LLPlClient>;
23
- export declare function getTestClient(alternativeRoot?: string, confOverrides?: Partial<PlClientConfig>): Promise<PlClient>;
24
- export type WithTempRootOptions = {
25
- /** If true and PL_ADDRESS is http://localhost or http://127.0.0.1:<port>,
26
- * a TCP proxy will be started and PL client will connect through it. */
27
- viaTcpProxy: true;
28
- /** Artificial latency for proxy (ms). Default 0 */
29
- proxyLatencyMs?: number;
25
+ declare function getTestLLClient(confOverrides?: Partial<PlClientConfig>): Promise<LLPlClient>;
26
+ declare function getTestClient(alternativeRoot?: string, confOverrides?: Partial<PlClientConfig>): Promise<PlClient>;
27
+ type WithTempRootOptions = {
28
+ /** If true and PL_ADDRESS is http://localhost or http://127.0.0.1:<port>,
29
+ * a TCP proxy will be started and PL client will connect through it. */
30
+ viaTcpProxy: true; /** Artificial latency for proxy (ms). Default 0 */
31
+ proxyLatencyMs?: number;
30
32
  } | {
31
- viaTcpProxy?: undefined;
33
+ viaTcpProxy?: undefined;
32
34
  };
33
- export declare function withTempRoot<T>(body: (pl: PlClient) => Promise<T>): Promise<T | void>;
34
- export declare function withTempRoot<T>(body: (pl: PlClient, proxy: Awaited<ReturnType<typeof startTcpProxy>>) => Promise<T>, options: {
35
- viaTcpProxy: true;
36
- proxyLatencyMs?: number;
35
+ declare function withTempRoot<T>(body: (pl: PlClient) => Promise<T>): Promise<T | void>;
36
+ declare function withTempRoot<T>(body: (pl: PlClient, proxy: Awaited<ReturnType<typeof startTcpProxy>>) => Promise<T>, options: {
37
+ viaTcpProxy: true;
38
+ proxyLatencyMs?: number;
37
39
  }): Promise<T>;
40
+ //#endregion
41
+ export { test_config_d_exports };
38
42
  //# sourceMappingURL=test_config.d.ts.map