@milaboratories/pl-client 2.18.5 → 3.1.0

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 (213) hide show
  1. package/dist/_virtual/_rolldown/runtime.cjs +12 -22
  2. package/dist/_virtual/_rolldown/runtime.js +6 -11
  3. package/dist/core/PromiseTracker.cjs +2 -3
  4. package/dist/core/PromiseTracker.cjs.map +1 -1
  5. package/dist/core/PromiseTracker.d.ts.map +1 -0
  6. package/dist/core/PromiseTracker.js +1 -2
  7. package/dist/core/PromiseTracker.js.map +1 -1
  8. package/dist/core/StatefulPromise.cjs +1 -2
  9. package/dist/core/StatefulPromise.cjs.map +1 -1
  10. package/dist/core/StatefulPromise.js +1 -1
  11. package/dist/core/StatefulPromise.js.map +1 -1
  12. package/dist/core/abstract_stream.d.ts.map +1 -0
  13. package/dist/core/advisory_locks.cjs +1 -2
  14. package/dist/core/advisory_locks.cjs.map +1 -1
  15. package/dist/core/advisory_locks.js +1 -1
  16. package/dist/core/advisory_locks.js.map +1 -1
  17. package/dist/core/auth.cjs +2 -3
  18. package/dist/core/auth.cjs.map +1 -1
  19. package/dist/core/auth.d.ts.map +1 -0
  20. package/dist/core/auth.js +1 -2
  21. package/dist/core/auth.js.map +1 -1
  22. package/dist/core/cache.d.ts.map +1 -0
  23. package/dist/core/client.cjs +63 -36
  24. package/dist/core/client.cjs.map +1 -1
  25. package/dist/core/client.d.ts +3 -1
  26. package/dist/core/client.d.ts.map +1 -0
  27. package/dist/core/client.js +54 -27
  28. package/dist/core/client.js.map +1 -1
  29. package/dist/core/config.cjs +16 -17
  30. package/dist/core/config.cjs.map +1 -1
  31. package/dist/core/config.d.ts.map +1 -0
  32. package/dist/core/config.js +16 -16
  33. package/dist/core/config.js.map +1 -1
  34. package/dist/core/default_client.cjs +6 -7
  35. package/dist/core/default_client.cjs.map +1 -1
  36. package/dist/core/default_client.d.ts.map +1 -0
  37. package/dist/core/default_client.js +1 -2
  38. package/dist/core/default_client.js.map +1 -1
  39. package/dist/core/driver.cjs +1 -2
  40. package/dist/core/driver.cjs.map +1 -1
  41. package/dist/core/driver.d.ts.map +1 -0
  42. package/dist/core/driver.js +1 -1
  43. package/dist/core/error_resource.cjs +1 -2
  44. package/dist/core/error_resource.cjs.map +1 -1
  45. package/dist/core/error_resource.js +1 -1
  46. package/dist/core/errors.cjs +11 -4
  47. package/dist/core/errors.cjs.map +1 -1
  48. package/dist/core/errors.d.ts +2 -1
  49. package/dist/core/errors.d.ts.map +1 -0
  50. package/dist/core/errors.js +9 -3
  51. package/dist/core/errors.js.map +1 -1
  52. package/dist/core/final.cjs +3 -4
  53. package/dist/core/final.cjs.map +1 -1
  54. package/dist/core/final.d.ts.map +1 -0
  55. package/dist/core/final.js +1 -2
  56. package/dist/core/final.js.map +1 -1
  57. package/dist/core/ll_client.cjs +35 -18
  58. package/dist/core/ll_client.cjs.map +1 -1
  59. package/dist/core/ll_client.d.ts +6 -1
  60. package/dist/core/ll_client.d.ts.map +1 -0
  61. package/dist/core/ll_client.js +25 -8
  62. package/dist/core/ll_client.js.map +1 -1
  63. package/dist/core/ll_transaction.cjs +4 -5
  64. package/dist/core/ll_transaction.cjs.map +1 -1
  65. package/dist/core/ll_transaction.d.ts.map +1 -0
  66. package/dist/core/ll_transaction.js +1 -2
  67. package/dist/core/ll_transaction.js.map +1 -1
  68. package/dist/core/stat.cjs +1 -2
  69. package/dist/core/stat.cjs.map +1 -1
  70. package/dist/core/stat.d.ts.map +1 -0
  71. package/dist/core/stat.js +1 -1
  72. package/dist/core/transaction.cjs +32 -21
  73. package/dist/core/transaction.cjs.map +1 -1
  74. package/dist/core/transaction.d.ts.map +1 -0
  75. package/dist/core/transaction.js +23 -12
  76. package/dist/core/transaction.js.map +1 -1
  77. package/dist/core/type_conversion.cjs +8 -9
  78. package/dist/core/type_conversion.cjs.map +1 -1
  79. package/dist/core/type_conversion.js +4 -5
  80. package/dist/core/type_conversion.js.map +1 -1
  81. package/dist/core/types.cjs +3 -4
  82. package/dist/core/types.cjs.map +1 -1
  83. package/dist/core/types.d.ts.map +1 -0
  84. package/dist/core/types.js +2 -3
  85. package/dist/core/types.js.map +1 -1
  86. package/dist/core/unauth_client.cjs +4 -5
  87. package/dist/core/unauth_client.cjs.map +1 -1
  88. package/dist/core/unauth_client.d.ts.map +1 -0
  89. package/dist/core/unauth_client.js +1 -2
  90. package/dist/core/unauth_client.js.map +1 -1
  91. package/dist/core/websocket_stream.cjs +4 -5
  92. package/dist/core/websocket_stream.cjs.map +1 -1
  93. package/dist/core/websocket_stream.js +1 -2
  94. package/dist/core/websocket_stream.js.map +1 -1
  95. package/dist/core/wire.d.ts.map +1 -0
  96. package/dist/helpers/pl.cjs +12 -14
  97. package/dist/helpers/pl.cjs.map +1 -1
  98. package/dist/helpers/pl.d.ts.map +1 -0
  99. package/dist/helpers/pl.js +5 -7
  100. package/dist/helpers/pl.js.map +1 -1
  101. package/dist/helpers/poll.cjs +3 -4
  102. package/dist/helpers/poll.cjs.map +1 -1
  103. package/dist/helpers/poll.d.ts.map +1 -0
  104. package/dist/helpers/poll.js +1 -2
  105. package/dist/helpers/poll.js.map +1 -1
  106. package/dist/helpers/retry_strategy.cjs +1 -2
  107. package/dist/helpers/retry_strategy.cjs.map +1 -1
  108. package/dist/helpers/retry_strategy.js +1 -1
  109. package/dist/helpers/retry_strategy.js.map +1 -1
  110. package/dist/helpers/tx_helpers.cjs +3 -4
  111. package/dist/helpers/tx_helpers.cjs.map +1 -1
  112. package/dist/helpers/tx_helpers.d.ts.map +1 -0
  113. package/dist/helpers/tx_helpers.js +1 -2
  114. package/dist/helpers/tx_helpers.js.map +1 -1
  115. package/dist/index.cjs +34 -34
  116. package/dist/index.d.ts +2 -2
  117. package/dist/index.js +2 -3
  118. package/dist/proto-grpc/github.com/googleapis/googleapis/google/rpc/status.cjs +3 -4
  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.map +1 -0
  121. package/dist/proto-grpc/github.com/googleapis/googleapis/google/rpc/status.js +1 -2
  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 +2039 -644
  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 +62 -13
  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 +78 -8
  128. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.d.ts.map +1 -0
  129. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.js +60 -11
  130. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.js.map +1 -1
  131. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.d.ts +658 -51
  132. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.d.ts.map +1 -0
  133. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.js +2033 -639
  134. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.js.map +1 -1
  135. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.cjs +251 -22
  136. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.cjs.map +1 -1
  137. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.d.ts +104 -10
  138. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.d.ts.map +1 -0
  139. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.js +248 -19
  140. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.js.map +1 -1
  141. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.cjs +28 -15
  142. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.cjs.map +1 -1
  143. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.d.ts +4 -0
  144. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.d.ts.map +1 -0
  145. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.js +27 -14
  146. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.js.map +1 -1
  147. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/resource_types.cjs +17 -16
  148. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/resource_types.cjs.map +1 -1
  149. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/resource_types.d.ts +4 -0
  150. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/resource_types.d.ts.map +1 -0
  151. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/resource_types.js +15 -14
  152. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/resource_types.js.map +1 -1
  153. package/dist/proto-grpc/google/protobuf/any.cjs +2 -3
  154. package/dist/proto-grpc/google/protobuf/any.cjs.map +1 -1
  155. package/dist/proto-grpc/google/protobuf/any.d.ts.map +1 -0
  156. package/dist/proto-grpc/google/protobuf/any.js +1 -2
  157. package/dist/proto-grpc/google/protobuf/any.js.map +1 -1
  158. package/dist/proto-grpc/google/protobuf/duration.cjs +2 -3
  159. package/dist/proto-grpc/google/protobuf/duration.cjs.map +1 -1
  160. package/dist/proto-grpc/google/protobuf/duration.d.ts.map +1 -0
  161. package/dist/proto-grpc/google/protobuf/duration.js +1 -2
  162. package/dist/proto-grpc/google/protobuf/duration.js.map +1 -1
  163. package/dist/proto-grpc/google/protobuf/timestamp.cjs +2 -3
  164. package/dist/proto-grpc/google/protobuf/timestamp.cjs.map +1 -1
  165. package/dist/proto-grpc/google/protobuf/timestamp.d.ts.map +1 -0
  166. package/dist/proto-grpc/google/protobuf/timestamp.js +1 -2
  167. package/dist/proto-grpc/google/protobuf/timestamp.js.map +1 -1
  168. package/dist/proto-grpc/google/rpc/code.cjs +1 -2
  169. package/dist/proto-grpc/google/rpc/code.cjs.map +1 -1
  170. package/dist/proto-grpc/google/rpc/code.d.ts.map +1 -0
  171. package/dist/proto-grpc/google/rpc/code.js +1 -1
  172. package/dist/proto-grpc/google/rpc/code.js.map +1 -1
  173. package/dist/proto-rest/index.cjs +8 -9
  174. package/dist/proto-rest/index.cjs.map +1 -1
  175. package/dist/proto-rest/index.d.ts.map +1 -0
  176. package/dist/proto-rest/index.js +1 -2
  177. package/dist/proto-rest/index.js.map +1 -1
  178. package/dist/proto-rest/plapi.d.ts +281 -28
  179. package/dist/proto-rest/plapi.d.ts.map +1 -0
  180. package/dist/test/tcp-proxy.cjs +2 -3
  181. package/dist/test/tcp-proxy.cjs.map +1 -1
  182. package/dist/test/tcp-proxy.d.ts.map +1 -0
  183. package/dist/test/tcp-proxy.js +1 -2
  184. package/dist/test/tcp-proxy.js.map +1 -1
  185. package/dist/test/test_config.cjs +16 -19
  186. package/dist/test/test_config.cjs.map +1 -1
  187. package/dist/test/test_config.d.ts.map +1 -0
  188. package/dist/test/test_config.js +3 -6
  189. package/dist/test/test_config.js.map +1 -1
  190. package/dist/util/pl.cjs +1 -2
  191. package/dist/util/pl.cjs.map +1 -1
  192. package/dist/util/pl.js +1 -1
  193. package/dist/util/util.cjs +1 -2
  194. package/dist/util/util.cjs.map +1 -1
  195. package/dist/util/util.js +1 -1
  196. package/package.json +8 -8
  197. package/src/core/client.ts +80 -30
  198. package/src/core/errors.ts +11 -0
  199. package/src/core/ll_client.test.ts +8 -0
  200. package/src/core/ll_client.ts +30 -2
  201. package/src/core/ll_transaction.test.ts +12 -2
  202. package/src/core/transaction.ts +41 -10
  203. package/src/core/type_conversion.ts +1 -1
  204. package/src/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.ts +119 -15
  205. package/src/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.ts +2274 -322
  206. package/src/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.ts +276 -20
  207. package/src/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.ts +11 -0
  208. package/src/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/import.ts +2 -2
  209. package/src/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/resource_types.ts +11 -0
  210. package/src/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/ws-test.ts +3 -3
  211. package/src/proto-grpc/google/protobuf/descriptor.ts +2 -5
  212. package/src/proto-grpc/google/protobuf/struct.ts +1 -1
  213. package/src/proto-rest/plapi.ts +293 -22
@@ -7,28 +7,20 @@ var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
8
  var __exportAll = (all, no_symbols) => {
9
9
  let target = {};
10
- for (var name in all) {
11
- __defProp(target, name, {
12
- get: all[name],
13
- enumerable: true
14
- });
15
- }
16
- if (!no_symbols) {
17
- __defProp(target, Symbol.toStringTag, { value: "Module" });
18
- }
10
+ for (var name in all) __defProp(target, name, {
11
+ get: all[name],
12
+ enumerable: true
13
+ });
14
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
19
15
  return target;
20
16
  };
21
17
  var __copyProps = (to, from, except, desc) => {
22
- if (from && typeof from === "object" || typeof from === "function") {
23
- for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
24
- key = keys[i];
25
- if (!__hasOwnProp.call(to, key) && key !== except) {
26
- __defProp(to, key, {
27
- get: ((k) => from[k]).bind(null, key),
28
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
29
- });
30
- }
31
- }
18
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
19
+ key = keys[i];
20
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
21
+ get: ((k) => from[k]).bind(null, key),
22
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
23
+ });
32
24
  }
33
25
  return to;
34
26
  };
@@ -36,8 +28,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
36
28
  value: mod,
37
29
  enumerable: true
38
30
  }) : target, mod));
39
-
40
31
  //#endregion
41
-
42
32
  exports.__exportAll = __exportAll;
43
- exports.__toESM = __toESM;
33
+ exports.__toESM = __toESM;
@@ -2,17 +2,12 @@
2
2
  var __defProp = Object.defineProperty;
3
3
  var __exportAll = (all, no_symbols) => {
4
4
  let target = {};
5
- for (var name in all) {
6
- __defProp(target, name, {
7
- get: all[name],
8
- enumerable: true
9
- });
10
- }
11
- if (!no_symbols) {
12
- __defProp(target, Symbol.toStringTag, { value: "Module" });
13
- }
5
+ for (var name in all) __defProp(target, name, {
6
+ get: all[name],
7
+ enumerable: true
8
+ });
9
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
14
10
  return target;
15
11
  };
16
-
17
12
  //#endregion
18
- export { __exportAll };
13
+ export { __exportAll };
@@ -1,5 +1,4 @@
1
- const require_StatefulPromise = require('./StatefulPromise.cjs');
2
-
1
+ const require_StatefulPromise = require("./StatefulPromise.cjs");
3
2
  //#region src/core/PromiseTracker.ts
4
3
  /**
5
4
  * Tracks pending promises to ensure they are all awaited before proceeding.
@@ -31,7 +30,7 @@ var PromiseTracker = class {
31
30
  });
32
31
  }
33
32
  };
34
-
35
33
  //#endregion
36
34
  exports.PromiseTracker = PromiseTracker;
35
+
37
36
  //# sourceMappingURL=PromiseTracker.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"PromiseTracker.cjs","names":["StatefulPromise"],"sources":["../../src/core/PromiseTracker.ts"],"sourcesContent":["import { StatefulPromise } from \"./StatefulPromise\";\n\n/**\n * Tracks pending promises to ensure they are all awaited before proceeding.\n * Useful for coordinating async operations, preventing premature completion,\n * and avoiding unhandled promise rejections.\n */\nexport class PromiseTracker {\n private promises: Set<Promise<unknown>> = new Set();\n private _draining = false;\n\n get draining(): boolean {\n return this._draining;\n }\n\n get size(): number {\n return this.promises.size;\n }\n\n track<T>(promiseOrCallback: Promise<T> | (() => Promise<T>)): Promise<T> {\n const _promise =\n typeof promiseOrCallback === \"function\" ? promiseOrCallback() : promiseOrCallback;\n\n const promise = StatefulPromise.fromDeferredReject(_promise, (p) => {\n this.promises.delete(p);\n });\n this.promises.add(promise);\n return promise;\n }\n\n async awaitAll() {\n const toAwait = Array.from(this.promises);\n this._draining = true;\n return await Promise.all(toAwait).finally(() => {\n this._draining = false;\n });\n }\n}\n"],"mappings":";;;;;;;;AAOA,IAAa,iBAAb,MAA4B;CAC1B,AAAQ,2BAAkC,IAAI,KAAK;CACnD,AAAQ,YAAY;CAEpB,IAAI,WAAoB;AACtB,SAAO,KAAK;;CAGd,IAAI,OAAe;AACjB,SAAO,KAAK,SAAS;;CAGvB,MAAS,mBAAgE;EACvE,MAAM,WACJ,OAAO,sBAAsB,aAAa,mBAAmB,GAAG;EAElE,MAAM,UAAUA,wCAAgB,mBAAmB,WAAW,MAAM;AAClE,QAAK,SAAS,OAAO,EAAE;IACvB;AACF,OAAK,SAAS,IAAI,QAAQ;AAC1B,SAAO;;CAGT,MAAM,WAAW;EACf,MAAM,UAAU,MAAM,KAAK,KAAK,SAAS;AACzC,OAAK,YAAY;AACjB,SAAO,MAAM,QAAQ,IAAI,QAAQ,CAAC,cAAc;AAC9C,QAAK,YAAY;IACjB"}
1
+ {"version":3,"file":"PromiseTracker.cjs","names":["StatefulPromise"],"sources":["../../src/core/PromiseTracker.ts"],"sourcesContent":["import { StatefulPromise } from \"./StatefulPromise\";\n\n/**\n * Tracks pending promises to ensure they are all awaited before proceeding.\n * Useful for coordinating async operations, preventing premature completion,\n * and avoiding unhandled promise rejections.\n */\nexport class PromiseTracker {\n private promises: Set<Promise<unknown>> = new Set();\n private _draining = false;\n\n get draining(): boolean {\n return this._draining;\n }\n\n get size(): number {\n return this.promises.size;\n }\n\n track<T>(promiseOrCallback: Promise<T> | (() => Promise<T>)): Promise<T> {\n const _promise =\n typeof promiseOrCallback === \"function\" ? promiseOrCallback() : promiseOrCallback;\n\n const promise = StatefulPromise.fromDeferredReject(_promise, (p) => {\n this.promises.delete(p);\n });\n this.promises.add(promise);\n return promise;\n }\n\n async awaitAll() {\n const toAwait = Array.from(this.promises);\n this._draining = true;\n return await Promise.all(toAwait).finally(() => {\n this._draining = false;\n });\n }\n}\n"],"mappings":";;;;;;;AAOA,IAAa,iBAAb,MAA4B;CAC1B,2BAA0C,IAAI,KAAK;CACnD,YAAoB;CAEpB,IAAI,WAAoB;AACtB,SAAO,KAAK;;CAGd,IAAI,OAAe;AACjB,SAAO,KAAK,SAAS;;CAGvB,MAAS,mBAAgE;EACvE,MAAM,WACJ,OAAO,sBAAsB,aAAa,mBAAmB,GAAG;EAElE,MAAM,UAAUA,wBAAAA,gBAAgB,mBAAmB,WAAW,MAAM;AAClE,QAAK,SAAS,OAAO,EAAE;IACvB;AACF,OAAK,SAAS,IAAI,QAAQ;AAC1B,SAAO;;CAGT,MAAM,WAAW;EACf,MAAM,UAAU,MAAM,KAAK,KAAK,SAAS;AACzC,OAAK,YAAY;AACjB,SAAO,MAAM,QAAQ,IAAI,QAAQ,CAAC,cAAc;AAC9C,QAAK,YAAY;IACjB"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PromiseTracker.d.ts","names":[],"sources":["../../src/core/PromiseTracker.ts"],"mappings":";;AAOA;;;;cAAa,cAAA;EAAA,QACH,QAAA;EAAA,QACA,SAAA;EAAA,IAEJ,QAAA,CAAA;EAAA,IAIA,IAAA,CAAA;EAIJ,KAAA,GAAA,CAAS,iBAAA,EAAmB,OAAA,CAAQ,CAAA,WAAY,OAAA,CAAQ,CAAA,KAAM,OAAA,CAAQ,CAAA;EAWhE,QAAA,CAAA,GAAQ,OAAA;AAAA"}
@@ -1,5 +1,4 @@
1
1
  import { StatefulPromise } from "./StatefulPromise.js";
2
-
3
2
  //#region src/core/PromiseTracker.ts
4
3
  /**
5
4
  * Tracks pending promises to ensure they are all awaited before proceeding.
@@ -31,7 +30,7 @@ var PromiseTracker = class {
31
30
  });
32
31
  }
33
32
  };
34
-
35
33
  //#endregion
36
34
  export { PromiseTracker };
35
+
37
36
  //# sourceMappingURL=PromiseTracker.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PromiseTracker.js","names":[],"sources":["../../src/core/PromiseTracker.ts"],"sourcesContent":["import { StatefulPromise } from \"./StatefulPromise\";\n\n/**\n * Tracks pending promises to ensure they are all awaited before proceeding.\n * Useful for coordinating async operations, preventing premature completion,\n * and avoiding unhandled promise rejections.\n */\nexport class PromiseTracker {\n private promises: Set<Promise<unknown>> = new Set();\n private _draining = false;\n\n get draining(): boolean {\n return this._draining;\n }\n\n get size(): number {\n return this.promises.size;\n }\n\n track<T>(promiseOrCallback: Promise<T> | (() => Promise<T>)): Promise<T> {\n const _promise =\n typeof promiseOrCallback === \"function\" ? promiseOrCallback() : promiseOrCallback;\n\n const promise = StatefulPromise.fromDeferredReject(_promise, (p) => {\n this.promises.delete(p);\n });\n this.promises.add(promise);\n return promise;\n }\n\n async awaitAll() {\n const toAwait = Array.from(this.promises);\n this._draining = true;\n return await Promise.all(toAwait).finally(() => {\n this._draining = false;\n });\n }\n}\n"],"mappings":";;;;;;;;AAOA,IAAa,iBAAb,MAA4B;CAC1B,AAAQ,2BAAkC,IAAI,KAAK;CACnD,AAAQ,YAAY;CAEpB,IAAI,WAAoB;AACtB,SAAO,KAAK;;CAGd,IAAI,OAAe;AACjB,SAAO,KAAK,SAAS;;CAGvB,MAAS,mBAAgE;EACvE,MAAM,WACJ,OAAO,sBAAsB,aAAa,mBAAmB,GAAG;EAElE,MAAM,UAAU,gBAAgB,mBAAmB,WAAW,MAAM;AAClE,QAAK,SAAS,OAAO,EAAE;IACvB;AACF,OAAK,SAAS,IAAI,QAAQ;AAC1B,SAAO;;CAGT,MAAM,WAAW;EACf,MAAM,UAAU,MAAM,KAAK,KAAK,SAAS;AACzC,OAAK,YAAY;AACjB,SAAO,MAAM,QAAQ,IAAI,QAAQ,CAAC,cAAc;AAC9C,QAAK,YAAY;IACjB"}
1
+ {"version":3,"file":"PromiseTracker.js","names":[],"sources":["../../src/core/PromiseTracker.ts"],"sourcesContent":["import { StatefulPromise } from \"./StatefulPromise\";\n\n/**\n * Tracks pending promises to ensure they are all awaited before proceeding.\n * Useful for coordinating async operations, preventing premature completion,\n * and avoiding unhandled promise rejections.\n */\nexport class PromiseTracker {\n private promises: Set<Promise<unknown>> = new Set();\n private _draining = false;\n\n get draining(): boolean {\n return this._draining;\n }\n\n get size(): number {\n return this.promises.size;\n }\n\n track<T>(promiseOrCallback: Promise<T> | (() => Promise<T>)): Promise<T> {\n const _promise =\n typeof promiseOrCallback === \"function\" ? promiseOrCallback() : promiseOrCallback;\n\n const promise = StatefulPromise.fromDeferredReject(_promise, (p) => {\n this.promises.delete(p);\n });\n this.promises.add(promise);\n return promise;\n }\n\n async awaitAll() {\n const toAwait = Array.from(this.promises);\n this._draining = true;\n return await Promise.all(toAwait).finally(() => {\n this._draining = false;\n });\n }\n}\n"],"mappings":";;;;;;;AAOA,IAAa,iBAAb,MAA4B;CAC1B,2BAA0C,IAAI,KAAK;CACnD,YAAoB;CAEpB,IAAI,WAAoB;AACtB,SAAO,KAAK;;CAGd,IAAI,OAAe;AACjB,SAAO,KAAK,SAAS;;CAGvB,MAAS,mBAAgE;EACvE,MAAM,WACJ,OAAO,sBAAsB,aAAa,mBAAmB,GAAG;EAElE,MAAM,UAAU,gBAAgB,mBAAmB,WAAW,MAAM;AAClE,QAAK,SAAS,OAAO,EAAE;IACvB;AACF,OAAK,SAAS,IAAI,QAAQ;AAC1B,SAAO;;CAGT,MAAM,WAAW;EACf,MAAM,UAAU,MAAM,KAAK,KAAK,SAAS;AACzC,OAAK,YAAY;AACjB,SAAO,MAAM,QAAQ,IAAI,QAAQ,CAAC,cAAc;AAC9C,QAAK,YAAY;IACjB"}
@@ -1,4 +1,3 @@
1
-
2
1
  //#region src/core/StatefulPromise.ts
3
2
  /**
4
3
  * A Promise wrapper that tracks its state (pending/fulfilled/rejected) and provides
@@ -58,7 +57,7 @@ var StatefulPromise = class StatefulPromise {
58
57
  return this.promise;
59
58
  }
60
59
  };
61
-
62
60
  //#endregion
63
61
  exports.StatefulPromise = StatefulPromise;
62
+
64
63
  //# sourceMappingURL=StatefulPromise.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"StatefulPromise.cjs","names":[],"sources":["../../src/core/StatefulPromise.ts"],"sourcesContent":["type PromiseState = \"pending\" | \"fulfilled\" | \"rejected\";\n\ntype StatefulPromiseOptions<T> = {\n /**\n * If true, rejections that happen inside the promise are *recorded* but\n * not rethrown from the constructor chain. They will only surface when you\n * call unwrap()/then()/await.\n */\n deferReject?: true;\n /**\n * Callback invoked when the promise is accessed (via then/catch/finally/await).\n * Useful for cleanup or tracking when a promise result is consumed.\n */\n onUnwrap?: (promise: StatefulPromise<T>) => void;\n};\n\n/**\n * A Promise wrapper that tracks its state (pending/fulfilled/rejected) and provides\n * optional deferred rejection handling to prevent unhandled promise rejections.\n */\nexport class StatefulPromise<T> implements Promise<T> {\n private _state: PromiseState;\n private _id: bigint;\n\n private static idCounter = 0n;\n\n public static debug = false;\n\n static from<T>(promise: Promise<T>, options: StatefulPromiseOptions<T> = {}): StatefulPromise<T> {\n return new StatefulPromise(promise, options);\n }\n\n static fromDeferredReject<T>(\n promise: Promise<T>,\n onUnwrap?: (promise: StatefulPromise<T>) => void,\n ): StatefulPromise<T> {\n return new StatefulPromise(promise, { deferReject: true, onUnwrap });\n }\n\n static fromDeferredRejectCallback<T>(\n asyncFn: () => Promise<T>,\n onUnwrap?: (promise: StatefulPromise<T>) => void,\n ): StatefulPromise<T> {\n return new StatefulPromise(asyncFn(), { deferReject: true, onUnwrap });\n }\n\n private constructor(\n private readonly promise: Promise<T>,\n private readonly options: StatefulPromiseOptions<T> = {},\n ) {\n this._state = \"pending\";\n this._id = StatefulPromise.idCounter++;\n\n this.promise\n .then((value) => {\n this._state = \"fulfilled\";\n return value;\n })\n .catch((err) => {\n this._state = \"rejected\";\n if (!options.deferReject) {\n throw err;\n }\n });\n }\n\n readonly [Symbol.toStringTag] = \"Promise\";\n\n get id(): bigint {\n return this._id;\n }\n\n get state(): PromiseState {\n return this._state;\n }\n\n then<TResult1 = T, TResult2 = never>(\n onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null,\n onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null,\n ): Promise<TResult1 | TResult2> {\n return this.unwrap().then(onfulfilled, onrejected);\n }\n\n catch<TResult = never>(\n onrejected?: (reason: unknown) => TResult | PromiseLike<TResult>,\n ): Promise<T | TResult> {\n return this.unwrap().catch(onrejected);\n }\n\n finally(onfinally?: () => void): Promise<T> {\n return this.unwrap().finally(onfinally);\n }\n\n async unwrap(): Promise<T> {\n if (this.options.onUnwrap) {\n this.options.onUnwrap(this);\n }\n\n return this.promise;\n }\n}\n"],"mappings":";;;;;;AAoBA,IAAa,kBAAb,MAAa,gBAAyC;CACpD,AAAQ;CACR,AAAQ;CAER,OAAe,YAAY;CAE3B,OAAc,QAAQ;CAEtB,OAAO,KAAQ,SAAqB,UAAqC,EAAE,EAAsB;AAC/F,SAAO,IAAI,gBAAgB,SAAS,QAAQ;;CAG9C,OAAO,mBACL,SACA,UACoB;AACpB,SAAO,IAAI,gBAAgB,SAAS;GAAE,aAAa;GAAM;GAAU,CAAC;;CAGtE,OAAO,2BACL,SACA,UACoB;AACpB,SAAO,IAAI,gBAAgB,SAAS,EAAE;GAAE,aAAa;GAAM;GAAU,CAAC;;CAGxE,AAAQ,YACN,AAAiB,SACjB,AAAiB,UAAqC,EAAE,EACxD;EAFiB;EACA;AAEjB,OAAK,SAAS;AACd,OAAK,MAAM,gBAAgB;AAE3B,OAAK,QACF,MAAM,UAAU;AACf,QAAK,SAAS;AACd,UAAO;IACP,CACD,OAAO,QAAQ;AACd,QAAK,SAAS;AACd,OAAI,CAAC,QAAQ,YACX,OAAM;IAER;;CAGN,CAAU,OAAO,eAAe;CAEhC,IAAI,KAAa;AACf,SAAO,KAAK;;CAGd,IAAI,QAAsB;AACxB,SAAO,KAAK;;CAGd,KACE,aACA,YAC8B;AAC9B,SAAO,KAAK,QAAQ,CAAC,KAAK,aAAa,WAAW;;CAGpD,MACE,YACsB;AACtB,SAAO,KAAK,QAAQ,CAAC,MAAM,WAAW;;CAGxC,QAAQ,WAAoC;AAC1C,SAAO,KAAK,QAAQ,CAAC,QAAQ,UAAU;;CAGzC,MAAM,SAAqB;AACzB,MAAI,KAAK,QAAQ,SACf,MAAK,QAAQ,SAAS,KAAK;AAG7B,SAAO,KAAK"}
1
+ {"version":3,"file":"StatefulPromise.cjs","names":[],"sources":["../../src/core/StatefulPromise.ts"],"sourcesContent":["type PromiseState = \"pending\" | \"fulfilled\" | \"rejected\";\n\ntype StatefulPromiseOptions<T> = {\n /**\n * If true, rejections that happen inside the promise are *recorded* but\n * not rethrown from the constructor chain. They will only surface when you\n * call unwrap()/then()/await.\n */\n deferReject?: true;\n /**\n * Callback invoked when the promise is accessed (via then/catch/finally/await).\n * Useful for cleanup or tracking when a promise result is consumed.\n */\n onUnwrap?: (promise: StatefulPromise<T>) => void;\n};\n\n/**\n * A Promise wrapper that tracks its state (pending/fulfilled/rejected) and provides\n * optional deferred rejection handling to prevent unhandled promise rejections.\n */\nexport class StatefulPromise<T> implements Promise<T> {\n private _state: PromiseState;\n private _id: bigint;\n\n private static idCounter = 0n;\n\n public static debug = false;\n\n static from<T>(promise: Promise<T>, options: StatefulPromiseOptions<T> = {}): StatefulPromise<T> {\n return new StatefulPromise(promise, options);\n }\n\n static fromDeferredReject<T>(\n promise: Promise<T>,\n onUnwrap?: (promise: StatefulPromise<T>) => void,\n ): StatefulPromise<T> {\n return new StatefulPromise(promise, { deferReject: true, onUnwrap });\n }\n\n static fromDeferredRejectCallback<T>(\n asyncFn: () => Promise<T>,\n onUnwrap?: (promise: StatefulPromise<T>) => void,\n ): StatefulPromise<T> {\n return new StatefulPromise(asyncFn(), { deferReject: true, onUnwrap });\n }\n\n private constructor(\n private readonly promise: Promise<T>,\n private readonly options: StatefulPromiseOptions<T> = {},\n ) {\n this._state = \"pending\";\n this._id = StatefulPromise.idCounter++;\n\n this.promise\n .then((value) => {\n this._state = \"fulfilled\";\n return value;\n })\n .catch((err) => {\n this._state = \"rejected\";\n if (!options.deferReject) {\n throw err;\n }\n });\n }\n\n readonly [Symbol.toStringTag] = \"Promise\";\n\n get id(): bigint {\n return this._id;\n }\n\n get state(): PromiseState {\n return this._state;\n }\n\n then<TResult1 = T, TResult2 = never>(\n onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null,\n onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null,\n ): Promise<TResult1 | TResult2> {\n return this.unwrap().then(onfulfilled, onrejected);\n }\n\n catch<TResult = never>(\n onrejected?: (reason: unknown) => TResult | PromiseLike<TResult>,\n ): Promise<T | TResult> {\n return this.unwrap().catch(onrejected);\n }\n\n finally(onfinally?: () => void): Promise<T> {\n return this.unwrap().finally(onfinally);\n }\n\n async unwrap(): Promise<T> {\n if (this.options.onUnwrap) {\n this.options.onUnwrap(this);\n }\n\n return this.promise;\n }\n}\n"],"mappings":";;;;;AAoBA,IAAa,kBAAb,MAAa,gBAAyC;CACpD;CACA;CAEA,OAAe,YAAY;CAE3B,OAAc,QAAQ;CAEtB,OAAO,KAAQ,SAAqB,UAAqC,EAAE,EAAsB;AAC/F,SAAO,IAAI,gBAAgB,SAAS,QAAQ;;CAG9C,OAAO,mBACL,SACA,UACoB;AACpB,SAAO,IAAI,gBAAgB,SAAS;GAAE,aAAa;GAAM;GAAU,CAAC;;CAGtE,OAAO,2BACL,SACA,UACoB;AACpB,SAAO,IAAI,gBAAgB,SAAS,EAAE;GAAE,aAAa;GAAM;GAAU,CAAC;;CAGxE,YACE,SACA,UAAsD,EAAE,EACxD;AAFiB,OAAA,UAAA;AACA,OAAA,UAAA;AAEjB,OAAK,SAAS;AACd,OAAK,MAAM,gBAAgB;AAE3B,OAAK,QACF,MAAM,UAAU;AACf,QAAK,SAAS;AACd,UAAO;IACP,CACD,OAAO,QAAQ;AACd,QAAK,SAAS;AACd,OAAI,CAAC,QAAQ,YACX,OAAM;IAER;;CAGN,CAAU,OAAO,eAAe;CAEhC,IAAI,KAAa;AACf,SAAO,KAAK;;CAGd,IAAI,QAAsB;AACxB,SAAO,KAAK;;CAGd,KACE,aACA,YAC8B;AAC9B,SAAO,KAAK,QAAQ,CAAC,KAAK,aAAa,WAAW;;CAGpD,MACE,YACsB;AACtB,SAAO,KAAK,QAAQ,CAAC,MAAM,WAAW;;CAGxC,QAAQ,WAAoC;AAC1C,SAAO,KAAK,QAAQ,CAAC,QAAQ,UAAU;;CAGzC,MAAM,SAAqB;AACzB,MAAI,KAAK,QAAQ,SACf,MAAK,QAAQ,SAAS,KAAK;AAG7B,SAAO,KAAK"}
@@ -57,7 +57,7 @@ var StatefulPromise = class StatefulPromise {
57
57
  return this.promise;
58
58
  }
59
59
  };
60
-
61
60
  //#endregion
62
61
  export { StatefulPromise };
62
+
63
63
  //# sourceMappingURL=StatefulPromise.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"StatefulPromise.js","names":[],"sources":["../../src/core/StatefulPromise.ts"],"sourcesContent":["type PromiseState = \"pending\" | \"fulfilled\" | \"rejected\";\n\ntype StatefulPromiseOptions<T> = {\n /**\n * If true, rejections that happen inside the promise are *recorded* but\n * not rethrown from the constructor chain. They will only surface when you\n * call unwrap()/then()/await.\n */\n deferReject?: true;\n /**\n * Callback invoked when the promise is accessed (via then/catch/finally/await).\n * Useful for cleanup or tracking when a promise result is consumed.\n */\n onUnwrap?: (promise: StatefulPromise<T>) => void;\n};\n\n/**\n * A Promise wrapper that tracks its state (pending/fulfilled/rejected) and provides\n * optional deferred rejection handling to prevent unhandled promise rejections.\n */\nexport class StatefulPromise<T> implements Promise<T> {\n private _state: PromiseState;\n private _id: bigint;\n\n private static idCounter = 0n;\n\n public static debug = false;\n\n static from<T>(promise: Promise<T>, options: StatefulPromiseOptions<T> = {}): StatefulPromise<T> {\n return new StatefulPromise(promise, options);\n }\n\n static fromDeferredReject<T>(\n promise: Promise<T>,\n onUnwrap?: (promise: StatefulPromise<T>) => void,\n ): StatefulPromise<T> {\n return new StatefulPromise(promise, { deferReject: true, onUnwrap });\n }\n\n static fromDeferredRejectCallback<T>(\n asyncFn: () => Promise<T>,\n onUnwrap?: (promise: StatefulPromise<T>) => void,\n ): StatefulPromise<T> {\n return new StatefulPromise(asyncFn(), { deferReject: true, onUnwrap });\n }\n\n private constructor(\n private readonly promise: Promise<T>,\n private readonly options: StatefulPromiseOptions<T> = {},\n ) {\n this._state = \"pending\";\n this._id = StatefulPromise.idCounter++;\n\n this.promise\n .then((value) => {\n this._state = \"fulfilled\";\n return value;\n })\n .catch((err) => {\n this._state = \"rejected\";\n if (!options.deferReject) {\n throw err;\n }\n });\n }\n\n readonly [Symbol.toStringTag] = \"Promise\";\n\n get id(): bigint {\n return this._id;\n }\n\n get state(): PromiseState {\n return this._state;\n }\n\n then<TResult1 = T, TResult2 = never>(\n onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null,\n onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null,\n ): Promise<TResult1 | TResult2> {\n return this.unwrap().then(onfulfilled, onrejected);\n }\n\n catch<TResult = never>(\n onrejected?: (reason: unknown) => TResult | PromiseLike<TResult>,\n ): Promise<T | TResult> {\n return this.unwrap().catch(onrejected);\n }\n\n finally(onfinally?: () => void): Promise<T> {\n return this.unwrap().finally(onfinally);\n }\n\n async unwrap(): Promise<T> {\n if (this.options.onUnwrap) {\n this.options.onUnwrap(this);\n }\n\n return this.promise;\n }\n}\n"],"mappings":";;;;;AAoBA,IAAa,kBAAb,MAAa,gBAAyC;CACpD,AAAQ;CACR,AAAQ;CAER,OAAe,YAAY;CAE3B,OAAc,QAAQ;CAEtB,OAAO,KAAQ,SAAqB,UAAqC,EAAE,EAAsB;AAC/F,SAAO,IAAI,gBAAgB,SAAS,QAAQ;;CAG9C,OAAO,mBACL,SACA,UACoB;AACpB,SAAO,IAAI,gBAAgB,SAAS;GAAE,aAAa;GAAM;GAAU,CAAC;;CAGtE,OAAO,2BACL,SACA,UACoB;AACpB,SAAO,IAAI,gBAAgB,SAAS,EAAE;GAAE,aAAa;GAAM;GAAU,CAAC;;CAGxE,AAAQ,YACN,AAAiB,SACjB,AAAiB,UAAqC,EAAE,EACxD;EAFiB;EACA;AAEjB,OAAK,SAAS;AACd,OAAK,MAAM,gBAAgB;AAE3B,OAAK,QACF,MAAM,UAAU;AACf,QAAK,SAAS;AACd,UAAO;IACP,CACD,OAAO,QAAQ;AACd,QAAK,SAAS;AACd,OAAI,CAAC,QAAQ,YACX,OAAM;IAER;;CAGN,CAAU,OAAO,eAAe;CAEhC,IAAI,KAAa;AACf,SAAO,KAAK;;CAGd,IAAI,QAAsB;AACxB,SAAO,KAAK;;CAGd,KACE,aACA,YAC8B;AAC9B,SAAO,KAAK,QAAQ,CAAC,KAAK,aAAa,WAAW;;CAGpD,MACE,YACsB;AACtB,SAAO,KAAK,QAAQ,CAAC,MAAM,WAAW;;CAGxC,QAAQ,WAAoC;AAC1C,SAAO,KAAK,QAAQ,CAAC,QAAQ,UAAU;;CAGzC,MAAM,SAAqB;AACzB,MAAI,KAAK,QAAQ,SACf,MAAK,QAAQ,SAAS,KAAK;AAG7B,SAAO,KAAK"}
1
+ {"version":3,"file":"StatefulPromise.js","names":[],"sources":["../../src/core/StatefulPromise.ts"],"sourcesContent":["type PromiseState = \"pending\" | \"fulfilled\" | \"rejected\";\n\ntype StatefulPromiseOptions<T> = {\n /**\n * If true, rejections that happen inside the promise are *recorded* but\n * not rethrown from the constructor chain. They will only surface when you\n * call unwrap()/then()/await.\n */\n deferReject?: true;\n /**\n * Callback invoked when the promise is accessed (via then/catch/finally/await).\n * Useful for cleanup or tracking when a promise result is consumed.\n */\n onUnwrap?: (promise: StatefulPromise<T>) => void;\n};\n\n/**\n * A Promise wrapper that tracks its state (pending/fulfilled/rejected) and provides\n * optional deferred rejection handling to prevent unhandled promise rejections.\n */\nexport class StatefulPromise<T> implements Promise<T> {\n private _state: PromiseState;\n private _id: bigint;\n\n private static idCounter = 0n;\n\n public static debug = false;\n\n static from<T>(promise: Promise<T>, options: StatefulPromiseOptions<T> = {}): StatefulPromise<T> {\n return new StatefulPromise(promise, options);\n }\n\n static fromDeferredReject<T>(\n promise: Promise<T>,\n onUnwrap?: (promise: StatefulPromise<T>) => void,\n ): StatefulPromise<T> {\n return new StatefulPromise(promise, { deferReject: true, onUnwrap });\n }\n\n static fromDeferredRejectCallback<T>(\n asyncFn: () => Promise<T>,\n onUnwrap?: (promise: StatefulPromise<T>) => void,\n ): StatefulPromise<T> {\n return new StatefulPromise(asyncFn(), { deferReject: true, onUnwrap });\n }\n\n private constructor(\n private readonly promise: Promise<T>,\n private readonly options: StatefulPromiseOptions<T> = {},\n ) {\n this._state = \"pending\";\n this._id = StatefulPromise.idCounter++;\n\n this.promise\n .then((value) => {\n this._state = \"fulfilled\";\n return value;\n })\n .catch((err) => {\n this._state = \"rejected\";\n if (!options.deferReject) {\n throw err;\n }\n });\n }\n\n readonly [Symbol.toStringTag] = \"Promise\";\n\n get id(): bigint {\n return this._id;\n }\n\n get state(): PromiseState {\n return this._state;\n }\n\n then<TResult1 = T, TResult2 = never>(\n onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null,\n onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null,\n ): Promise<TResult1 | TResult2> {\n return this.unwrap().then(onfulfilled, onrejected);\n }\n\n catch<TResult = never>(\n onrejected?: (reason: unknown) => TResult | PromiseLike<TResult>,\n ): Promise<T | TResult> {\n return this.unwrap().catch(onrejected);\n }\n\n finally(onfinally?: () => void): Promise<T> {\n return this.unwrap().finally(onfinally);\n }\n\n async unwrap(): Promise<T> {\n if (this.options.onUnwrap) {\n this.options.onUnwrap(this);\n }\n\n return this.promise;\n }\n}\n"],"mappings":";;;;;AAoBA,IAAa,kBAAb,MAAa,gBAAyC;CACpD;CACA;CAEA,OAAe,YAAY;CAE3B,OAAc,QAAQ;CAEtB,OAAO,KAAQ,SAAqB,UAAqC,EAAE,EAAsB;AAC/F,SAAO,IAAI,gBAAgB,SAAS,QAAQ;;CAG9C,OAAO,mBACL,SACA,UACoB;AACpB,SAAO,IAAI,gBAAgB,SAAS;GAAE,aAAa;GAAM;GAAU,CAAC;;CAGtE,OAAO,2BACL,SACA,UACoB;AACpB,SAAO,IAAI,gBAAgB,SAAS,EAAE;GAAE,aAAa;GAAM;GAAU,CAAC;;CAGxE,YACE,SACA,UAAsD,EAAE,EACxD;AAFiB,OAAA,UAAA;AACA,OAAA,UAAA;AAEjB,OAAK,SAAS;AACd,OAAK,MAAM,gBAAgB;AAE3B,OAAK,QACF,MAAM,UAAU;AACf,QAAK,SAAS;AACd,UAAO;IACP,CACD,OAAO,QAAQ;AACd,QAAK,SAAS;AACd,OAAI,CAAC,QAAQ,YACX,OAAM;IAER;;CAGN,CAAU,OAAO,eAAe;CAEhC,IAAI,KAAa;AACf,SAAO,KAAK;;CAGd,IAAI,QAAsB;AACxB,SAAO,KAAK;;CAGd,KACE,aACA,YAC8B;AAC9B,SAAO,KAAK,QAAQ,CAAC,KAAK,aAAa,WAAW;;CAGpD,MACE,YACsB;AACtB,SAAO,KAAK,QAAQ,CAAC,MAAM,WAAW;;CAGxC,QAAQ,WAAoC;AAC1C,SAAO,KAAK,QAAQ,CAAC,QAAQ,UAAU;;CAGzC,MAAM,SAAqB;AACzB,MAAI,KAAK,QAAQ,SACf,MAAK,QAAQ,SAAS,KAAK;AAG7B,SAAO,KAAK"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abstract_stream.d.ts","names":[],"sources":["../../src/core/abstract_stream.ts"],"mappings":";UAEiB,cAAA;EAAA;;;;EAKf,IAAA,CAAK,OAAA,EAAS,CAAA,GAAI,OAAA;EAMN;;;;;EAAZ,QAAA,IAAY,OAAA;AAAA;AAAA,UAGG,UAAA;EACf,QAAA,EAAU,cAAA,CAAe,CAAA;EACzB,SAAA,EAAW,aAAA,CAAc,CAAA;AAAA"}
@@ -1,4 +1,3 @@
1
-
2
1
  //#region src/core/advisory_locks.ts
3
2
  var AwaitLock = class {
4
3
  acquired = false;
@@ -42,7 +41,7 @@ async function advisoryLock(id) {
42
41
  if (lock.release()) m.delete(id);
43
42
  };
44
43
  }
45
-
46
44
  //#endregion
47
45
  exports.advisoryLock = advisoryLock;
46
+
48
47
  //# sourceMappingURL=advisory_locks.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"advisory_locks.cjs","names":[],"sources":["../../src/core/advisory_locks.ts"],"sourcesContent":["class AwaitLock {\n private acquired = false;\n private resolvers: (() => void)[] = [];\n\n acquireAsync(): Promise<void> {\n if (!this.acquired) {\n this.acquired = true;\n return Promise.resolve();\n }\n\n return new Promise((resolve) => {\n this.resolvers.push(resolve);\n });\n }\n\n /**\n * Releases the lock. Returns true if the lock becomes fully idle (no waiters, not acquired).\n */\n release(): boolean {\n if (!this.acquired) {\n throw new Error(\"Cannot release an unacquired lock\");\n }\n\n if (this.resolvers.length) {\n this.resolvers.shift()?.();\n return false;\n } else {\n this.acquired = false;\n return true;\n }\n }\n}\n\nconst m = new Map<string, AwaitLock>();\n\n/**\n * Acquire a process-local async lock for the given id and return a release function.\n * Ensures only one concurrent operation per id within this process.\n */\nexport async function advisoryLock(id: string) {\n if (!m.has(id)) {\n m.set(id, new AwaitLock());\n }\n\n const lock = m.get(id)!;\n await lock.acquireAsync();\n\n let released = false;\n return () => {\n if (released) return;\n released = true;\n const nowIdle = lock.release();\n if (nowIdle) m.delete(id);\n };\n}\n\n/**\n * Run the callback under the lock for the given id; releases automatically.\n */\nexport async function advisoryLockCallback<T>(id: string, cb: () => Promise<T>): Promise<T> {\n const release = await advisoryLock(id);\n try {\n return await cb();\n } finally {\n release();\n }\n}\n"],"mappings":";;AAAA,IAAM,YAAN,MAAgB;CACd,AAAQ,WAAW;CACnB,AAAQ,YAA4B,EAAE;CAEtC,eAA8B;AAC5B,MAAI,CAAC,KAAK,UAAU;AAClB,QAAK,WAAW;AAChB,UAAO,QAAQ,SAAS;;AAG1B,SAAO,IAAI,SAAS,YAAY;AAC9B,QAAK,UAAU,KAAK,QAAQ;IAC5B;;;;;CAMJ,UAAmB;AACjB,MAAI,CAAC,KAAK,SACR,OAAM,IAAI,MAAM,oCAAoC;AAGtD,MAAI,KAAK,UAAU,QAAQ;AACzB,QAAK,UAAU,OAAO,IAAI;AAC1B,UAAO;SACF;AACL,QAAK,WAAW;AAChB,UAAO;;;;AAKb,MAAM,oBAAI,IAAI,KAAwB;;;;;AAMtC,eAAsB,aAAa,IAAY;AAC7C,KAAI,CAAC,EAAE,IAAI,GAAG,CACZ,GAAE,IAAI,IAAI,IAAI,WAAW,CAAC;CAG5B,MAAM,OAAO,EAAE,IAAI,GAAG;AACtB,OAAM,KAAK,cAAc;CAEzB,IAAI,WAAW;AACf,cAAa;AACX,MAAI,SAAU;AACd,aAAW;AAEX,MADgB,KAAK,SAAS,CACjB,GAAE,OAAO,GAAG"}
1
+ {"version":3,"file":"advisory_locks.cjs","names":[],"sources":["../../src/core/advisory_locks.ts"],"sourcesContent":["class AwaitLock {\n private acquired = false;\n private resolvers: (() => void)[] = [];\n\n acquireAsync(): Promise<void> {\n if (!this.acquired) {\n this.acquired = true;\n return Promise.resolve();\n }\n\n return new Promise((resolve) => {\n this.resolvers.push(resolve);\n });\n }\n\n /**\n * Releases the lock. Returns true if the lock becomes fully idle (no waiters, not acquired).\n */\n release(): boolean {\n if (!this.acquired) {\n throw new Error(\"Cannot release an unacquired lock\");\n }\n\n if (this.resolvers.length) {\n this.resolvers.shift()?.();\n return false;\n } else {\n this.acquired = false;\n return true;\n }\n }\n}\n\nconst m = new Map<string, AwaitLock>();\n\n/**\n * Acquire a process-local async lock for the given id and return a release function.\n * Ensures only one concurrent operation per id within this process.\n */\nexport async function advisoryLock(id: string) {\n if (!m.has(id)) {\n m.set(id, new AwaitLock());\n }\n\n const lock = m.get(id)!;\n await lock.acquireAsync();\n\n let released = false;\n return () => {\n if (released) return;\n released = true;\n const nowIdle = lock.release();\n if (nowIdle) m.delete(id);\n };\n}\n\n/**\n * Run the callback under the lock for the given id; releases automatically.\n */\nexport async function advisoryLockCallback<T>(id: string, cb: () => Promise<T>): Promise<T> {\n const release = await advisoryLock(id);\n try {\n return await cb();\n } finally {\n release();\n }\n}\n"],"mappings":";AAAA,IAAM,YAAN,MAAgB;CACd,WAAmB;CACnB,YAAoC,EAAE;CAEtC,eAA8B;AAC5B,MAAI,CAAC,KAAK,UAAU;AAClB,QAAK,WAAW;AAChB,UAAO,QAAQ,SAAS;;AAG1B,SAAO,IAAI,SAAS,YAAY;AAC9B,QAAK,UAAU,KAAK,QAAQ;IAC5B;;;;;CAMJ,UAAmB;AACjB,MAAI,CAAC,KAAK,SACR,OAAM,IAAI,MAAM,oCAAoC;AAGtD,MAAI,KAAK,UAAU,QAAQ;AACzB,QAAK,UAAU,OAAO,IAAI;AAC1B,UAAO;SACF;AACL,QAAK,WAAW;AAChB,UAAO;;;;AAKb,MAAM,oBAAI,IAAI,KAAwB;;;;;AAMtC,eAAsB,aAAa,IAAY;AAC7C,KAAI,CAAC,EAAE,IAAI,GAAG,CACZ,GAAE,IAAI,IAAI,IAAI,WAAW,CAAC;CAG5B,MAAM,OAAO,EAAE,IAAI,GAAG;AACtB,OAAM,KAAK,cAAc;CAEzB,IAAI,WAAW;AACf,cAAa;AACX,MAAI,SAAU;AACd,aAAW;AAEX,MADgB,KAAK,SAAS,CACjB,GAAE,OAAO,GAAG"}
@@ -41,7 +41,7 @@ async function advisoryLock(id) {
41
41
  if (lock.release()) m.delete(id);
42
42
  };
43
43
  }
44
-
45
44
  //#endregion
46
45
  export { advisoryLock };
46
+
47
47
  //# sourceMappingURL=advisory_locks.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"advisory_locks.js","names":[],"sources":["../../src/core/advisory_locks.ts"],"sourcesContent":["class AwaitLock {\n private acquired = false;\n private resolvers: (() => void)[] = [];\n\n acquireAsync(): Promise<void> {\n if (!this.acquired) {\n this.acquired = true;\n return Promise.resolve();\n }\n\n return new Promise((resolve) => {\n this.resolvers.push(resolve);\n });\n }\n\n /**\n * Releases the lock. Returns true if the lock becomes fully idle (no waiters, not acquired).\n */\n release(): boolean {\n if (!this.acquired) {\n throw new Error(\"Cannot release an unacquired lock\");\n }\n\n if (this.resolvers.length) {\n this.resolvers.shift()?.();\n return false;\n } else {\n this.acquired = false;\n return true;\n }\n }\n}\n\nconst m = new Map<string, AwaitLock>();\n\n/**\n * Acquire a process-local async lock for the given id and return a release function.\n * Ensures only one concurrent operation per id within this process.\n */\nexport async function advisoryLock(id: string) {\n if (!m.has(id)) {\n m.set(id, new AwaitLock());\n }\n\n const lock = m.get(id)!;\n await lock.acquireAsync();\n\n let released = false;\n return () => {\n if (released) return;\n released = true;\n const nowIdle = lock.release();\n if (nowIdle) m.delete(id);\n };\n}\n\n/**\n * Run the callback under the lock for the given id; releases automatically.\n */\nexport async function advisoryLockCallback<T>(id: string, cb: () => Promise<T>): Promise<T> {\n const release = await advisoryLock(id);\n try {\n return await cb();\n } finally {\n release();\n }\n}\n"],"mappings":";AAAA,IAAM,YAAN,MAAgB;CACd,AAAQ,WAAW;CACnB,AAAQ,YAA4B,EAAE;CAEtC,eAA8B;AAC5B,MAAI,CAAC,KAAK,UAAU;AAClB,QAAK,WAAW;AAChB,UAAO,QAAQ,SAAS;;AAG1B,SAAO,IAAI,SAAS,YAAY;AAC9B,QAAK,UAAU,KAAK,QAAQ;IAC5B;;;;;CAMJ,UAAmB;AACjB,MAAI,CAAC,KAAK,SACR,OAAM,IAAI,MAAM,oCAAoC;AAGtD,MAAI,KAAK,UAAU,QAAQ;AACzB,QAAK,UAAU,OAAO,IAAI;AAC1B,UAAO;SACF;AACL,QAAK,WAAW;AAChB,UAAO;;;;AAKb,MAAM,oBAAI,IAAI,KAAwB;;;;;AAMtC,eAAsB,aAAa,IAAY;AAC7C,KAAI,CAAC,EAAE,IAAI,GAAG,CACZ,GAAE,IAAI,IAAI,IAAI,WAAW,CAAC;CAG5B,MAAM,OAAO,EAAE,IAAI,GAAG;AACtB,OAAM,KAAK,cAAc;CAEzB,IAAI,WAAW;AACf,cAAa;AACX,MAAI,SAAU;AACd,aAAW;AAEX,MADgB,KAAK,SAAS,CACjB,GAAE,OAAO,GAAG"}
1
+ {"version":3,"file":"advisory_locks.js","names":[],"sources":["../../src/core/advisory_locks.ts"],"sourcesContent":["class AwaitLock {\n private acquired = false;\n private resolvers: (() => void)[] = [];\n\n acquireAsync(): Promise<void> {\n if (!this.acquired) {\n this.acquired = true;\n return Promise.resolve();\n }\n\n return new Promise((resolve) => {\n this.resolvers.push(resolve);\n });\n }\n\n /**\n * Releases the lock. Returns true if the lock becomes fully idle (no waiters, not acquired).\n */\n release(): boolean {\n if (!this.acquired) {\n throw new Error(\"Cannot release an unacquired lock\");\n }\n\n if (this.resolvers.length) {\n this.resolvers.shift()?.();\n return false;\n } else {\n this.acquired = false;\n return true;\n }\n }\n}\n\nconst m = new Map<string, AwaitLock>();\n\n/**\n * Acquire a process-local async lock for the given id and return a release function.\n * Ensures only one concurrent operation per id within this process.\n */\nexport async function advisoryLock(id: string) {\n if (!m.has(id)) {\n m.set(id, new AwaitLock());\n }\n\n const lock = m.get(id)!;\n await lock.acquireAsync();\n\n let released = false;\n return () => {\n if (released) return;\n released = true;\n const nowIdle = lock.release();\n if (nowIdle) m.delete(id);\n };\n}\n\n/**\n * Run the callback under the lock for the given id; releases automatically.\n */\nexport async function advisoryLockCallback<T>(id: string, cb: () => Promise<T>): Promise<T> {\n const release = await advisoryLock(id);\n try {\n return await cb();\n } finally {\n release();\n }\n}\n"],"mappings":";AAAA,IAAM,YAAN,MAAgB;CACd,WAAmB;CACnB,YAAoC,EAAE;CAEtC,eAA8B;AAC5B,MAAI,CAAC,KAAK,UAAU;AAClB,QAAK,WAAW;AAChB,UAAO,QAAQ,SAAS;;AAG1B,SAAO,IAAI,SAAS,YAAY;AAC9B,QAAK,UAAU,KAAK,QAAQ;IAC5B;;;;;CAMJ,UAAmB;AACjB,MAAI,CAAC,KAAK,SACR,OAAM,IAAI,MAAM,oCAAoC;AAGtD,MAAI,KAAK,UAAU,QAAQ;AACzB,QAAK,UAAU,OAAO,IAAI;AAC1B,UAAO;SACF;AACL,QAAK,WAAW;AAChB,UAAO;;;;AAKb,MAAM,oBAAI,IAAI,KAAwB;;;;;AAMtC,eAAsB,aAAa,IAAY;AAC7C,KAAI,CAAC,EAAE,IAAI,GAAG,CACZ,GAAE,IAAI,IAAI,IAAI,WAAW,CAAC;CAG5B,MAAM,OAAO,EAAE,IAAI,GAAG;AACtB,OAAM,KAAK,cAAc;CAEzB,IAAI,WAAW;AACf,cAAa;AACX,MAAI,SAAU;AACd,aAAW;AAEX,MADgB,KAAK,SAAS,CACjB,GAAE,OAAO,GAAG"}
@@ -1,5 +1,4 @@
1
- const require_pl = require('../util/pl.cjs');
2
-
1
+ const require_pl = require("../util/pl.cjs");
3
2
  //#region src/core/auth.ts
4
3
  /** Returns a timestamp when current authorization information should be refreshed.
5
4
  * Compare the value with Date.now(). */
@@ -12,8 +11,8 @@ function expirationFromAuthInformation(authInfo) {
12
11
  if (authInfo.jwtToken === void 0) return void 0;
13
12
  return require_pl.parsePlJwt(authInfo.jwtToken).exp * 1e3;
14
13
  }
15
-
16
14
  //#endregion
17
15
  exports.expirationFromAuthInformation = expirationFromAuthInformation;
18
16
  exports.inferAuthRefreshTime = inferAuthRefreshTime;
17
+
19
18
  //# sourceMappingURL=auth.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth.cjs","names":["parsePlJwt"],"sources":["../../src/core/auth.ts"],"sourcesContent":["import type { AuthInformation } from \"./config\";\nimport { parsePlJwt } from \"../util/pl\";\n\n/** Returns a timestamp when current authorization information should be refreshed.\n * Compare the value with Date.now(). */\nexport function inferAuthRefreshTime(\n info: AuthInformation,\n maxRefreshSeconds: number,\n): number | undefined {\n if (info.jwtToken === undefined) return undefined;\n\n const { exp, iat } = parsePlJwt(info.jwtToken);\n\n return (\n Math.min(\n // in the middle between issue and expiration time points\n (iat + exp) / 2,\n iat + maxRefreshSeconds,\n ) * 1000\n );\n}\n\nexport function expirationFromAuthInformation(authInfo: AuthInformation): number | undefined {\n if (authInfo.jwtToken === undefined) return undefined;\n const parsed = parsePlJwt(authInfo.jwtToken);\n return parsed.exp * 1000;\n}\n"],"mappings":";;;;;AAKA,SAAgB,qBACd,MACA,mBACoB;AACpB,KAAI,KAAK,aAAa,OAAW,QAAO;CAExC,MAAM,EAAE,KAAK,QAAQA,sBAAW,KAAK,SAAS;AAE9C,QACE,KAAK,KAEF,MAAM,OAAO,GACd,MAAM,kBACP,GAAG;;AAIR,SAAgB,8BAA8B,UAA+C;AAC3F,KAAI,SAAS,aAAa,OAAW,QAAO;AAE5C,QADeA,sBAAW,SAAS,SAAS,CAC9B,MAAM"}
1
+ {"version":3,"file":"auth.cjs","names":["parsePlJwt"],"sources":["../../src/core/auth.ts"],"sourcesContent":["import type { AuthInformation } from \"./config\";\nimport { parsePlJwt } from \"../util/pl\";\n\n/** Returns a timestamp when current authorization information should be refreshed.\n * Compare the value with Date.now(). */\nexport function inferAuthRefreshTime(\n info: AuthInformation,\n maxRefreshSeconds: number,\n): number | undefined {\n if (info.jwtToken === undefined) return undefined;\n\n const { exp, iat } = parsePlJwt(info.jwtToken);\n\n return (\n Math.min(\n // in the middle between issue and expiration time points\n (iat + exp) / 2,\n iat + maxRefreshSeconds,\n ) * 1000\n );\n}\n\nexport function expirationFromAuthInformation(authInfo: AuthInformation): number | undefined {\n if (authInfo.jwtToken === undefined) return undefined;\n const parsed = parsePlJwt(authInfo.jwtToken);\n return parsed.exp * 1000;\n}\n"],"mappings":";;;;AAKA,SAAgB,qBACd,MACA,mBACoB;AACpB,KAAI,KAAK,aAAa,KAAA,EAAW,QAAO,KAAA;CAExC,MAAM,EAAE,KAAK,QAAQA,WAAAA,WAAW,KAAK,SAAS;AAE9C,QACE,KAAK,KAEF,MAAM,OAAO,GACd,MAAM,kBACP,GAAG;;AAIR,SAAgB,8BAA8B,UAA+C;AAC3F,KAAI,SAAS,aAAa,KAAA,EAAW,QAAO,KAAA;AAE5C,QADeA,WAAAA,WAAW,SAAS,SAAS,CAC9B,MAAM"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","names":[],"sources":["../../src/core/auth.ts"],"mappings":";;;;;iBAKgB,oBAAA,CACd,IAAA,EAAM,eAAA,EACN,iBAAA;AAAA,iBAec,6BAAA,CAA8B,QAAA,EAAU,eAAA"}
package/dist/core/auth.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import { parsePlJwt } from "../util/pl.js";
2
-
3
2
  //#region src/core/auth.ts
4
3
  /** Returns a timestamp when current authorization information should be refreshed.
5
4
  * Compare the value with Date.now(). */
@@ -12,7 +11,7 @@ function expirationFromAuthInformation(authInfo) {
12
11
  if (authInfo.jwtToken === void 0) return void 0;
13
12
  return parsePlJwt(authInfo.jwtToken).exp * 1e3;
14
13
  }
15
-
16
14
  //#endregion
17
15
  export { expirationFromAuthInformation, inferAuthRefreshTime };
16
+
18
17
  //# sourceMappingURL=auth.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth.js","names":[],"sources":["../../src/core/auth.ts"],"sourcesContent":["import type { AuthInformation } from \"./config\";\nimport { parsePlJwt } from \"../util/pl\";\n\n/** Returns a timestamp when current authorization information should be refreshed.\n * Compare the value with Date.now(). */\nexport function inferAuthRefreshTime(\n info: AuthInformation,\n maxRefreshSeconds: number,\n): number | undefined {\n if (info.jwtToken === undefined) return undefined;\n\n const { exp, iat } = parsePlJwt(info.jwtToken);\n\n return (\n Math.min(\n // in the middle between issue and expiration time points\n (iat + exp) / 2,\n iat + maxRefreshSeconds,\n ) * 1000\n );\n}\n\nexport function expirationFromAuthInformation(authInfo: AuthInformation): number | undefined {\n if (authInfo.jwtToken === undefined) return undefined;\n const parsed = parsePlJwt(authInfo.jwtToken);\n return parsed.exp * 1000;\n}\n"],"mappings":";;;;;AAKA,SAAgB,qBACd,MACA,mBACoB;AACpB,KAAI,KAAK,aAAa,OAAW,QAAO;CAExC,MAAM,EAAE,KAAK,QAAQ,WAAW,KAAK,SAAS;AAE9C,QACE,KAAK,KAEF,MAAM,OAAO,GACd,MAAM,kBACP,GAAG;;AAIR,SAAgB,8BAA8B,UAA+C;AAC3F,KAAI,SAAS,aAAa,OAAW,QAAO;AAE5C,QADe,WAAW,SAAS,SAAS,CAC9B,MAAM"}
1
+ {"version":3,"file":"auth.js","names":[],"sources":["../../src/core/auth.ts"],"sourcesContent":["import type { AuthInformation } from \"./config\";\nimport { parsePlJwt } from \"../util/pl\";\n\n/** Returns a timestamp when current authorization information should be refreshed.\n * Compare the value with Date.now(). */\nexport function inferAuthRefreshTime(\n info: AuthInformation,\n maxRefreshSeconds: number,\n): number | undefined {\n if (info.jwtToken === undefined) return undefined;\n\n const { exp, iat } = parsePlJwt(info.jwtToken);\n\n return (\n Math.min(\n // in the middle between issue and expiration time points\n (iat + exp) / 2,\n iat + maxRefreshSeconds,\n ) * 1000\n );\n}\n\nexport function expirationFromAuthInformation(authInfo: AuthInformation): number | undefined {\n if (authInfo.jwtToken === undefined) return undefined;\n const parsed = parsePlJwt(authInfo.jwtToken);\n return parsed.exp * 1000;\n}\n"],"mappings":";;;;AAKA,SAAgB,qBACd,MACA,mBACoB;AACpB,KAAI,KAAK,aAAa,KAAA,EAAW,QAAO,KAAA;CAExC,MAAM,EAAE,KAAK,QAAQ,WAAW,KAAK,SAAS;AAE9C,QACE,KAAK,KAEF,MAAM,OAAO,GACd,MAAM,kBACP,GAAG;;AAIR,SAAgB,8BAA8B,UAA+C;AAC3F,KAAI,SAAS,aAAa,KAAA,EAAW,QAAO,KAAA;AAE5C,QADe,WAAW,SAAS,SAAS,CAC9B,MAAM"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache.d.ts","names":[],"sources":["../../src/core/cache.ts"],"mappings":";;;KAEY,uBAAA;;AAAZ;EAGE,oBAAA;EACA,IAAA,EAAM,YAAA;EAAA,SACG,SAAA,EAAW,iBAAA;AAAA"}
@@ -1,19 +1,19 @@
1
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
- const require_types = require('./types.cjs');
3
- const require_api = require('../proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.cjs');
4
- const require_stat = require('./stat.cjs');
5
- const require_transaction = require('./transaction.cjs');
6
- const require_pl = require('../helpers/pl.cjs');
7
- const require_config = require('./config.cjs');
8
- const require_ll_client = require('./ll_client.cjs');
9
- const require_final = require('./final.cjs');
10
- const require_advisory_locks = require('./advisory_locks.cjs');
1
+ const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
2
+ const require_types = require("./types.cjs");
3
+ const require_api = require("../proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.cjs");
4
+ const require_errors = require("./errors.cjs");
5
+ const require_stat = require("./stat.cjs");
6
+ const require_transaction = require("./transaction.cjs");
7
+ const require_pl = require("../helpers/pl.cjs");
8
+ const require_config = require("./config.cjs");
9
+ const require_ll_client = require("./ll_client.cjs");
10
+ const require_final = require("./final.cjs");
11
+ const require_advisory_locks = require("./advisory_locks.cjs");
11
12
  let _milaboratories_ts_helpers = require("@milaboratories/ts-helpers");
12
13
  let node_crypto = require("node:crypto");
13
14
  let node_timers_promises = require("node:timers/promises");
14
15
  node_timers_promises = require_runtime.__toESM(node_timers_promises);
15
16
  let lru_cache = require("lru-cache");
16
-
17
17
  //#region src/core/client.ts
18
18
  const defaultTxOps = { sync: false };
19
19
  const AnonymousClientRoot = "AnonymousRoot";
@@ -133,41 +133,68 @@ var PlClient = class PlClient {
133
133
  this.checkInitialized();
134
134
  return this._serverInfo;
135
135
  }
136
- /** Currently implements custom logic to emulate future behaviour with single root. */
136
+ /** Discovers or creates the user's root resource.
137
+ * Tries ListUserResources RPC first (new backend), falls back to
138
+ * legacy named-resource lookup for older backends. */
137
139
  async init() {
138
140
  if (this.initialized) throw new Error("Already initialized");
139
141
  this._ll = await this.buildLLPlClient(false);
140
142
  const wireProtocol = this._ll.wireProtocol;
141
- const user = this._ll.authUser;
142
- const mainRootName = user === null ? AnonymousClientRoot : (0, node_crypto.createHash)("sha256").update(user).digest("hex");
143
143
  this._serverInfo = await this.ping();
144
144
  if (this._serverInfo.compression === require_api.MaintenanceAPI_Ping_Response_Compression.GZIP) {
145
145
  await this._ll.close();
146
146
  this._ll = await this.buildLLPlClient(true, wireProtocol);
147
147
  }
148
- this._clientRoot = await this._withTx("initialization", true, require_types.NullResourceId, async (tx) => {
149
- let mainRoot;
150
- if (await tx.checkResourceNameExists(mainRootName)) mainRoot = await tx.getResourceByName(mainRootName);
151
- else {
152
- mainRoot = tx.createRoot(require_pl.ClientRoot);
153
- tx.setResourceName(mainRootName, mainRoot);
154
- }
155
- if (this.conf.alternativeRoot === void 0) {
156
- await tx.commit();
157
- return await require_transaction.toGlobalResourceId(mainRoot);
158
- } else {
159
- const aFId = {
160
- resourceId: mainRoot,
161
- fieldName: alternativeRootFieldName(this.conf.alternativeRoot)
162
- };
163
- const altRoot = tx.createEphemeral(require_pl.ClientRoot);
164
- tx.lock(altRoot);
165
- tx.createField(aFId, "Dynamic");
166
- tx.setField(aFId, altRoot);
167
- await tx.commit();
168
- return await altRoot.globalId;
148
+ let rootFromServer;
149
+ try {
150
+ const responses = await this._ll.listUserResources({ limit: 1 });
151
+ for (const msg of responses) if (msg.entry.oneofKind === "userRoot") {
152
+ rootFromServer = require_types.bigintToResourceId(msg.entry.userRoot.resourceId);
153
+ break;
169
154
  }
155
+ } catch (err) {
156
+ if (!require_errors.isUnimplementedError(err)) throw err;
157
+ }
158
+ if (rootFromServer !== void 0) if (this.conf.alternativeRoot === void 0) this._clientRoot = rootFromServer;
159
+ else this._clientRoot = await this._withTx("initialization", true, rootFromServer, async (tx) => {
160
+ const aFId = {
161
+ resourceId: tx.clientRoot,
162
+ fieldName: alternativeRootFieldName(this.conf.alternativeRoot)
163
+ };
164
+ const altRoot = tx.createEphemeral(require_pl.ClientRoot);
165
+ tx.lock(altRoot);
166
+ tx.createField(aFId, "Dynamic");
167
+ tx.setField(aFId, altRoot);
168
+ await tx.commit();
169
+ return await altRoot.globalId;
170
170
  });
171
+ else {
172
+ const user = this._ll.authUser;
173
+ const mainRootName = user === null ? AnonymousClientRoot : (0, node_crypto.createHash)("sha256").update(user).digest("hex");
174
+ this._clientRoot = await this._withTx("initialization", true, require_types.NullResourceId, async (tx) => {
175
+ let mainRoot;
176
+ if (await tx.checkResourceNameExists(mainRootName)) mainRoot = await tx.getResourceByName(mainRootName);
177
+ else {
178
+ mainRoot = tx.createRoot(require_pl.ClientRoot);
179
+ tx.setResourceName(mainRootName, mainRoot);
180
+ }
181
+ if (this.conf.alternativeRoot === void 0) {
182
+ await tx.commit();
183
+ return await require_transaction.toGlobalResourceId(mainRoot);
184
+ } else {
185
+ const aFId = {
186
+ resourceId: mainRoot,
187
+ fieldName: alternativeRootFieldName(this.conf.alternativeRoot)
188
+ };
189
+ const altRoot = tx.createEphemeral(require_pl.ClientRoot);
190
+ tx.lock(altRoot);
191
+ tx.createField(aFId, "Dynamic");
192
+ tx.setField(aFId, altRoot);
193
+ await tx.commit();
194
+ return await altRoot.globalId;
195
+ }
196
+ });
197
+ }
171
198
  }
172
199
  /** Returns true if field existed */
173
200
  async deleteAlternativeRoot(alternativeRootName) {
@@ -256,7 +283,7 @@ var PlClient = class PlClient {
256
283
  return pl;
257
284
  }
258
285
  };
259
-
260
286
  //#endregion
261
287
  exports.PlClient = PlClient;
288
+
262
289
  //# sourceMappingURL=client.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.cjs","names":["NullResourceId","initialTxStat","plAddressToConfig","LLPlClient","DefaultFinalResourceDataPredicate","LRUCache","addStat","isNullResourceId","ensureResourceIdNotNull","MaintenanceAPI_Ping_Response_Compression","ClientRoot","toGlobalResourceId","advisoryLock","PlTransaction","TxCommitConflict","tp"],"sources":["../../src/core/client.ts"],"sourcesContent":["import type { AuthOps, PlClientConfig, PlConnectionStatusListener, wireProtocol } from \"./config\";\nimport type { PlCallOps } from \"./ll_client\";\nimport { LLPlClient } from \"./ll_client\";\nimport type { AnyResourceRef } from \"./transaction\";\nimport { PlTransaction, toGlobalResourceId, TxCommitConflict } from \"./transaction\";\nimport { createHash } from \"node:crypto\";\nimport type { OptionalResourceId, ResourceId } from \"./types\";\nimport { ensureResourceIdNotNull, isNullResourceId, NullResourceId } from \"./types\";\nimport { ClientRoot } from \"../helpers/pl\";\nimport type { MiLogger, RetryOptions } from \"@milaboratories/ts-helpers\";\nimport { assertNever, createRetryState, nextRetryStateOrError } from \"@milaboratories/ts-helpers\";\nimport type { PlDriver, PlDriverDefinition } from \"./driver\";\nimport type {\n MaintenanceAPI_Ping_Response,\n MaintenanceAPI_License_Response,\n} from \"../proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api\";\nimport { MaintenanceAPI_Ping_Response_Compression } from \"../proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api\";\nimport * as tp from \"node:timers/promises\";\nimport type { Dispatcher } from \"undici\";\nimport { LRUCache } from \"lru-cache\";\nimport type { ResourceDataCacheRecord } from \"./cache\";\nimport type { FinalResourceDataPredicate } from \"./final\";\nimport { DefaultFinalResourceDataPredicate } from \"./final\";\nimport type { AllTxStat, TxStat } from \"./stat\";\nimport { addStat, initialTxStat } from \"./stat\";\nimport type { WireConnection } from \"./wire\";\nimport { advisoryLock } from \"./advisory_locks\";\nimport { plAddressToConfig } from \"./config\";\n\nexport type TxOps = PlCallOps & {\n sync?: boolean;\n retryOptions?: RetryOptions;\n name?: string;\n lockId?: string;\n};\n\nconst defaultTxOps = {\n sync: false,\n};\n\nconst AnonymousClientRoot = \"AnonymousRoot\";\n\nfunction alternativeRootFieldName(alternativeRoot: string): string {\n return `alternative_root_${alternativeRoot}`;\n}\n\n/** Client to access core PL API. */\nexport class PlClient {\n private readonly drivers = new Map<string, PlDriver>();\n\n /** Artificial delay introduced after write transactions completion, to\n * somewhat throttle the load on pl. Delay introduced after sync, if requested. */\n private readonly txDelay: number;\n\n /** Last resort measure to solve complicated race conditions in pl. */\n private readonly forceSync: boolean;\n\n /** Last resort measure to solve complicated race conditions in pl. */\n private readonly defaultRetryOptions: RetryOptions;\n\n private readonly buildLLPlClient: (\n shouldUseGzip: boolean,\n wireProtocol?: wireProtocol,\n ) => Promise<LLPlClient>;\n private _ll?: LLPlClient;\n\n private get ll(): LLPlClient {\n if (this._ll === undefined) {\n throw new Error(\"LLPlClient not initialized\");\n }\n return this._ll;\n }\n\n /** Stores client root (this abstraction is intended for future implementation of the security model) */\n private _clientRoot: OptionalResourceId = NullResourceId;\n\n private _serverInfo: MaintenanceAPI_Ping_Response | undefined = undefined;\n\n private _txCommittedStat: TxStat = initialTxStat();\n private _txConflictStat: TxStat = initialTxStat();\n private _txErrorStat: TxStat = initialTxStat();\n\n //\n // Caching\n //\n\n /** This function determines whether resource data can be cached */\n public readonly finalPredicate: FinalResourceDataPredicate;\n\n /** Resource data cache, to minimize redundant data rereading from remote db */\n private readonly resourceDataCache: LRUCache<ResourceId, ResourceDataCacheRecord>;\n\n private constructor(\n configOrAddress: PlClientConfig | string,\n auth: AuthOps,\n ops: {\n statusListener?: PlConnectionStatusListener;\n finalPredicate?: FinalResourceDataPredicate;\n logger?: MiLogger;\n } = {},\n ) {\n const conf =\n typeof configOrAddress === \"string\" ? plAddressToConfig(configOrAddress) : configOrAddress;\n\n this.buildLLPlClient = async (\n shouldUseGzip: boolean,\n wireProtocol?: wireProtocol,\n ): Promise<LLPlClient> => {\n if (wireProtocol) conf.wireProtocol = wireProtocol;\n return await LLPlClient.build(conf, { auth, ...ops, shouldUseGzip });\n };\n\n this.txDelay = conf.txDelay;\n this.forceSync = conf.forceSync;\n this.finalPredicate = ops.finalPredicate ?? DefaultFinalResourceDataPredicate;\n this.resourceDataCache = new LRUCache({\n maxSize: conf.maxCacheBytes,\n sizeCalculation: (v) => (v.basicData.data?.length ?? 0) + 64,\n });\n switch (conf.retryBackoffAlgorithm) {\n case \"exponential\":\n this.defaultRetryOptions = {\n type: \"exponentialBackoff\",\n initialDelay: conf.retryInitialDelay,\n maxAttempts: conf.retryMaxAttempts,\n backoffMultiplier: conf.retryExponentialBackoffMultiplier,\n jitter: conf.retryJitter,\n };\n break;\n case \"linear\":\n this.defaultRetryOptions = {\n type: \"linearBackoff\",\n initialDelay: conf.retryInitialDelay,\n maxAttempts: conf.retryMaxAttempts,\n backoffStep: conf.retryLinearBackoffStep,\n jitter: conf.retryJitter,\n };\n break;\n default:\n assertNever(conf.retryBackoffAlgorithm);\n }\n }\n\n public get txCommittedStat(): TxStat {\n return { ...this._txCommittedStat };\n }\n\n public get txConflictStat(): TxStat {\n return { ...this._txConflictStat };\n }\n\n public get txErrorStat(): TxStat {\n return { ...this._txErrorStat };\n }\n\n public get txTotalStat(): TxStat {\n return addStat(addStat(this._txCommittedStat, this._txConflictStat), this._txErrorStat);\n }\n\n public get allTxStat(): AllTxStat {\n return {\n committed: this.txCommittedStat,\n conflict: this.txConflictStat,\n error: this.txErrorStat,\n };\n }\n\n public async ping(): Promise<MaintenanceAPI_Ping_Response> {\n return await this.ll.ping();\n }\n\n public async license(): Promise<MaintenanceAPI_License_Response> {\n return await this.ll.license();\n }\n\n public get conf(): PlClientConfig {\n return this.ll.conf;\n }\n\n public get httpDispatcher(): Dispatcher {\n return this.ll.httpDispatcher;\n }\n\n public get connectionOpts(): WireConnection {\n return this.ll.wireConnection;\n }\n\n private get initialized() {\n return !isNullResourceId(this._clientRoot);\n }\n\n private checkInitialized() {\n if (!this.initialized) throw new Error(\"Client not initialized\");\n }\n\n public get clientRoot(): ResourceId {\n this.checkInitialized();\n return ensureResourceIdNotNull(this._clientRoot);\n }\n\n public get serverInfo(): MaintenanceAPI_Ping_Response {\n this.checkInitialized();\n return this._serverInfo!;\n }\n\n /** Currently implements custom logic to emulate future behaviour with single root. */\n private async init() {\n if (this.initialized) throw new Error(\"Already initialized\");\n\n // Initial client is created without gzip to perform server ping and detect optimal wire protocol.\n // LLPlClient.build() internally calls detectOptimalWireProtocol() which starts with default 'grpc',\n // then retries with 'rest' if ping fails, alternating until a working protocol is found.\n // We save the detected wireProtocol here because if the server supports gzip compression,\n // we'll need to reinitialize the client with gzip enabled - passing the already-detected\n // wireProtocol avoids redundant protocol detection on reinit.\n this._ll = await this.buildLLPlClient(false);\n const wireProtocol = this._ll.wireProtocol;\n\n // calculating reproducible root name from the username\n const user = this._ll.authUser;\n const mainRootName =\n user === null ? AnonymousClientRoot : createHash(\"sha256\").update(user).digest(\"hex\");\n\n this._serverInfo = await this.ping();\n if (this._serverInfo.compression === MaintenanceAPI_Ping_Response_Compression.GZIP) {\n await this._ll.close();\n this._ll = await this.buildLLPlClient(true, wireProtocol);\n }\n\n this._clientRoot = await this._withTx(\"initialization\", true, NullResourceId, async (tx) => {\n let mainRoot: AnyResourceRef;\n\n if (await tx.checkResourceNameExists(mainRootName))\n mainRoot = await tx.getResourceByName(mainRootName);\n else {\n mainRoot = tx.createRoot(ClientRoot);\n tx.setResourceName(mainRootName, mainRoot);\n }\n\n if (this.conf.alternativeRoot === undefined) {\n await tx.commit();\n return await toGlobalResourceId(mainRoot);\n } else {\n const aFId = {\n resourceId: mainRoot,\n fieldName: alternativeRootFieldName(this.conf.alternativeRoot),\n };\n\n const altRoot = tx.createEphemeral(ClientRoot);\n tx.lock(altRoot);\n tx.createField(aFId, \"Dynamic\");\n tx.setField(aFId, altRoot);\n await tx.commit();\n\n return await altRoot.globalId;\n }\n });\n }\n\n /** Returns true if field existed */\n public async deleteAlternativeRoot(alternativeRootName: string): Promise<boolean> {\n this.checkInitialized();\n if (this.ll.conf.alternativeRoot !== undefined)\n throw new Error(\"Initialized with alternative root.\");\n return await this.withWriteTx(\"delete-alternative-root\", async (tx) => {\n const fId = {\n resourceId: tx.clientRoot,\n fieldName: alternativeRootFieldName(alternativeRootName),\n };\n const exists = tx.fieldExists(fId);\n tx.removeField(fId);\n await tx.commit();\n return await exists;\n });\n }\n\n private async _withTx<T>(\n name: string,\n writable: boolean,\n clientRoot: OptionalResourceId,\n body: (tx: PlTransaction) => Promise<T>,\n ops?: TxOps,\n ): Promise<T> {\n // for exponential / linear backoff\n let retryState = createRetryState(ops?.retryOptions ?? this.defaultRetryOptions);\n\n while (true) {\n const release = ops?.lockId ? await advisoryLock(ops.lockId) : () => {};\n\n try {\n // opening low-level tx\n const llTx = this.ll.createTx(writable, ops);\n // wrapping it into high-level tx (this also asynchronously sends initialization message)\n const tx = new PlTransaction(\n llTx,\n name,\n writable,\n clientRoot,\n this.finalPredicate,\n this.resourceDataCache,\n );\n\n let ok = false;\n let result: T | undefined = undefined;\n let txId;\n\n try {\n // executing transaction body\n result = await body(tx);\n // collecting stat\n this._txCommittedStat = addStat(this._txCommittedStat, tx.stat);\n ok = true;\n } catch (e: unknown) {\n // the only recoverable\n if (e instanceof TxCommitConflict) {\n // ignoring\n // collecting stat\n this._txConflictStat = addStat(this._txConflictStat, tx.stat);\n } else {\n // collecting stat\n this._txErrorStat = addStat(this._txErrorStat, tx.stat);\n throw e;\n }\n } finally {\n // close underlying grpc stream, if not yet done\n\n // even though we can skip two lines below for read-only transactions,\n // we don't do it to simplify reasoning about what is going on in\n // concurrent code, especially in significant latency situations\n await tx.complete();\n await tx.await();\n\n txId = await tx.getGlobalTxId();\n }\n\n if (ok) {\n // syncing on transaction if requested\n if (ops?.sync === undefined ? this.forceSync : ops?.sync) await this.ll.txSync(txId);\n\n // introducing artificial delay, if requested\n if (writable && this.txDelay > 0)\n await tp.setTimeout(this.txDelay, undefined, { signal: ops?.abortSignal });\n\n return result!;\n }\n } finally {\n release();\n }\n\n // we only get here after TxCommitConflict error,\n // all other errors terminate this loop instantly\n\n await tp.setTimeout(retryState.nextDelay, undefined, { signal: ops?.abortSignal });\n retryState = nextRetryStateOrError(retryState);\n }\n }\n\n private async withTx<T>(\n name: string,\n writable: boolean,\n body: (tx: PlTransaction) => Promise<T>,\n ops: Partial<TxOps> = {},\n ): Promise<T> {\n this.checkInitialized();\n return await this._withTx(name, writable, this.clientRoot, body, { ...ops, ...defaultTxOps });\n }\n\n public async withWriteTx<T>(\n name: string,\n body: (tx: PlTransaction) => Promise<T>,\n ops: Partial<TxOps> = {},\n ): Promise<T> {\n return await this.withTx(name, true, body, { ...ops, ...defaultTxOps });\n }\n\n public async withReadTx<T>(\n name: string,\n body: (tx: PlTransaction) => Promise<T>,\n ops: Partial<TxOps> = {},\n ): Promise<T> {\n return await this.withTx(name, false, body, { ...ops, ...defaultTxOps });\n }\n\n public getDriver<Drv extends PlDriver>(definition: PlDriverDefinition<Drv>): Drv {\n const attached = this.drivers.get(definition.name);\n if (attached !== undefined) return attached as Drv;\n const driver = definition.init(this, this.ll, this.httpDispatcher);\n this.drivers.set(definition.name, driver);\n return driver;\n }\n\n /** Closes underlying transport */\n public async close() {\n await this.ll.close();\n }\n\n public static async init(\n configOrAddress: PlClientConfig | string,\n auth: AuthOps,\n ops: {\n statusListener?: PlConnectionStatusListener;\n logger?: MiLogger;\n } = {},\n ) {\n const pl = new PlClient(configOrAddress, auth, ops);\n await pl.init();\n return pl;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAoCA,MAAM,eAAe,EACnB,MAAM,OACP;AAED,MAAM,sBAAsB;AAE5B,SAAS,yBAAyB,iBAAiC;AACjE,QAAO,oBAAoB;;;AAI7B,IAAa,WAAb,MAAa,SAAS;CACpB,AAAiB,0BAAU,IAAI,KAAuB;;;CAItD,AAAiB;;CAGjB,AAAiB;;CAGjB,AAAiB;CAEjB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EACnC,MAAM,SAAS,WAAW,KAAK,MAAM,KAAK,IAAI,KAAK,eAAe;AAClE,OAAK,QAAQ,IAAI,WAAW,MAAM,OAAO;AACzC,SAAO;;;CAIT,MAAa,QAAQ;AACnB,QAAM,KAAK,GAAG,OAAO;;CAGvB,aAAoB,KAClB,iBACA,MACA,MAGI,EAAE,EACN;EACA,MAAM,KAAK,IAAI,SAAS,iBAAiB,MAAM,IAAI;AACnD,QAAM,GAAG,MAAM;AACf,SAAO"}
1
+ {"version":3,"file":"client.cjs","names":["NullResourceId","initialTxStat","plAddressToConfig","LLPlClient","DefaultFinalResourceDataPredicate","LRUCache","addStat","isNullResourceId","ensureResourceIdNotNull","MaintenanceAPI_Ping_Response_Compression","bigintToResourceId","isUnimplementedError","ClientRoot","toGlobalResourceId","advisoryLock","PlTransaction","TxCommitConflict","tp"],"sources":["../../src/core/client.ts"],"sourcesContent":["import type { AuthOps, PlClientConfig, PlConnectionStatusListener, wireProtocol } from \"./config\";\nimport type { PlCallOps } from \"./ll_client\";\nimport { LLPlClient } from \"./ll_client\";\nimport type { AnyResourceRef } from \"./transaction\";\nimport { PlTransaction, toGlobalResourceId, TxCommitConflict } from \"./transaction\";\nimport { createHash } from \"node:crypto\";\nimport type { OptionalResourceId, ResourceId } from \"./types\";\nimport {\n bigintToResourceId,\n ensureResourceIdNotNull,\n isNullResourceId,\n NullResourceId,\n} from \"./types\";\nimport { ClientRoot } from \"../helpers/pl\";\nimport { isUnimplementedError } from \"./errors\";\nimport type { MiLogger, RetryOptions } from \"@milaboratories/ts-helpers\";\nimport { assertNever, createRetryState, nextRetryStateOrError } from \"@milaboratories/ts-helpers\";\nimport type { PlDriver, PlDriverDefinition } from \"./driver\";\nimport type {\n MaintenanceAPI_Ping_Response,\n MaintenanceAPI_License_Response,\n} from \"../proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api\";\nimport { MaintenanceAPI_Ping_Response_Compression } from \"../proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api\";\nimport * as tp from \"node:timers/promises\";\nimport type { Dispatcher } from \"undici\";\nimport { LRUCache } from \"lru-cache\";\nimport type { ResourceDataCacheRecord } from \"./cache\";\nimport type { FinalResourceDataPredicate } from \"./final\";\nimport { DefaultFinalResourceDataPredicate } from \"./final\";\nimport type { AllTxStat, TxStat } from \"./stat\";\nimport { addStat, initialTxStat } from \"./stat\";\nimport type { WireConnection } from \"./wire\";\nimport { advisoryLock } from \"./advisory_locks\";\nimport { plAddressToConfig } from \"./config\";\n\nexport type TxOps = PlCallOps & {\n sync?: boolean;\n retryOptions?: RetryOptions;\n name?: string;\n lockId?: string;\n};\n\nconst defaultTxOps = {\n sync: false,\n};\n\nconst AnonymousClientRoot = \"AnonymousRoot\";\n\nfunction alternativeRootFieldName(alternativeRoot: string): string {\n return `alternative_root_${alternativeRoot}`;\n}\n\n/** Client to access core PL API. */\nexport class PlClient {\n private readonly drivers = new Map<string, PlDriver>();\n\n /** Artificial delay introduced after write transactions completion, to\n * somewhat throttle the load on pl. Delay introduced after sync, if requested. */\n private readonly txDelay: number;\n\n /** Last resort measure to solve complicated race conditions in pl. */\n private readonly forceSync: boolean;\n\n /** Last resort measure to solve complicated race conditions in pl. */\n private readonly defaultRetryOptions: RetryOptions;\n\n private readonly buildLLPlClient: (\n shouldUseGzip: boolean,\n wireProtocol?: wireProtocol,\n ) => Promise<LLPlClient>;\n private _ll?: LLPlClient;\n\n private get ll(): LLPlClient {\n if (this._ll === undefined) {\n throw new Error(\"LLPlClient not initialized\");\n }\n return this._ll;\n }\n\n /** Stores client root (this abstraction is intended for future implementation of the security model) */\n private _clientRoot: OptionalResourceId = NullResourceId;\n\n private _serverInfo: MaintenanceAPI_Ping_Response | undefined = undefined;\n\n private _txCommittedStat: TxStat = initialTxStat();\n private _txConflictStat: TxStat = initialTxStat();\n private _txErrorStat: TxStat = initialTxStat();\n\n //\n // Caching\n //\n\n /** This function determines whether resource data can be cached */\n public readonly finalPredicate: FinalResourceDataPredicate;\n\n /** Resource data cache, to minimize redundant data rereading from remote db */\n private readonly resourceDataCache: LRUCache<ResourceId, ResourceDataCacheRecord>;\n\n private constructor(\n configOrAddress: PlClientConfig | string,\n auth: AuthOps,\n ops: {\n statusListener?: PlConnectionStatusListener;\n finalPredicate?: FinalResourceDataPredicate;\n logger?: MiLogger;\n } = {},\n ) {\n const conf =\n typeof configOrAddress === \"string\" ? plAddressToConfig(configOrAddress) : configOrAddress;\n\n this.buildLLPlClient = async (\n shouldUseGzip: boolean,\n wireProtocol?: wireProtocol,\n ): Promise<LLPlClient> => {\n if (wireProtocol) conf.wireProtocol = wireProtocol;\n return await LLPlClient.build(conf, { auth, ...ops, shouldUseGzip });\n };\n\n this.txDelay = conf.txDelay;\n this.forceSync = conf.forceSync;\n this.finalPredicate = ops.finalPredicate ?? DefaultFinalResourceDataPredicate;\n this.resourceDataCache = new LRUCache({\n maxSize: conf.maxCacheBytes,\n sizeCalculation: (v) => (v.basicData.data?.length ?? 0) + 64,\n });\n switch (conf.retryBackoffAlgorithm) {\n case \"exponential\":\n this.defaultRetryOptions = {\n type: \"exponentialBackoff\",\n initialDelay: conf.retryInitialDelay,\n maxAttempts: conf.retryMaxAttempts,\n backoffMultiplier: conf.retryExponentialBackoffMultiplier,\n jitter: conf.retryJitter,\n };\n break;\n case \"linear\":\n this.defaultRetryOptions = {\n type: \"linearBackoff\",\n initialDelay: conf.retryInitialDelay,\n maxAttempts: conf.retryMaxAttempts,\n backoffStep: conf.retryLinearBackoffStep,\n jitter: conf.retryJitter,\n };\n break;\n default:\n assertNever(conf.retryBackoffAlgorithm);\n }\n }\n\n public get txCommittedStat(): TxStat {\n return { ...this._txCommittedStat };\n }\n\n public get txConflictStat(): TxStat {\n return { ...this._txConflictStat };\n }\n\n public get txErrorStat(): TxStat {\n return { ...this._txErrorStat };\n }\n\n public get txTotalStat(): TxStat {\n return addStat(addStat(this._txCommittedStat, this._txConflictStat), this._txErrorStat);\n }\n\n public get allTxStat(): AllTxStat {\n return {\n committed: this.txCommittedStat,\n conflict: this.txConflictStat,\n error: this.txErrorStat,\n };\n }\n\n public async ping(): Promise<MaintenanceAPI_Ping_Response> {\n return await this.ll.ping();\n }\n\n public async license(): Promise<MaintenanceAPI_License_Response> {\n return await this.ll.license();\n }\n\n public get conf(): PlClientConfig {\n return this.ll.conf;\n }\n\n public get httpDispatcher(): Dispatcher {\n return this.ll.httpDispatcher;\n }\n\n public get connectionOpts(): WireConnection {\n return this.ll.wireConnection;\n }\n\n private get initialized() {\n return !isNullResourceId(this._clientRoot);\n }\n\n private checkInitialized() {\n if (!this.initialized) throw new Error(\"Client not initialized\");\n }\n\n public get clientRoot(): ResourceId {\n this.checkInitialized();\n return ensureResourceIdNotNull(this._clientRoot);\n }\n\n public get serverInfo(): MaintenanceAPI_Ping_Response {\n this.checkInitialized();\n return this._serverInfo!;\n }\n\n /** Discovers or creates the user's root resource.\n * Tries ListUserResources RPC first (new backend), falls back to\n * legacy named-resource lookup for older backends. */\n private async init() {\n if (this.initialized) throw new Error(\"Already initialized\");\n\n // Initial client is created without gzip to perform server ping and detect optimal wire protocol.\n // LLPlClient.build() internally calls detectOptimalWireProtocol() which starts with default 'grpc',\n // then retries with 'rest' if ping fails, alternating until a working protocol is found.\n // We save the detected wireProtocol here because if the server supports gzip compression,\n // we'll need to reinitialize the client with gzip enabled - passing the already-detected\n // wireProtocol avoids redundant protocol detection on reinit.\n this._ll = await this.buildLLPlClient(false);\n const wireProtocol = this._ll.wireProtocol;\n\n this._serverInfo = await this.ping();\n if (this._serverInfo.compression === MaintenanceAPI_Ping_Response_Compression.GZIP) {\n await this._ll.close();\n this._ll = await this.buildLLPlClient(true, wireProtocol);\n }\n\n // Try ListUserResources first (new backend, gRPC only)\n let rootFromServer: ResourceId | undefined;\n try {\n const responses = await this._ll.listUserResources({ limit: 1 });\n for (const msg of responses) {\n if (msg.entry.oneofKind === \"userRoot\") {\n rootFromServer = bigintToResourceId(msg.entry.userRoot.resourceId);\n break;\n }\n }\n } catch (err) {\n if (!isUnimplementedError(err)) throw err;\n // Backend doesn't support ListUserResources — fall through to legacy\n }\n\n if (rootFromServer !== undefined) {\n // New path: server created/returned the root\n if (this.conf.alternativeRoot === undefined) {\n this._clientRoot = rootFromServer;\n } else {\n this._clientRoot = await this._withTx(\n \"initialization\",\n true,\n rootFromServer,\n async (tx) => {\n const aFId = {\n resourceId: tx.clientRoot,\n fieldName: alternativeRootFieldName(this.conf.alternativeRoot!),\n };\n\n const altRoot = tx.createEphemeral(ClientRoot);\n tx.lock(altRoot);\n tx.createField(aFId, \"Dynamic\");\n tx.setField(aFId, altRoot);\n await tx.commit();\n\n return await altRoot.globalId;\n },\n );\n }\n } else {\n // Legacy path: named resource lookup\n const user = this._ll.authUser;\n const mainRootName =\n user === null ? AnonymousClientRoot : createHash(\"sha256\").update(user).digest(\"hex\");\n\n this._clientRoot = await this._withTx(\"initialization\", true, NullResourceId, async (tx) => {\n let mainRoot: AnyResourceRef;\n\n if (await tx.checkResourceNameExists(mainRootName))\n mainRoot = await tx.getResourceByName(mainRootName);\n else {\n mainRoot = tx.createRoot(ClientRoot);\n tx.setResourceName(mainRootName, mainRoot);\n }\n\n if (this.conf.alternativeRoot === undefined) {\n await tx.commit();\n return await toGlobalResourceId(mainRoot);\n } else {\n const aFId = {\n resourceId: mainRoot,\n fieldName: alternativeRootFieldName(this.conf.alternativeRoot),\n };\n\n const altRoot = tx.createEphemeral(ClientRoot);\n tx.lock(altRoot);\n tx.createField(aFId, \"Dynamic\");\n tx.setField(aFId, altRoot);\n await tx.commit();\n\n return await altRoot.globalId;\n }\n });\n }\n }\n\n /** Returns true if field existed */\n public async deleteAlternativeRoot(alternativeRootName: string): Promise<boolean> {\n this.checkInitialized();\n if (this.ll.conf.alternativeRoot !== undefined)\n throw new Error(\"Initialized with alternative root.\");\n return await this.withWriteTx(\"delete-alternative-root\", async (tx) => {\n const fId = {\n resourceId: tx.clientRoot,\n fieldName: alternativeRootFieldName(alternativeRootName),\n };\n const exists = tx.fieldExists(fId);\n tx.removeField(fId);\n await tx.commit();\n return await exists;\n });\n }\n\n private async _withTx<T>(\n name: string,\n writable: boolean,\n clientRoot: OptionalResourceId,\n body: (tx: PlTransaction) => Promise<T>,\n ops?: TxOps,\n ): Promise<T> {\n // for exponential / linear backoff\n let retryState = createRetryState(ops?.retryOptions ?? this.defaultRetryOptions);\n\n while (true) {\n const release = ops?.lockId ? await advisoryLock(ops.lockId) : () => {};\n\n try {\n // opening low-level tx\n const llTx = this.ll.createTx(writable, ops);\n // wrapping it into high-level tx (this also asynchronously sends initialization message)\n const tx = new PlTransaction(\n llTx,\n name,\n writable,\n clientRoot,\n this.finalPredicate,\n this.resourceDataCache,\n );\n\n let ok = false;\n let result: T | undefined = undefined;\n let txId;\n\n try {\n // executing transaction body\n result = await body(tx);\n // collecting stat\n this._txCommittedStat = addStat(this._txCommittedStat, tx.stat);\n ok = true;\n } catch (e: unknown) {\n // the only recoverable\n if (e instanceof TxCommitConflict) {\n // ignoring\n // collecting stat\n this._txConflictStat = addStat(this._txConflictStat, tx.stat);\n } else {\n // collecting stat\n this._txErrorStat = addStat(this._txErrorStat, tx.stat);\n throw e;\n }\n } finally {\n // close underlying grpc stream, if not yet done\n\n // even though we can skip two lines below for read-only transactions,\n // we don't do it to simplify reasoning about what is going on in\n // concurrent code, especially in significant latency situations\n await tx.complete();\n await tx.await();\n\n txId = await tx.getGlobalTxId();\n }\n\n if (ok) {\n // syncing on transaction if requested\n if (ops?.sync === undefined ? this.forceSync : ops?.sync) await this.ll.txSync(txId);\n\n // introducing artificial delay, if requested\n if (writable && this.txDelay > 0)\n await tp.setTimeout(this.txDelay, undefined, { signal: ops?.abortSignal });\n\n return result!;\n }\n } finally {\n release();\n }\n\n // we only get here after TxCommitConflict error,\n // all other errors terminate this loop instantly\n\n await tp.setTimeout(retryState.nextDelay, undefined, { signal: ops?.abortSignal });\n retryState = nextRetryStateOrError(retryState);\n }\n }\n\n private async withTx<T>(\n name: string,\n writable: boolean,\n body: (tx: PlTransaction) => Promise<T>,\n ops: Partial<TxOps> = {},\n ): Promise<T> {\n this.checkInitialized();\n return await this._withTx(name, writable, this.clientRoot, body, { ...ops, ...defaultTxOps });\n }\n\n public async withWriteTx<T>(\n name: string,\n body: (tx: PlTransaction) => Promise<T>,\n ops: Partial<TxOps> = {},\n ): Promise<T> {\n return await this.withTx(name, true, body, { ...ops, ...defaultTxOps });\n }\n\n public async withReadTx<T>(\n name: string,\n body: (tx: PlTransaction) => Promise<T>,\n ops: Partial<TxOps> = {},\n ): Promise<T> {\n return await this.withTx(name, false, body, { ...ops, ...defaultTxOps });\n }\n\n public getDriver<Drv extends PlDriver>(definition: PlDriverDefinition<Drv>): Drv {\n const attached = this.drivers.get(definition.name);\n if (attached !== undefined) return attached as Drv;\n const driver = definition.init(this, this.ll, this.httpDispatcher);\n this.drivers.set(definition.name, driver);\n return driver;\n }\n\n /** Closes underlying transport */\n public async close() {\n await this.ll.close();\n }\n\n public static async init(\n configOrAddress: PlClientConfig | string,\n auth: AuthOps,\n ops: {\n statusListener?: PlConnectionStatusListener;\n logger?: MiLogger;\n } = {},\n ) {\n const pl = new PlClient(configOrAddress, auth, ops);\n await pl.init();\n return pl;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA0CA,MAAM,eAAe,EACnB,MAAM,OACP;AAED,MAAM,sBAAsB;AAE5B,SAAS,yBAAyB,iBAAiC;AACjE,QAAO,oBAAoB;;;AAI7B,IAAa,WAAb,MAAa,SAAS;CACpB,0BAA2B,IAAI,KAAuB;;;CAItD;;CAGA;;CAGA;CAEA;CAIA;CAEA,IAAY,KAAiB;AAC3B,MAAI,KAAK,QAAQ,KAAA,EACf,OAAM,IAAI,MAAM,6BAA6B;AAE/C,SAAO,KAAK;;;CAId,cAA0CA,cAAAA;CAE1C,cAAgE,KAAA;CAEhE,mBAAmCC,aAAAA,eAAe;CAClD,kBAAkCA,aAAAA,eAAe;CACjD,eAA+BA,aAAAA,eAAe;;CAO9C;;CAGA;CAEA,YACE,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AW,WAAW,WAAW,KAAA,GAAW,EAAE,QAAQ,KAAK,aAAa,CAAC;AAClF,iBAAA,GAAA,2BAAA,uBAAmC,WAAW;;;CAIlD,MAAc,OACZ,MACA,UACA,MACA,MAAsB,EAAE,EACZ;AACZ,OAAK,kBAAkB;AACvB,SAAO,MAAM,KAAK,QAAQ,MAAM,UAAU,KAAK,YAAY,MAAM;GAAE,GAAG;GAAK,GAAG;GAAc,CAAC;;CAG/F,MAAa,YACX,MACA,MACA,MAAsB,EAAE,EACZ;AACZ,SAAO,MAAM,KAAK,OAAO,MAAM,MAAM,MAAM;GAAE,GAAG;GAAK,GAAG;GAAc,CAAC;;CAGzE,MAAa,WACX,MACA,MACA,MAAsB,EAAE,EACZ;AACZ,SAAO,MAAM,KAAK,OAAO,MAAM,OAAO,MAAM;GAAE,GAAG;GAAK,GAAG;GAAc,CAAC;;CAG1E,UAAuC,YAA0C;EAC/E,MAAM,WAAW,KAAK,QAAQ,IAAI,WAAW,KAAK;AAClD,MAAI,aAAa,KAAA,EAAW,QAAO;EACnC,MAAM,SAAS,WAAW,KAAK,MAAM,KAAK,IAAI,KAAK,eAAe;AAClE,OAAK,QAAQ,IAAI,WAAW,MAAM,OAAO;AACzC,SAAO;;;CAIT,MAAa,QAAQ;AACnB,QAAM,KAAK,GAAG,OAAO;;CAGvB,aAAoB,KAClB,iBACA,MACA,MAGI,EAAE,EACN;EACA,MAAM,KAAK,IAAI,SAAS,iBAAiB,MAAM,IAAI;AACnD,QAAM,GAAG,MAAM;AACf,SAAO"}
@@ -55,7 +55,9 @@ declare class PlClient {
55
55
  private checkInitialized;
56
56
  get clientRoot(): ResourceId;
57
57
  get serverInfo(): MaintenanceAPI_Ping_Response;
58
- /** Currently implements custom logic to emulate future behaviour with single root. */
58
+ /** Discovers or creates the user's root resource.
59
+ * Tries ListUserResources RPC first (new backend), falls back to
60
+ * legacy named-resource lookup for older backends. */
59
61
  private init;
60
62
  /** Returns true if field existed */
61
63
  deleteAlternativeRoot(al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