@milaboratories/pl-client 3.11.5 → 3.12.1

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 (206) hide show
  1. package/dist/core/PromiseTracker.cjs.map +1 -1
  2. package/dist/core/PromiseTracker.d.ts.map +1 -1
  3. package/dist/core/PromiseTracker.js.map +1 -1
  4. package/dist/core/StatefulPromise.cjs +2 -0
  5. package/dist/core/StatefulPromise.cjs.map +1 -1
  6. package/dist/core/StatefulPromise.js +2 -0
  7. package/dist/core/StatefulPromise.js.map +1 -1
  8. package/dist/core/abstract_stream.d.ts +1 -1
  9. package/dist/core/advisory_locks.cjs.map +1 -1
  10. package/dist/core/advisory_locks.js.map +1 -1
  11. package/dist/core/auth.cjs.map +1 -1
  12. package/dist/core/auth.d.ts.map +1 -1
  13. package/dist/core/auth.js.map +1 -1
  14. package/dist/core/cache.d.ts.map +1 -1
  15. package/dist/core/capabilities.cjs.map +1 -1
  16. package/dist/core/capabilities.d.ts +2 -3
  17. package/dist/core/capabilities.d.ts.map +1 -1
  18. package/dist/core/capabilities.js.map +1 -1
  19. package/dist/core/client.cjs +23 -6
  20. package/dist/core/client.cjs.map +1 -1
  21. package/dist/core/client.d.ts +14 -4
  22. package/dist/core/client.d.ts.map +1 -1
  23. package/dist/core/client.js +22 -5
  24. package/dist/core/client.js.map +1 -1
  25. package/dist/core/config.cjs.map +1 -1
  26. package/dist/core/config.d.ts.map +1 -1
  27. package/dist/core/config.js.map +1 -1
  28. package/dist/core/default_client.cjs +5 -5
  29. package/dist/core/default_client.cjs.map +1 -1
  30. package/dist/core/default_client.d.ts.map +1 -1
  31. package/dist/core/default_client.js.map +1 -1
  32. package/dist/core/driver.cjs.map +1 -1
  33. package/dist/core/driver.d.ts.map +1 -1
  34. package/dist/core/driver.js.map +1 -1
  35. package/dist/core/error_resource.cjs.map +1 -1
  36. package/dist/core/error_resource.js.map +1 -1
  37. package/dist/core/errors.cjs +11 -11
  38. package/dist/core/errors.cjs.map +1 -1
  39. package/dist/core/errors.d.ts.map +1 -1
  40. package/dist/core/errors.js +11 -10
  41. package/dist/core/errors.js.map +1 -1
  42. package/dist/core/final.cjs +6 -2
  43. package/dist/core/final.cjs.map +1 -1
  44. package/dist/core/final.d.ts.map +1 -1
  45. package/dist/core/final.js +4 -1
  46. package/dist/core/final.js.map +1 -1
  47. package/dist/core/ll_client.cjs +60 -16
  48. package/dist/core/ll_client.cjs.map +1 -1
  49. package/dist/core/ll_client.d.ts +23 -7
  50. package/dist/core/ll_client.d.ts.map +1 -1
  51. package/dist/core/ll_client.js +62 -17
  52. package/dist/core/ll_client.js.map +1 -1
  53. package/dist/core/ll_transaction.cjs +3 -1
  54. package/dist/core/ll_transaction.cjs.map +1 -1
  55. package/dist/core/ll_transaction.d.ts +1 -1
  56. package/dist/core/ll_transaction.d.ts.map +1 -1
  57. package/dist/core/ll_transaction.js +2 -1
  58. package/dist/core/ll_transaction.js.map +1 -1
  59. package/dist/core/stat.cjs.map +1 -1
  60. package/dist/core/stat.js.map +1 -1
  61. package/dist/core/transaction.cjs +91 -4
  62. package/dist/core/transaction.cjs.map +1 -1
  63. package/dist/core/transaction.d.ts +52 -2
  64. package/dist/core/transaction.d.ts.map +1 -1
  65. package/dist/core/transaction.js +90 -5
  66. package/dist/core/transaction.js.map +1 -1
  67. package/dist/core/tree_filter.cjs +73 -18
  68. package/dist/core/tree_filter.cjs.map +1 -1
  69. package/dist/core/tree_filter.d.ts +1 -1
  70. package/dist/core/tree_filter.d.ts.map +1 -1
  71. package/dist/core/tree_filter.js +72 -19
  72. package/dist/core/tree_filter.js.map +1 -1
  73. package/dist/core/type_conversion.cjs +19 -20
  74. package/dist/core/type_conversion.cjs.map +1 -1
  75. package/dist/core/type_conversion.js +19 -19
  76. package/dist/core/type_conversion.js.map +1 -1
  77. package/dist/core/types.cjs +2 -3
  78. package/dist/core/types.cjs.map +1 -1
  79. package/dist/core/types.d.ts.map +1 -1
  80. package/dist/core/types.js +2 -2
  81. package/dist/core/types.js.map +1 -1
  82. package/dist/core/unauth_client.cjs +7 -6
  83. package/dist/core/unauth_client.cjs.map +1 -1
  84. package/dist/core/unauth_client.d.ts +9 -0
  85. package/dist/core/unauth_client.d.ts.map +1 -1
  86. package/dist/core/unauth_client.js +7 -5
  87. package/dist/core/unauth_client.js.map +1 -1
  88. package/dist/core/user_resources.cjs +57 -1
  89. package/dist/core/user_resources.cjs.map +1 -1
  90. package/dist/core/user_resources.d.ts +55 -1
  91. package/dist/core/user_resources.d.ts.map +1 -1
  92. package/dist/core/user_resources.js +57 -0
  93. package/dist/core/user_resources.js.map +1 -1
  94. package/dist/core/websocket_stream.cjs +17 -20
  95. package/dist/core/websocket_stream.cjs.map +1 -1
  96. package/dist/core/websocket_stream.js +16 -19
  97. package/dist/core/websocket_stream.js.map +1 -1
  98. package/dist/core/wire.d.ts.map +1 -1
  99. package/dist/helpers/pl.cjs +25 -0
  100. package/dist/helpers/pl.cjs.map +1 -1
  101. package/dist/helpers/pl.d.ts +1 -1
  102. package/dist/helpers/pl.d.ts.map +1 -1
  103. package/dist/helpers/pl.js +1 -1
  104. package/dist/helpers/pl.js.map +1 -1
  105. package/dist/helpers/poll.cjs +5 -1
  106. package/dist/helpers/poll.cjs.map +1 -1
  107. package/dist/helpers/poll.d.ts.map +1 -1
  108. package/dist/helpers/poll.js +4 -0
  109. package/dist/helpers/poll.js.map +1 -1
  110. package/dist/helpers/retry_strategy.cjs +1 -0
  111. package/dist/helpers/retry_strategy.cjs.map +1 -1
  112. package/dist/helpers/retry_strategy.js +1 -1
  113. package/dist/helpers/retry_strategy.js.map +1 -1
  114. package/dist/helpers/tx_helpers.cjs +0 -1
  115. package/dist/helpers/tx_helpers.cjs.map +1 -1
  116. package/dist/helpers/tx_helpers.d.ts.map +1 -1
  117. package/dist/helpers/tx_helpers.js.map +1 -1
  118. package/dist/index.cjs +3 -1
  119. package/dist/index.d.ts +3 -3
  120. package/dist/index.js +2 -2
  121. package/dist/proto-grpc/github.com/googleapis/googleapis/google/rpc/status.cjs +0 -1
  122. package/dist/proto-grpc/github.com/googleapis/googleapis/google/rpc/status.cjs.map +1 -1
  123. package/dist/proto-grpc/github.com/googleapis/googleapis/google/rpc/status.d.ts.map +1 -1
  124. package/dist/proto-grpc/github.com/googleapis/googleapis/google/rpc/status.js.map +1 -1
  125. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.cjs +537 -83
  126. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.cjs.map +1 -1
  127. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.cjs +11 -4
  128. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.cjs.map +1 -1
  129. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.d.ts +12 -6
  130. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.d.ts.map +1 -1
  131. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.js +11 -3
  132. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.js.map +1 -1
  133. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.d.ts +112 -7
  134. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.d.ts.map +1 -1
  135. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.js +336 -83
  136. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.js.map +1 -1
  137. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.cjs +23 -7
  138. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.cjs.map +1 -1
  139. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.d.ts +10 -3
  140. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.d.ts.map +1 -1
  141. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.js +18 -7
  142. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.js.map +1 -1
  143. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.cjs +1 -2
  144. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.cjs.map +1 -1
  145. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.d.ts.map +1 -1
  146. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.js +1 -1
  147. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.js.map +1 -1
  148. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/resource_types.cjs +2 -2
  149. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/resource_types.cjs.map +1 -1
  150. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/resource_types.d.ts +1 -1
  151. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/resource_types.d.ts.map +1 -1
  152. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/resource_types.js +2 -2
  153. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/resource_types.js.map +1 -1
  154. package/dist/proto-grpc/google/protobuf/any.cjs +1 -2
  155. package/dist/proto-grpc/google/protobuf/any.cjs.map +1 -1
  156. package/dist/proto-grpc/google/protobuf/any.d.ts.map +1 -1
  157. package/dist/proto-grpc/google/protobuf/any.js +1 -1
  158. package/dist/proto-grpc/google/protobuf/any.js.map +1 -1
  159. package/dist/proto-grpc/google/protobuf/duration.cjs +0 -1
  160. package/dist/proto-grpc/google/protobuf/duration.cjs.map +1 -1
  161. package/dist/proto-grpc/google/protobuf/duration.d.ts.map +1 -1
  162. package/dist/proto-grpc/google/protobuf/duration.js.map +1 -1
  163. package/dist/proto-grpc/google/protobuf/timestamp.cjs +0 -1
  164. package/dist/proto-grpc/google/protobuf/timestamp.cjs.map +1 -1
  165. package/dist/proto-grpc/google/protobuf/timestamp.d.ts.map +1 -1
  166. package/dist/proto-grpc/google/protobuf/timestamp.js.map +1 -1
  167. package/dist/proto-grpc/google/rpc/code.d.ts.map +1 -1
  168. package/dist/proto-rest/index.cjs +1 -1
  169. package/dist/proto-rest/index.cjs.map +1 -1
  170. package/dist/proto-rest/index.d.ts +1 -1
  171. package/dist/proto-rest/index.d.ts.map +1 -1
  172. package/dist/proto-rest/index.js.map +1 -1
  173. package/dist/proto-rest/plapi.d.ts +30 -9
  174. package/dist/proto-rest/plapi.d.ts.map +1 -1
  175. package/dist/test/tcp-proxy.cjs +2 -2
  176. package/dist/test/tcp-proxy.cjs.map +1 -1
  177. package/dist/test/tcp-proxy.d.ts +1 -1
  178. package/dist/test/tcp-proxy.js.map +1 -1
  179. package/dist/test/test_config.cjs +8 -2
  180. package/dist/test/test_config.cjs.map +1 -1
  181. package/dist/test/test_config.d.ts +1 -1
  182. package/dist/test/test_config.d.ts.map +1 -1
  183. package/dist/test/test_config.js +1 -1
  184. package/dist/test/test_config.js.map +1 -1
  185. package/dist/util/pl.cjs.map +1 -1
  186. package/dist/util/pl.js.map +1 -1
  187. package/dist/util/util.cjs.map +1 -1
  188. package/dist/util/util.js.map +1 -1
  189. package/package.json +4 -4
  190. package/src/core/capabilities.ts +10 -3
  191. package/src/core/client.ts +30 -3
  192. package/src/core/errors.ts +2 -0
  193. package/src/core/final.ts +4 -0
  194. package/src/core/ll_client.test.ts +15 -2
  195. package/src/core/ll_client.ts +66 -11
  196. package/src/core/transaction.ts +103 -3
  197. package/src/core/unauth_client.ts +17 -2
  198. package/src/core/user_resources.ts +85 -0
  199. package/src/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.ts +16 -3
  200. package/src/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.ts +335 -12
  201. package/src/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.ts +21 -7
  202. package/src/proto-rest/plapi.ts +29 -8
  203. package/dist/proto-grpc/google/rpc/code.cjs +0 -224
  204. package/dist/proto-grpc/google/rpc/code.cjs.map +0 -1
  205. package/dist/proto-grpc/google/rpc/code.js +0 -224
  206. package/dist/proto-grpc/google/rpc/code.js.map +0 -1
@@ -1,11 +1,10 @@
1
- import { Code } from "../proto-grpc/google/rpc/code.js";
2
1
  import { Aborted } from "@milaboratories/ts-helpers";
3
2
  //#region src/core/errors.ts
4
3
  function isConnectionProblem(err, nested = false) {
5
4
  if (err === void 0 || err === null) return false;
6
5
  if (err instanceof DisconnectedError) return true;
7
6
  if (err.name == "RpcError" && err.code == "UNAVAILABLE") return true;
8
- if (err.name == "RESTError" && err.status.code == Code.UNAVAILABLE) return true;
7
+ if (err.name == "RESTError" && err.status.code == 14) return true;
9
8
  if (err.cause !== void 0 && !nested) return isConnectionProblem(err.cause, true);
10
9
  return false;
11
10
  }
@@ -13,7 +12,8 @@ function isUnauthenticated(err, nested = false) {
13
12
  if (err === void 0 || err === null) return false;
14
13
  if (err instanceof UnauthenticatedError) return true;
15
14
  if (err.name == "RpcError" && err.code == "UNAUTHENTICATED") return true;
16
- if (err.name == "RESTError" && err.status.code == Code.UNAUTHENTICATED) return true;
15
+ if (err.name == "RESTError" && err.status.code == 16) return true;
16
+ if (err instanceof PlError && err.status?.code === 16) return true;
17
17
  if (err.cause !== void 0 && !nested) return isUnauthenticated(err.cause, true);
18
18
  return false;
19
19
  }
@@ -21,7 +21,7 @@ function isPermissionDenied(err, nested = false) {
21
21
  if (err === void 0 || err === null) return false;
22
22
  if (err instanceof PermissionDeniedError) return true;
23
23
  if (err.name == "RpcError" && err.code == "PERMISSION_DENIED") return true;
24
- if (err.name == "RESTError" && err.status.code == Code.PERMISSION_DENIED) return true;
24
+ if (err.name == "RESTError" && err.status.code == 7) return true;
25
25
  if (err.cause !== void 0 && !nested) return isPermissionDenied(err.cause, true);
26
26
  return false;
27
27
  }
@@ -29,14 +29,14 @@ function isTimeoutError(err, nested = false) {
29
29
  if (err === void 0 || err === null) return false;
30
30
  if (err.name == "TimeoutError") return true;
31
31
  if (err.name == "RpcError" && err.code == "DEADLINE_EXCEEDED") return true;
32
- if (err.name == "RESTError" && err.status.code == Code.DEADLINE_EXCEEDED) return true;
32
+ if (err.name == "RESTError" && err.status.code == 4) return true;
33
33
  if (err.cause !== void 0 && !nested) return isTimeoutError(err.cause, true);
34
34
  return false;
35
35
  }
36
36
  function isCancelError(err, nested = false) {
37
37
  if (err === void 0 || err === null) return false;
38
38
  if (err.name == "RpcError" && err.code == "CANCELLED") return true;
39
- if (err.name == "RESTError" && err.status.code == Code.CANCELLED) return true;
39
+ if (err.name == "RESTError" && err.status.code == 1) return true;
40
40
  if (err.cause !== void 0 && !nested) return isCancelError(err.cause, true);
41
41
  return false;
42
42
  }
@@ -46,7 +46,7 @@ function isAbortedError(err, nested = false) {
46
46
  if (err.code == "ABORT_ERR") return true;
47
47
  if (err instanceof DOMException && err.code === DOMException.ABORT_ERR) return true;
48
48
  if (err.name == "RpcError" && err.code == "ABORTED") return true;
49
- if (err.name == "RESTError" && err.status.code == Code.ABORTED) return true;
49
+ if (err.name == "RESTError" && err.status.code == 10) return true;
50
50
  if (err.cause !== void 0 && !nested) return isAbortedError(err.cause, true);
51
51
  return false;
52
52
  }
@@ -61,19 +61,20 @@ function isTimeoutOrCancelError(err, nested = false) {
61
61
  function isUnimplementedError(err, nested = false) {
62
62
  if (err === void 0 || err === null) return false;
63
63
  if (err.name == "RpcError" && err.code == "UNIMPLEMENTED") return true;
64
- if (err.name == "RESTError" && err.status.code == Code.UNIMPLEMENTED) return true;
64
+ if (err.name == "RESTError" && err.status.code == 12) return true;
65
65
  if (err.cause !== void 0 && !nested) return isUnimplementedError(err.cause, true);
66
66
  return false;
67
67
  }
68
68
  function isNotFoundError(err, nested = false) {
69
69
  if (err === void 0 || err === null) return false;
70
70
  if (err.name == "RpcError" && err.code == "NOT_FOUND") return true;
71
- if (err.name == "RESTError" && err.status.code == Code.NOT_FOUND) return true;
71
+ if (err.name == "RESTError" && err.status.code == 5) return true;
72
72
  if (err.cause !== void 0 && !nested) return isNotFoundError(err.cause, true);
73
73
  return err instanceof RecoverablePlError && err.status.code === PlErrorCodeNotFound;
74
74
  }
75
- const PlErrorCodeNotFound = Code.NOT_FOUND;
75
+ const PlErrorCodeNotFound = 5;
76
76
  var PlError = class extends Error {
77
+ status;
77
78
  name = "PlError";
78
79
  constructor(status, opts) {
79
80
  super(`code=${status.code} ${status.message}`, opts);
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","names":[],"sources":["../../src/core/errors.ts"],"sourcesContent":["import type { Status } from \"../proto-grpc/github.com/googleapis/googleapis/google/rpc/status\";\nimport { Aborted } from \"@milaboratories/ts-helpers\";\nimport { Code } from \"../proto-grpc/google/rpc/code\";\n\nexport function isConnectionProblem(err: unknown, nested: boolean = false): boolean {\n if (err === undefined || err === null) return false;\n\n if (err instanceof DisconnectedError) return true;\n if ((err as any).name == \"RpcError\" && (err as any).code == \"UNAVAILABLE\") return true;\n if ((err as any).name == \"RESTError\" && (err as any).status.code == Code.UNAVAILABLE) return true;\n if ((err as any).cause !== undefined && !nested)\n return isConnectionProblem((err as any).cause, true);\n return false;\n}\n\nexport function isUnauthenticated(err: unknown, nested: boolean = false): boolean {\n if (err === undefined || err === null) return false;\n\n if (err instanceof UnauthenticatedError) return true;\n if ((err as any).name == \"RpcError\" && (err as any).code == \"UNAUTHENTICATED\") return true;\n if ((err as any).name == \"RESTError\" && (err as any).status.code == Code.UNAUTHENTICATED)\n return true;\n if ((err as any).cause !== undefined && !nested)\n return isUnauthenticated((err as any).cause, true);\n return false;\n}\n\nexport function isPermissionDenied(err: unknown, nested: boolean = false): boolean {\n if (err === undefined || err === null) return false;\n\n if (err instanceof PermissionDeniedError) return true;\n if ((err as any).name == \"RpcError\" && (err as any).code == \"PERMISSION_DENIED\") return true;\n if ((err as any).name == \"RESTError\" && (err as any).status.code == Code.PERMISSION_DENIED)\n return true;\n if ((err as any).cause !== undefined && !nested)\n return isPermissionDenied((err as any).cause, true);\n return false;\n}\n\nexport function isTimeoutError(err: unknown, nested: boolean = false): boolean {\n if (err === undefined || err === null) return false;\n\n if ((err as any).name == \"TimeoutError\") return true;\n if ((err as any).name == \"RpcError\" && (err as any).code == \"DEADLINE_EXCEEDED\") return true;\n if ((err as any).name == \"RESTError\" && (err as any).status.code == Code.DEADLINE_EXCEEDED)\n return true;\n if ((err as any).cause !== undefined && !nested) return isTimeoutError((err as any).cause, true);\n return false;\n}\n\nexport function isCancelError(err: unknown, nested: boolean = false): boolean {\n if (err === undefined || err === null) return false;\n\n if ((err as any).name == \"RpcError\" && (err as any).code == \"CANCELLED\") return true;\n if ((err as any).name == \"RESTError\" && (err as any).status.code == Code.CANCELLED) return true;\n if ((err as any).cause !== undefined && !nested) return isCancelError((err as any).cause, true);\n return false;\n}\n\nexport function isAbortedError(err: unknown, nested: boolean = false): boolean {\n if (err === undefined || err === null) return false;\n\n if (err instanceof Aborted || (err as any).name == \"AbortError\") return true;\n if ((err as any).code == \"ABORT_ERR\") return true;\n if (err instanceof DOMException && err.code === DOMException.ABORT_ERR) return true; // WebSocket error\n if ((err as any).name == \"RpcError\" && (err as any).code == \"ABORTED\") return true;\n if ((err as any).name == \"RESTError\" && (err as any).status.code == Code.ABORTED) return true;\n if ((err as any).cause !== undefined && !nested) return isAbortedError((err as any).cause, true);\n return false;\n}\n\nexport function isTimeoutOrCancelError(err: unknown, nested: boolean = false): boolean {\n if (err === undefined || err === null) return false;\n\n if (isAbortedError(err, true)) return true;\n if (isTimeoutError(err, true)) return true;\n if (isCancelError(err, true)) return true;\n if ((err as any).cause !== undefined && !nested)\n return isTimeoutOrCancelError((err as any).cause, true);\n return false;\n}\n\nexport function isUnimplementedError(err: unknown, nested: boolean = false): boolean {\n if (err === undefined || err === null) return false;\n\n if ((err as any).name == \"RpcError\" && (err as any).code == \"UNIMPLEMENTED\") return true;\n if ((err as any).name == \"RESTError\" && (err as any).status.code == Code.UNIMPLEMENTED)\n return true;\n if ((err as any).cause !== undefined && !nested)\n return isUnimplementedError((err as any).cause, true);\n return false;\n}\n\nexport function isNotFoundError(err: unknown, nested: boolean = false): boolean {\n if (err === undefined || err === null) return false;\n\n if ((err as any).name == \"RpcError\" && (err as any).code == \"NOT_FOUND\") return true;\n if ((err as any).name == \"RESTError\" && (err as any).status.code == Code.NOT_FOUND) return true;\n if ((err as any).cause !== undefined && !nested) return isNotFoundError((err as any).cause, true);\n return err instanceof RecoverablePlError && err.status.code === PlErrorCodeNotFound;\n}\n\nexport const PlErrorCodeNotFound: number = Code.NOT_FOUND;\n\nexport class PlError extends Error {\n name = \"PlError\";\n constructor(\n public readonly status: Status,\n opts?: ErrorOptions,\n ) {\n super(`code=${status.code} ${status.message}`, opts);\n }\n}\n\nexport function throwPlNotFoundError(message: string): never {\n throw new RecoverablePlError({ code: PlErrorCodeNotFound, message, details: [] });\n}\n\nexport class RecoverablePlError extends PlError {\n name = \"RecoverablePlError\";\n constructor(status: Status) {\n super(status);\n }\n}\n\nexport class UnrecoverablePlError extends PlError {\n name = \"UnrecoverablePlError\";\n constructor(status: Status) {\n super(status);\n }\n}\n\nexport class UnauthenticatedError extends Error {\n name = \"UnauthenticatedError\";\n constructor(message: string) {\n super(\"LoginFailed: \" + message);\n }\n}\n\nexport class PermissionDeniedError extends Error {\n name = \"PermissionDeniedError\";\n constructor(message: string) {\n super(\"PermissionDenied: \" + message);\n }\n}\n\nexport class DisconnectedError extends Error {\n name = \"DisconnectedError\";\n constructor(message: string) {\n super(\"Disconnected: \" + message);\n }\n}\n\nexport class RESTError extends PlError {\n name = \"RESTError\";\n constructor(status: Status, opts?: ErrorOptions) {\n super(status, opts);\n }\n}\n\nexport function rethrowMeaningfulError(error: any, wrapIfUnknown: boolean = false): never {\n if (isUnauthenticated(error)) {\n if (error instanceof UnauthenticatedError) throw error;\n throw new UnauthenticatedError(error.message);\n }\n if (isPermissionDenied(error)) {\n if (error instanceof PermissionDeniedError) throw error;\n throw new PermissionDeniedError(error.message);\n }\n if (isConnectionProblem(error)) {\n if (error instanceof DisconnectedError) throw error;\n throw new DisconnectedError(error.message);\n }\n if (isTimeoutOrCancelError(error)) throw new Aborted(error);\n if (wrapIfUnknown) {\n const message = error.message || String(error) || \"Unknown error\";\n throw new Error(message, { cause: error });\n } else throw error;\n}\n"],"mappings":";;;AAIA,SAAgB,oBAAoB,KAAc,SAAkB,OAAgB;AAClF,KAAI,QAAQ,KAAA,KAAa,QAAQ,KAAM,QAAO;AAE9C,KAAI,eAAe,kBAAmB,QAAO;AAC7C,KAAK,IAAY,QAAQ,cAAe,IAAY,QAAQ,cAAe,QAAO;AAClF,KAAK,IAAY,QAAQ,eAAgB,IAAY,OAAO,QAAQ,KAAK,YAAa,QAAO;AAC7F,KAAK,IAAY,UAAU,KAAA,KAAa,CAAC,OACvC,QAAO,oBAAqB,IAAY,OAAO,KAAK;AACtD,QAAO;;AAGT,SAAgB,kBAAkB,KAAc,SAAkB,OAAgB;AAChF,KAAI,QAAQ,KAAA,KAAa,QAAQ,KAAM,QAAO;AAE9C,KAAI,eAAe,qBAAsB,QAAO;AAChD,KAAK,IAAY,QAAQ,cAAe,IAAY,QAAQ,kBAAmB,QAAO;AACtF,KAAK,IAAY,QAAQ,eAAgB,IAAY,OAAO,QAAQ,KAAK,gBACvE,QAAO;AACT,KAAK,IAAY,UAAU,KAAA,KAAa,CAAC,OACvC,QAAO,kBAAmB,IAAY,OAAO,KAAK;AACpD,QAAO;;AAGT,SAAgB,mBAAmB,KAAc,SAAkB,OAAgB;AACjF,KAAI,QAAQ,KAAA,KAAa,QAAQ,KAAM,QAAO;AAE9C,KAAI,eAAe,sBAAuB,QAAO;AACjD,KAAK,IAAY,QAAQ,cAAe,IAAY,QAAQ,oBAAqB,QAAO;AACxF,KAAK,IAAY,QAAQ,eAAgB,IAAY,OAAO,QAAQ,KAAK,kBACvE,QAAO;AACT,KAAK,IAAY,UAAU,KAAA,KAAa,CAAC,OACvC,QAAO,mBAAoB,IAAY,OAA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AAgB;AAC1B,QAAM,OAAO;;;AAIjB,IAAa,uBAAb,cAA0C,QAAQ;CAChD,OAAO;CACP,YAAY,QAAgB;AAC1B,QAAM,OAAO;;;AAIjB,IAAa,uBAAb,cAA0C,MAAM;CAC9C,OAAO;CACP,YAAY,SAAiB;AAC3B,QAAM,kBAAkB,QAAQ;;;AAIpC,IAAa,wBAAb,cAA2C,MAAM;CAC/C,OAAO;CACP,YAAY,SAAiB;AAC3B,QAAM,uBAAuB,QAAQ;;;AAIzC,IAAa,oBAAb,cAAuC,MAAM;CAC3C,OAAO;CACP,YAAY,SAAiB;AAC3B,QAAM,mBAAmB,QAAQ;;;AAIrC,IAAa,YAAb,cAA+B,QAAQ;CACrC,OAAO;CACP,YAAY,QAAgB,MAAqB;AAC/C,QAAM,QAAQ,KAAK;;;AAIvB,SAAgB,uBAAuB,OAAY,gBAAyB,OAAc;AACxF,KAAI,kBAAkB,MAAM,EAAE;AAC5B,MAAI,iBAAiB,qBAAsB,OAAM;AACjD,QAAM,IAAI,qBAAqB,MAAM,QAAQ;;AAE/C,KAAI,mBAAmB,MAAM,EAAE;AAC7B,MAAI,iBAAiB,sBAAuB,OAAM;AAClD,QAAM,IAAI,sBAAsB,MAAM,QAAQ;;AAEhD,KAAI,oBAAoB,MAAM,EAAE;AAC9B,MAAI,iBAAiB,kBAAmB,OAAM;AAC9C,QAAM,IAAI,kBAAkB,MAAM,QAAQ;;AAE5C,KAAI,uBAAuB,MAAM,CAAE,OAAM,IAAI,QAAQ,MAAM;AAC3D,KAAI,eAAe;EACjB,MAAM,UAAU,MAAM,WAAW,OAAO,MAAM,IAAI;AAClD,QAAM,IAAI,MAAM,SAAS,EAAE,OAAO,OAAO,CAAC;OACrC,OAAM"}
1
+ {"version":3,"file":"errors.js","names":[],"sources":["../../src/core/errors.ts"],"sourcesContent":["import type { Status } from \"../proto-grpc/github.com/googleapis/googleapis/google/rpc/status\";\nimport { Aborted } from \"@milaboratories/ts-helpers\";\nimport { Code } from \"../proto-grpc/google/rpc/code\";\n\nexport function isConnectionProblem(err: unknown, nested: boolean = false): boolean {\n if (err === undefined || err === null) return false;\n\n if (err instanceof DisconnectedError) return true;\n if ((err as any).name == \"RpcError\" && (err as any).code == \"UNAVAILABLE\") return true;\n if ((err as any).name == \"RESTError\" && (err as any).status.code == Code.UNAVAILABLE) return true;\n if ((err as any).cause !== undefined && !nested)\n return isConnectionProblem((err as any).cause, true);\n return false;\n}\n\nexport function isUnauthenticated(err: unknown, nested: boolean = false): boolean {\n if (err === undefined || err === null) return false;\n\n if (err instanceof UnauthenticatedError) return true;\n if ((err as any).name == \"RpcError\" && (err as any).code == \"UNAUTHENTICATED\") return true;\n if ((err as any).name == \"RESTError\" && (err as any).status.code == Code.UNAUTHENTICATED)\n return true;\n // PlError (e.g. UnrecoverablePlError from a failed streaming tx) carries the status code numerically.\n if (err instanceof PlError && err.status?.code === Code.UNAUTHENTICATED) return true;\n if ((err as any).cause !== undefined && !nested)\n return isUnauthenticated((err as any).cause, true);\n return false;\n}\n\nexport function isPermissionDenied(err: unknown, nested: boolean = false): boolean {\n if (err === undefined || err === null) return false;\n\n if (err instanceof PermissionDeniedError) return true;\n if ((err as any).name == \"RpcError\" && (err as any).code == \"PERMISSION_DENIED\") return true;\n if ((err as any).name == \"RESTError\" && (err as any).status.code == Code.PERMISSION_DENIED)\n return true;\n if ((err as any).cause !== undefined && !nested)\n return isPermissionDenied((err as any).cause, true);\n return false;\n}\n\nexport function isTimeoutError(err: unknown, nested: boolean = false): boolean {\n if (err === undefined || err === null) return false;\n\n if ((err as any).name == \"TimeoutError\") return true;\n if ((err as any).name == \"RpcError\" && (err as any).code == \"DEADLINE_EXCEEDED\") return true;\n if ((err as any).name == \"RESTError\" && (err as any).status.code == Code.DEADLINE_EXCEEDED)\n return true;\n if ((err as any).cause !== undefined && !nested) return isTimeoutError((err as any).cause, true);\n return false;\n}\n\nexport function isCancelError(err: unknown, nested: boolean = false): boolean {\n if (err === undefined || err === null) return false;\n\n if ((err as any).name == \"RpcError\" && (err as any).code == \"CANCELLED\") return true;\n if ((err as any).name == \"RESTError\" && (err as any).status.code == Code.CANCELLED) return true;\n if ((err as any).cause !== undefined && !nested) return isCancelError((err as any).cause, true);\n return false;\n}\n\nexport function isAbortedError(err: unknown, nested: boolean = false): boolean {\n if (err === undefined || err === null) return false;\n\n if (err instanceof Aborted || (err as any).name == \"AbortError\") return true;\n if ((err as any).code == \"ABORT_ERR\") return true;\n if (err instanceof DOMException && err.code === DOMException.ABORT_ERR) return true; // WebSocket error\n if ((err as any).name == \"RpcError\" && (err as any).code == \"ABORTED\") return true;\n if ((err as any).name == \"RESTError\" && (err as any).status.code == Code.ABORTED) return true;\n if ((err as any).cause !== undefined && !nested) return isAbortedError((err as any).cause, true);\n return false;\n}\n\nexport function isTimeoutOrCancelError(err: unknown, nested: boolean = false): boolean {\n if (err === undefined || err === null) return false;\n\n if (isAbortedError(err, true)) return true;\n if (isTimeoutError(err, true)) return true;\n if (isCancelError(err, true)) return true;\n if ((err as any).cause !== undefined && !nested)\n return isTimeoutOrCancelError((err as any).cause, true);\n return false;\n}\n\nexport function isUnimplementedError(err: unknown, nested: boolean = false): boolean {\n if (err === undefined || err === null) return false;\n\n if ((err as any).name == \"RpcError\" && (err as any).code == \"UNIMPLEMENTED\") return true;\n if ((err as any).name == \"RESTError\" && (err as any).status.code == Code.UNIMPLEMENTED)\n return true;\n if ((err as any).cause !== undefined && !nested)\n return isUnimplementedError((err as any).cause, true);\n return false;\n}\n\nexport function isNotFoundError(err: unknown, nested: boolean = false): boolean {\n if (err === undefined || err === null) return false;\n\n if ((err as any).name == \"RpcError\" && (err as any).code == \"NOT_FOUND\") return true;\n if ((err as any).name == \"RESTError\" && (err as any).status.code == Code.NOT_FOUND) return true;\n if ((err as any).cause !== undefined && !nested) return isNotFoundError((err as any).cause, true);\n return err instanceof RecoverablePlError && err.status.code === PlErrorCodeNotFound;\n}\n\nexport const PlErrorCodeNotFound: number = Code.NOT_FOUND;\n\nexport class PlError extends Error {\n name = \"PlError\";\n constructor(\n public readonly status: Status,\n opts?: ErrorOptions,\n ) {\n super(`code=${status.code} ${status.message}`, opts);\n }\n}\n\nexport function throwPlNotFoundError(message: string): never {\n throw new RecoverablePlError({ code: PlErrorCodeNotFound, message, details: [] });\n}\n\nexport class RecoverablePlError extends PlError {\n name = \"RecoverablePlError\";\n constructor(status: Status) {\n super(status);\n }\n}\n\nexport class UnrecoverablePlError extends PlError {\n name = \"UnrecoverablePlError\";\n constructor(status: Status) {\n super(status);\n }\n}\n\nexport class UnauthenticatedError extends Error {\n name = \"UnauthenticatedError\";\n constructor(message: string) {\n super(\"LoginFailed: \" + message);\n }\n}\n\nexport class PermissionDeniedError extends Error {\n name = \"PermissionDeniedError\";\n constructor(message: string) {\n super(\"PermissionDenied: \" + message);\n }\n}\n\nexport class DisconnectedError extends Error {\n name = \"DisconnectedError\";\n constructor(message: string) {\n super(\"Disconnected: \" + message);\n }\n}\n\nexport class RESTError extends PlError {\n name = \"RESTError\";\n constructor(status: Status, opts?: ErrorOptions) {\n super(status, opts);\n }\n}\n\nexport function rethrowMeaningfulError(error: any, wrapIfUnknown: boolean = false): never {\n if (isUnauthenticated(error)) {\n if (error instanceof UnauthenticatedError) throw error;\n throw new UnauthenticatedError(error.message);\n }\n if (isPermissionDenied(error)) {\n if (error instanceof PermissionDeniedError) throw error;\n throw new PermissionDeniedError(error.message);\n }\n if (isConnectionProblem(error)) {\n if (error instanceof DisconnectedError) throw error;\n throw new DisconnectedError(error.message);\n }\n if (isTimeoutOrCancelError(error)) throw new Aborted(error);\n if (wrapIfUnknown) {\n const message = error.message || String(error) || \"Unknown error\";\n throw new Error(message, { cause: error });\n } else throw error;\n}\n"],"mappings":";;AAIA,SAAgB,oBAAoB,KAAc,SAAkB,OAAgB;CAClF,IAAI,QAAQ,KAAA,KAAa,QAAQ,MAAM,OAAO;CAE9C,IAAI,eAAe,mBAAmB,OAAO;CAC7C,IAAK,IAAY,QAAQ,cAAe,IAAY,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;CACtC;AACF;AAEA,IAAa,oBAAb,cAAuC,MAAM;CAC3C,OAAO;CACP,YAAY,SAAiB;EAC3B,MAAM,mBAAmB,OAAO;CAClC;AACF;AAEA,IAAa,YAAb,cAA+B,QAAQ;CACrC,OAAO;CACP,YAAY,QAAgB,MAAqB;EAC/C,MAAM,QAAQ,IAAI;CACpB;AACF;AAEA,SAAgB,uBAAuB,OAAY,gBAAyB,OAAc;CACxF,IAAI,kBAAkB,KAAK,GAAG;EAC5B,IAAI,iBAAiB,sBAAsB,MAAM;EACjD,MAAM,IAAI,qBAAqB,MAAM,OAAO;CAC9C;CACA,IAAI,mBAAmB,KAAK,GAAG;EAC7B,IAAI,iBAAiB,uBAAuB,MAAM;EAClD,MAAM,IAAI,sBAAsB,MAAM,OAAO;CAC/C;CACA,IAAI,oBAAoB,KAAK,GAAG;EAC9B,IAAI,iBAAiB,mBAAmB,MAAM;EAC9C,MAAM,IAAI,kBAAkB,MAAM,OAAO;CAC3C;CACA,IAAI,uBAAuB,KAAK,GAAG,MAAM,IAAI,QAAQ,KAAK;CAC1D,IAAI,eAAe;EACjB,MAAM,UAAU,MAAM,WAAW,OAAO,KAAK,KAAK;EAClD,MAAM,IAAI,MAAM,SAAS,EAAE,OAAO,MAAM,CAAC;CAC3C,OAAO,MAAM;AACf"}
@@ -1,4 +1,3 @@
1
- require("../_virtual/_rolldown/runtime.cjs");
2
1
  const require_types = require("./types.cjs");
3
2
  let _milaboratories_pl_model_common = require("@milaboratories/pl-model-common");
4
3
  //#region src/core/final.ts
@@ -57,7 +56,10 @@ const DefaultFinalResourceDataPredicate = (r) => {
57
56
  case _milaboratories_pl_model_common.ResourceTypeName.WorkingDirectory: return true;
58
57
  case _milaboratories_pl_model_common.ResourceTypeName.UserProject:
59
58
  case _milaboratories_pl_model_common.ResourceTypeName.Projects:
60
- case _milaboratories_pl_model_common.ResourceTypeName.ClientRoot: return false;
59
+ case _milaboratories_pl_model_common.ResourceTypeName.ClientRoot:
60
+ case _milaboratories_pl_model_common.ResourceTypeName.SharingOutbox:
61
+ case _milaboratories_pl_model_common.ResourceTypeName.SharingState:
62
+ case _milaboratories_pl_model_common.ResourceTypeName.SharedEnvelope: return false;
61
63
  default: if (r.type.name.startsWith(_milaboratories_pl_model_common.ResourceTypePrefix.Blob) || r.type.name.startsWith(_milaboratories_pl_model_common.ResourceTypePrefix.LS) || r.type.name.startsWith(_milaboratories_pl_model_common.ResourceTypePrefix.WorkingDirectory) || r.type.name.startsWith(_milaboratories_pl_model_common.ResourceTypePrefix.StorageSpaceAllocation)) return true;
62
64
  else if (r.type.name.startsWith(_milaboratories_pl_model_common.ResourceTypePrefix.BlobUpload) || r.type.name.startsWith(_milaboratories_pl_model_common.ResourceTypePrefix.BlobIndex)) return readyAndHasAllOutputsFilled(r);
63
65
  else if (r.type.name.startsWith(_milaboratories_pl_model_common.ResourceTypePrefix.PColumnData)) return readyOrDuplicateOrError(r);
@@ -71,5 +73,7 @@ const DefaultFinalResourceDataPredicate = (r) => {
71
73
  };
72
74
  //#endregion
73
75
  exports.DefaultFinalResourceDataPredicate = DefaultFinalResourceDataPredicate;
76
+ exports.ResourceTypeName = _milaboratories_pl_model_common.ResourceTypeName;
77
+ exports.ResourceTypePrefix = _milaboratories_pl_model_common.ResourceTypePrefix;
74
78
 
75
79
  //# sourceMappingURL=final.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"final.cjs","names":["isNotNullSignedResourceId","isNullSignedResourceId","ResourceTypeName","getField","ResourceTypePrefix"],"sources":["../../src/core/final.ts"],"sourcesContent":["import type { Optional } from \"utility-types\";\nimport type { BasicResourceData, ResourceData } from \"./types\";\nimport { getField, isNotNullSignedResourceId, isNullSignedResourceId } from \"./types\";\nimport { ResourceTypeName, ResourceTypePrefix } from \"@milaboratories/pl-model-common\";\nexport { ResourceTypeName, ResourceTypePrefix };\n\n/**\n * Function is used to guide multiple layers of caching in pl-client and derived pl-tree.\n *\n * This function defines expected resource-specific state mutation behaviour,\n * if it returns true, system will expect that this data will never change as long as resource exist.\n *\n * If resource data contain information about fields, if should be taken into account, fields are undefined,\n * \"final\" state should be calculated for \"basic\" part of resource data only.\n */\nexport type FinalResourceDataPredicate = (\n resourceData: Optional<ResourceData, \"fields\">,\n) => boolean;\n\nfunction readyOrDuplicateOrError(r: ResourceData | BasicResourceData): boolean {\n return (\n r.resourceReady ||\n isNotNullSignedResourceId(r.originalResourceId) ||\n isNotNullSignedResourceId(r.error)\n );\n}\n\nfunction readyAndHasAllOutputsFilled(r: Optional<ResourceData, \"fields\">): boolean {\n if (!readyOrDuplicateOrError(r)) return false;\n if (!r.outputsLocked) return false;\n if (r.fields === undefined) return true; // if fields are not provided basic resource state is not expected to change in the future\n for (const f of r.fields)\n if (isNullSignedResourceId(f.error) && (isNullSignedResourceId(f.value) || !f.valueIsFinal))\n return false;\n return true;\n}\n\n// solely for logging\nconst unknownResourceTypeNames = new Set<string>();\n\n/** Default implementation, defining behaviour for built-in resource types. */\nexport const DefaultFinalResourceDataPredicate: FinalResourceDataPredicate = (r): boolean => {\n switch (r.type.name) {\n case ResourceTypeName.StreamManager: {\n if (!readyOrDuplicateOrError(r)) return false;\n if (r.fields === undefined) return true; // if fields are not provided basic resource state is not expected to change in the future\n if (isNotNullSignedResourceId(r.error)) return true;\n const downloadable = getField(r as ResourceData, \"downloadable\");\n const stream = getField(r as ResourceData, \"stream\");\n return stream.value === downloadable.value; // it's equal to the resource is marked as final on backend side\n }\n case ResourceTypeName.StdMap:\n case ResourceTypeName.StdMapSlash:\n case ResourceTypeName.EphStdMap:\n case ResourceTypeName.PFrame:\n case ResourceTypeName.ParquetChunk:\n case ResourceTypeName.BContext:\n case ResourceTypeName.BlockPackCustom:\n case ResourceTypeName.BinaryMap:\n case ResourceTypeName.BinaryValue:\n case ResourceTypeName.BlobMap:\n case ResourceTypeName.BResolveSingle:\n case ResourceTypeName.BResolveSingleNoResult:\n case ResourceTypeName.BQueryResult:\n case ResourceTypeName.TengoTemplate:\n case ResourceTypeName.TengoLib:\n case ResourceTypeName.SoftwareInfo:\n case ResourceTypeName.Dummy:\n return readyOrDuplicateOrError(r);\n case ResourceTypeName.JsonResourceError:\n return r.type.version === \"1\";\n case ResourceTypeName.JsonObject:\n case ResourceTypeName.JsonGzObject:\n case ResourceTypeName.JsonString:\n case ResourceTypeName.JsonArray:\n case ResourceTypeName.JsonNumber:\n case ResourceTypeName.BContextEnd:\n case ResourceTypeName.FrontendFromUrl:\n case ResourceTypeName.FrontendFromFolder:\n case ResourceTypeName.BObjectSpec:\n case ResourceTypeName.Blob:\n case ResourceTypeName.Null:\n case ResourceTypeName.Binary:\n case ResourceTypeName.LSProvider:\n case ResourceTypeName.WorkingDirectory:\n return true;\n case ResourceTypeName.UserProject:\n case ResourceTypeName.Projects:\n case ResourceTypeName.ClientRoot:\n return false;\n default:\n if (\n r.type.name.startsWith(ResourceTypePrefix.Blob) ||\n r.type.name.startsWith(ResourceTypePrefix.LS) ||\n r.type.name.startsWith(ResourceTypePrefix.WorkingDirectory) ||\n r.type.name.startsWith(ResourceTypePrefix.StorageSpaceAllocation)\n ) {\n return true;\n } else if (\n r.type.name.startsWith(ResourceTypePrefix.BlobUpload) ||\n r.type.name.startsWith(ResourceTypePrefix.BlobIndex)\n ) {\n return readyAndHasAllOutputsFilled(r);\n } else if (r.type.name.startsWith(ResourceTypePrefix.PColumnData)) {\n return readyOrDuplicateOrError(r);\n } else if (r.type.name.startsWith(ResourceTypePrefix.StreamWorkdir)) {\n return readyOrDuplicateOrError(r);\n } else {\n // Unknown resource type detected\n // Set used to log this message only once\n if (!unknownResourceTypeNames.has(r.type.name)) {\n console.log(\"UNKNOWN RESOURCE TYPE: \" + r.type.name);\n unknownResourceTypeNames.add(r.type.name);\n }\n }\n }\n return false;\n};\n"],"mappings":";;;;AAmBA,SAAS,wBAAwB,GAA8C;AAC7E,QACE,EAAE,iBACFA,cAAAA,0BAA0B,EAAE,mBAAmB,IAC/CA,cAAAA,0BAA0B,EAAE,MAAM;;AAItC,SAAS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I,EAAE,KAAK,KAAK;;;AAIjD,QAAO"}
1
+ {"version":3,"file":"final.cjs","names":["isNotNullSignedResourceId","isNullSignedResourceId","ResourceTypeName","getField","ResourceTypePrefix"],"sources":["../../src/core/final.ts"],"sourcesContent":["import type { Optional } from \"utility-types\";\nimport type { BasicResourceData, ResourceData } from \"./types\";\nimport { getField, isNotNullSignedResourceId, isNullSignedResourceId } from \"./types\";\nimport { ResourceTypeName, ResourceTypePrefix } from \"@milaboratories/pl-model-common\";\nexport { ResourceTypeName, ResourceTypePrefix };\n\n/**\n * Function is used to guide multiple layers of caching in pl-client and derived pl-tree.\n *\n * This function defines expected resource-specific state mutation behaviour,\n * if it returns true, system will expect that this data will never change as long as resource exist.\n *\n * If resource data contain information about fields, if should be taken into account, fields are undefined,\n * \"final\" state should be calculated for \"basic\" part of resource data only.\n */\nexport type FinalResourceDataPredicate = (\n resourceData: Optional<ResourceData, \"fields\">,\n) => boolean;\n\nfunction readyOrDuplicateOrError(r: ResourceData | BasicResourceData): boolean {\n return (\n r.resourceReady ||\n isNotNullSignedResourceId(r.originalResourceId) ||\n isNotNullSignedResourceId(r.error)\n );\n}\n\nfunction readyAndHasAllOutputsFilled(r: Optional<ResourceData, \"fields\">): boolean {\n if (!readyOrDuplicateOrError(r)) return false;\n if (!r.outputsLocked) return false;\n if (r.fields === undefined) return true; // if fields are not provided basic resource state is not expected to change in the future\n for (const f of r.fields)\n if (isNullSignedResourceId(f.error) && (isNullSignedResourceId(f.value) || !f.valueIsFinal))\n return false;\n return true;\n}\n\n// solely for logging\nconst unknownResourceTypeNames = new Set<string>();\n\n/** Default implementation, defining behaviour for built-in resource types. */\nexport const DefaultFinalResourceDataPredicate: FinalResourceDataPredicate = (r): boolean => {\n switch (r.type.name) {\n case ResourceTypeName.StreamManager: {\n if (!readyOrDuplicateOrError(r)) return false;\n if (r.fields === undefined) return true; // if fields are not provided basic resource state is not expected to change in the future\n if (isNotNullSignedResourceId(r.error)) return true;\n const downloadable = getField(r as ResourceData, \"downloadable\");\n const stream = getField(r as ResourceData, \"stream\");\n return stream.value === downloadable.value; // it's equal to the resource is marked as final on backend side\n }\n case ResourceTypeName.StdMap:\n case ResourceTypeName.StdMapSlash:\n case ResourceTypeName.EphStdMap:\n case ResourceTypeName.PFrame:\n case ResourceTypeName.ParquetChunk:\n case ResourceTypeName.BContext:\n case ResourceTypeName.BlockPackCustom:\n case ResourceTypeName.BinaryMap:\n case ResourceTypeName.BinaryValue:\n case ResourceTypeName.BlobMap:\n case ResourceTypeName.BResolveSingle:\n case ResourceTypeName.BResolveSingleNoResult:\n case ResourceTypeName.BQueryResult:\n case ResourceTypeName.TengoTemplate:\n case ResourceTypeName.TengoLib:\n case ResourceTypeName.SoftwareInfo:\n case ResourceTypeName.Dummy:\n return readyOrDuplicateOrError(r);\n case ResourceTypeName.JsonResourceError:\n return r.type.version === \"1\";\n case ResourceTypeName.JsonObject:\n case ResourceTypeName.JsonGzObject:\n case ResourceTypeName.JsonString:\n case ResourceTypeName.JsonArray:\n case ResourceTypeName.JsonNumber:\n case ResourceTypeName.BContextEnd:\n case ResourceTypeName.FrontendFromUrl:\n case ResourceTypeName.FrontendFromFolder:\n case ResourceTypeName.BObjectSpec:\n case ResourceTypeName.Blob:\n case ResourceTypeName.Null:\n case ResourceTypeName.Binary:\n case ResourceTypeName.LSProvider:\n case ResourceTypeName.WorkingDirectory:\n return true;\n case ResourceTypeName.UserProject:\n case ResourceTypeName.Projects:\n case ResourceTypeName.ClientRoot:\n // Never final — these sharing resources gain and lose dynamic child fields over their lifetime.\n case ResourceTypeName.SharingOutbox:\n case ResourceTypeName.SharingState:\n case ResourceTypeName.SharedEnvelope:\n return false;\n default:\n if (\n r.type.name.startsWith(ResourceTypePrefix.Blob) ||\n r.type.name.startsWith(ResourceTypePrefix.LS) ||\n r.type.name.startsWith(ResourceTypePrefix.WorkingDirectory) ||\n r.type.name.startsWith(ResourceTypePrefix.StorageSpaceAllocation)\n ) {\n return true;\n } else if (\n r.type.name.startsWith(ResourceTypePrefix.BlobUpload) ||\n r.type.name.startsWith(ResourceTypePrefix.BlobIndex)\n ) {\n return readyAndHasAllOutputsFilled(r);\n } else if (r.type.name.startsWith(ResourceTypePrefix.PColumnData)) {\n return readyOrDuplicateOrError(r);\n } else if (r.type.name.startsWith(ResourceTypePrefix.StreamWorkdir)) {\n return readyOrDuplicateOrError(r);\n } else {\n // Unknown resource type detected\n // Set used to log this message only once\n if (!unknownResourceTypeNames.has(r.type.name)) {\n console.log(\"UNKNOWN RESOURCE TYPE: \" + r.type.name);\n unknownResourceTypeNames.add(r.type.name);\n }\n }\n }\n return false;\n};\n"],"mappings":";;;AAmBA,SAAS,wBAAwB,GAA8C;CAC7E,OACE,EAAE,iBACFA,cAAAA,0BAA0B,EAAE,kBAAkB,KAC9CA,cAAAA,0BAA0B,EAAE,KAAK;AAErC;AAEA,SAAS,4BAA4B,GAA8C;CACjF,IAAI,CAAC,wBAAwB,CAAC,GAAG,OAAO;CACxC,IAAI,CAAC,EAAE,eAAe,OAAO;CAC7B,IAAI,EAAE,WAAW,KAAA,GAAW,OAAO;CACnC,KAAK,MAAM,KAAK,EAAE,QAChB,IAAIC,cAAAA,uBAAuB,EAAE,KAAK,MAAMA,cAAAA,uBAAuB,EAAE,KAAK,KAAK,CAAC,EAAE,eAC5E,OAAO;CACX,OAAO;AACT;AAGA,MAAM,2CAA2B,IAAI,IAAY;;AAGjD,MAAa,qCAAiE,MAAe;CAC3F,QAAQ,EAAE,KAAK,MAAf;EACE,KAAKC,gCAAAA,iBAAiB,eAAe;GACnC,IAAI,CAAC,wBAAwB,CAAC,GAAG,OAAO;GACxC,IAAI,EAAE,WAAW,KAAA,GAAW,OAAO;GACnC,IAAIF,cAAAA,0BAA0B,EAAE,KAAK,GAAG,OAAO;GAC/C,MAAM,eAAeG,cAAAA,SAAS,GAAmB,cAAc;GAE/D,OADeA,cAAAA,SAAS,GAAmB,QAC/B,CAAC,CAAC,UAAU,aAAa;EACvC;EACA,KAAKD,g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E,KAAK,KAAK,WAAWE,gCAAAA,mBAAmB,IAAI,KAC9C,EAAE,KAAK,KAAK,WAAWA,gCAAAA,mBAAmB,EAAE,KAC5C,EAAE,KAAK,KAAK,WAAWA,gCAAAA,mBAAmB,gBAAgB,KAC1D,EAAE,KAAK,KAAK,WAAWA,gCAAAA,mBAAmB,sBAAsB,GAEhE,OAAO;OACF,IACL,EAAE,KAAK,KAAK,WAAWA,gCAAAA,mBAAmB,UAAU,KACpD,EAAE,KAAK,KAAK,WAAWA,gCAAAA,mBAAmB,SAAS,GAEnD,OAAO,4BAA4B,CAAC;OAC/B,IAAI,EAAE,KAAK,KAAK,WAAWA,gCAAAA,mBAAmB,WAAW,GAC9D,OAAO,wBAAwB,CAAC;OAC3B,IAAI,EAAE,KAAK,KAAK,WAAWA,gCAAAA,mBAAmB,aAAa,GAChE,OAAO,wBAAwB,CAAC;OAIhC,IAAI,CAAC,yBAAyB,IAAI,EAAE,KAAK,IAAI,GAAG;GAC9C,QAAQ,IAAI,4BAA4B,EAAE,KAAK,IAAI;GACnD,yBAAyB,IAAI,EAAE,KAAK,IAAI;EAC1C;CAEN;CACA,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"final.d.ts","names":[],"sources":["../../src/core/final.ts"],"mappings":";;;;;;AAeA;;;;;;;;KAAY,0BAAA,IACV,YAAA,EAAc,QAAA,CAAS,YAAA;AAyBzB;AAAA,cAAa,iCAAA,EAAmC,0BAAA"}
1
+ {"version":3,"file":"final.d.ts","names":[],"sources":["../../src/core/final.ts"],"mappings":";;;;;;AAeA;;;;;;;;KAAY,0BAAA,IACV,YAAA,EAAc,QAAQ,CAAC,YAAA;AAyBzB;AAAA,cAAa,iCAAA,EAAmC,0BAgF/C"}
@@ -56,7 +56,10 @@ const DefaultFinalResourceDataPredicate = (r) => {
56
56
  case ResourceTypeName.WorkingDirectory: return true;
57
57
  case ResourceTypeName.UserProject:
58
58
  case ResourceTypeName.Projects:
59
- case ResourceTypeName.ClientRoot: return false;
59
+ case ResourceTypeName.ClientRoot:
60
+ case ResourceTypeName.SharingOutbox:
61
+ case ResourceTypeName.SharingState:
62
+ case ResourceTypeName.SharedEnvelope: return false;
60
63
  default: if (r.type.name.startsWith(ResourceTypePrefix.Blob) || r.type.name.startsWith(ResourceTypePrefix.LS) || r.type.name.startsWith(ResourceTypePrefix.WorkingDirectory) || r.type.name.startsWith(ResourceTypePrefix.StorageSpaceAllocation)) return true;
61
64
  else if (r.type.name.startsWith(ResourceTypePrefix.BlobUpload) || r.type.name.startsWith(ResourceTypePrefix.BlobIndex)) return readyAndHasAllOutputsFilled(r);
62
65
  else if (r.type.name.startsWith(ResourceTypePrefix.PColumnData)) return readyOrDuplicateOrError(r);
@@ -1 +1 @@
1
- {"version":3,"file":"final.js","names":[],"sources":["../../src/core/final.ts"],"sourcesContent":["import type { Optional } from \"utility-types\";\nimport type { BasicResourceData, ResourceData } from \"./types\";\nimport { getField, isNotNullSignedResourceId, isNullSignedResourceId } from \"./types\";\nimport { ResourceTypeName, ResourceTypePrefix } from \"@milaboratories/pl-model-common\";\nexport { ResourceTypeName, ResourceTypePrefix };\n\n/**\n * Function is used to guide multiple layers of caching in pl-client and derived pl-tree.\n *\n * This function defines expected resource-specific state mutation behaviour,\n * if it returns true, system will expect that this data will never change as long as resource exist.\n *\n * If resource data contain information about fields, if should be taken into account, fields are undefined,\n * \"final\" state should be calculated for \"basic\" part of resource data only.\n */\nexport type FinalResourceDataPredicate = (\n resourceData: Optional<ResourceData, \"fields\">,\n) => boolean;\n\nfunction readyOrDuplicateOrError(r: ResourceData | BasicResourceData): boolean {\n return (\n r.resourceReady ||\n isNotNullSignedResourceId(r.originalResourceId) ||\n isNotNullSignedResourceId(r.error)\n );\n}\n\nfunction readyAndHasAllOutputsFilled(r: Optional<ResourceData, \"fields\">): boolean {\n if (!readyOrDuplicateOrError(r)) return false;\n if (!r.outputsLocked) return false;\n if (r.fields === undefined) return true; // if fields are not provided basic resource state is not expected to change in the future\n for (const f of r.fields)\n if (isNullSignedResourceId(f.error) && (isNullSignedResourceId(f.value) || !f.valueIsFinal))\n return false;\n return true;\n}\n\n// solely for logging\nconst unknownResourceTypeNames = new Set<string>();\n\n/** Default implementation, defining behaviour for built-in resource types. */\nexport const DefaultFinalResourceDataPredicate: FinalResourceDataPredicate = (r): boolean => {\n switch (r.type.name) {\n case ResourceTypeName.StreamManager: {\n if (!readyOrDuplicateOrError(r)) return false;\n if (r.fields === undefined) return true; // if fields are not provided basic resource state is not expected to change in the future\n if (isNotNullSignedResourceId(r.error)) return true;\n const downloadable = getField(r as ResourceData, \"downloadable\");\n const stream = getField(r as ResourceData, \"stream\");\n return stream.value === downloadable.value; // it's equal to the resource is marked as final on backend side\n }\n case ResourceTypeName.StdMap:\n case ResourceTypeName.StdMapSlash:\n case ResourceTypeName.EphStdMap:\n case ResourceTypeName.PFrame:\n case ResourceTypeName.ParquetChunk:\n case ResourceTypeName.BContext:\n case ResourceTypeName.BlockPackCustom:\n case ResourceTypeName.BinaryMap:\n case ResourceTypeName.BinaryValue:\n case ResourceTypeName.BlobMap:\n case ResourceTypeName.BResolveSingle:\n case ResourceTypeName.BResolveSingleNoResult:\n case ResourceTypeName.BQueryResult:\n case ResourceTypeName.TengoTemplate:\n case ResourceTypeName.TengoLib:\n case ResourceTypeName.SoftwareInfo:\n case ResourceTypeName.Dummy:\n return readyOrDuplicateOrError(r);\n case ResourceTypeName.JsonResourceError:\n return r.type.version === \"1\";\n case ResourceTypeName.JsonObject:\n case ResourceTypeName.JsonGzObject:\n case ResourceTypeName.JsonString:\n case ResourceTypeName.JsonArray:\n case ResourceTypeName.JsonNumber:\n case ResourceTypeName.BContextEnd:\n case ResourceTypeName.FrontendFromUrl:\n case ResourceTypeName.FrontendFromFolder:\n case ResourceTypeName.BObjectSpec:\n case ResourceTypeName.Blob:\n case ResourceTypeName.Null:\n case ResourceTypeName.Binary:\n case ResourceTypeName.LSProvider:\n case ResourceTypeName.WorkingDirectory:\n return true;\n case ResourceTypeName.UserProject:\n case ResourceTypeName.Projects:\n case ResourceTypeName.ClientRoot:\n return false;\n default:\n if (\n r.type.name.startsWith(ResourceTypePrefix.Blob) ||\n r.type.name.startsWith(ResourceTypePrefix.LS) ||\n r.type.name.startsWith(ResourceTypePrefix.WorkingDirectory) ||\n r.type.name.startsWith(ResourceTypePrefix.StorageSpaceAllocation)\n ) {\n return true;\n } else if (\n r.type.name.startsWith(ResourceTypePrefix.BlobUpload) ||\n r.type.name.startsWith(ResourceTypePrefix.BlobIndex)\n ) {\n return readyAndHasAllOutputsFilled(r);\n } else if (r.type.name.startsWith(ResourceTypePrefix.PColumnData)) {\n return readyOrDuplicateOrError(r);\n } else if (r.type.name.startsWith(ResourceTypePrefix.StreamWorkdir)) {\n return readyOrDuplicateOrError(r);\n } else {\n // Unknown resource type detected\n // Set used to log this message only once\n if (!unknownResourceTypeNames.has(r.type.name)) {\n console.log(\"UNKNOWN RESOURCE TYPE: \" + r.type.name);\n unknownResourceTypeNames.add(r.type.name);\n }\n }\n }\n return false;\n};\n"],"mappings":";;;AAmBA,SAAS,wBAAwB,GAA8C;AAC7E,QACE,EAAE,iBACF,0BAA0B,EAAE,mBAAmB,IAC/C,0BAA0B,EAAE,MAAM;;AAItC,SAAS,4BAA4B,GAA8C;AACjF,KAAI,CAAC,wBAAwB,EAAE,CAAE,QAAO;AACxC,KAAI,CAAC,EAAE,cAAe,QAAO;AAC7B,KAAI,EAAE,WAAW,KAAA,EAAW,QAAO;AACnC,MAAK,MAAM,KAAK,EAAE,OAChB,KAAI,uBAAuB,EAAE,MAAM,KAAK,uBAAuB,EAAE,MAAM,IAAI,CAAC,EAAE,cAC5E,QAAO;AACX,QAAO;;AAIT,MAAM,2CAA2B,IAAI,KAAa;;AAGlD,MAAa,qCAAiE,MAAe;AAC3F,SAAQ,EAAE,KAAK,MAAf;EACE,KAAK,iBAAiB,eAAe;AACnC,OAAI,CAAC,wBAAwB,EAAE,CAAE,QAAO;AACxC,OAAI,EAAE,WAAW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AW,mBAAmB,UAAU,CAEpD,QAAO,4BAA4B,EAAE;WAC5B,EAAE,KAAK,KAAK,WAAW,mBAAmB,YAAY,CAC/D,QAAO,wBAAwB,EAAE;WACxB,EAAE,KAAK,KAAK,WAAW,mBAAmB,cAAc,CACjE,QAAO,wBAAwB,EAAE;WAI7B,CAAC,yBAAyB,IAAI,EAAE,KAAK,KAAK,EAAE;AAC9C,WAAQ,IAAI,4BAA4B,EAAE,KAAK,KAAK;AACpD,4BAAyB,IAAI,EAAE,KAAK,KAAK;;;AAIjD,QAAO"}
1
+ {"version":3,"file":"final.js","names":[],"sources":["../../src/core/final.ts"],"sourcesContent":["import type { Optional } from \"utility-types\";\nimport type { BasicResourceData, ResourceData } from \"./types\";\nimport { getField, isNotNullSignedResourceId, isNullSignedResourceId } from \"./types\";\nimport { ResourceTypeName, ResourceTypePrefix } from \"@milaboratories/pl-model-common\";\nexport { ResourceTypeName, ResourceTypePrefix };\n\n/**\n * Function is used to guide multiple layers of caching in pl-client and derived pl-tree.\n *\n * This function defines expected resource-specific state mutation behaviour,\n * if it returns true, system will expect that this data will never change as long as resource exist.\n *\n * If resource data contain information about fields, if should be taken into account, fields are undefined,\n * \"final\" state should be calculated for \"basic\" part of resource data only.\n */\nexport type FinalResourceDataPredicate = (\n resourceData: Optional<ResourceData, \"fields\">,\n) => boolean;\n\nfunction readyOrDuplicateOrError(r: ResourceData | BasicResourceData): boolean {\n return (\n r.resourceReady ||\n isNotNullSignedResourceId(r.originalResourceId) ||\n isNotNullSignedResourceId(r.error)\n );\n}\n\nfunction readyAndHasAllOutputsFilled(r: Optional<ResourceData, \"fields\">): boolean {\n if (!readyOrDuplicateOrError(r)) return false;\n if (!r.outputsLocked) return false;\n if (r.fields === undefined) return true; // if fields are not provided basic resource state is not expected to change in the future\n for (const f of r.fields)\n if (isNullSignedResourceId(f.error) && (isNullSignedResourceId(f.value) || !f.valueIsFinal))\n return false;\n return true;\n}\n\n// solely for logging\nconst unknownResourceTypeNames = new Set<string>();\n\n/** Default implementation, defining behaviour for built-in resource types. */\nexport const DefaultFinalResourceDataPredicate: FinalResourceDataPredicate = (r): boolean => {\n switch (r.type.name) {\n case ResourceTypeName.StreamManager: {\n if (!readyOrDuplicateOrError(r)) return false;\n if (r.fields === undefined) return true; // if fields are not provided basic resource state is not expected to change in the future\n if (isNotNullSignedResourceId(r.error)) return true;\n const downloadable = getField(r as ResourceData, \"downloadable\");\n const stream = getField(r as ResourceData, \"stream\");\n return stream.value === downloadable.value; // it's equal to the resource is marked as final on backend side\n }\n case ResourceTypeName.StdMap:\n case ResourceTypeName.StdMapSlash:\n case ResourceTypeName.EphStdMap:\n case ResourceTypeName.PFrame:\n case ResourceTypeName.ParquetChunk:\n case ResourceTypeName.BContext:\n case ResourceTypeName.BlockPackCustom:\n case ResourceTypeName.BinaryMap:\n case ResourceTypeName.BinaryValue:\n case ResourceTypeName.BlobMap:\n case ResourceTypeName.BResolveSingle:\n case ResourceTypeName.BResolveSingleNoResult:\n case ResourceTypeName.BQueryResult:\n case ResourceTypeName.TengoTemplate:\n case ResourceTypeName.TengoLib:\n case ResourceTypeName.SoftwareInfo:\n case ResourceTypeName.Dummy:\n return readyOrDuplicateOrError(r);\n case ResourceTypeName.JsonResourceError:\n return r.type.version === \"1\";\n case ResourceTypeName.JsonObject:\n case ResourceTypeName.JsonGzObject:\n case ResourceTypeName.JsonString:\n case ResourceTypeName.JsonArray:\n case ResourceTypeName.JsonNumber:\n case ResourceTypeName.BContextEnd:\n case ResourceTypeName.FrontendFromUrl:\n case ResourceTypeName.FrontendFromFolder:\n case ResourceTypeName.BObjectSpec:\n case ResourceTypeName.Blob:\n case ResourceTypeName.Null:\n case ResourceTypeName.Binary:\n case ResourceTypeName.LSProvider:\n case ResourceTypeName.WorkingDirectory:\n return true;\n case ResourceTypeName.UserProject:\n case ResourceTypeName.Projects:\n case ResourceTypeName.ClientRoot:\n // Never final — these sharing resources gain and lose dynamic child fields over their lifetime.\n case ResourceTypeName.SharingOutbox:\n case ResourceTypeName.SharingState:\n case ResourceTypeName.SharedEnvelope:\n return false;\n default:\n if (\n r.type.name.startsWith(ResourceTypePrefix.Blob) ||\n r.type.name.startsWith(ResourceTypePrefix.LS) ||\n r.type.name.startsWith(ResourceTypePrefix.WorkingDirectory) ||\n r.type.name.startsWith(ResourceTypePrefix.StorageSpaceAllocation)\n ) {\n return true;\n } else if (\n r.type.name.startsWith(ResourceTypePrefix.BlobUpload) ||\n r.type.name.startsWith(ResourceTypePrefix.BlobIndex)\n ) {\n return readyAndHasAllOutputsFilled(r);\n } else if (r.type.name.startsWith(ResourceTypePrefix.PColumnData)) {\n return readyOrDuplicateOrError(r);\n } else if (r.type.name.startsWith(ResourceTypePrefix.StreamWorkdir)) {\n return readyOrDuplicateOrError(r);\n } else {\n // Unknown resource type detected\n // Set used to log this message only once\n if (!unknownResourceTypeNames.has(r.type.name)) {\n console.log(\"UNKNOWN RESOURCE TYPE: \" + r.type.name);\n unknownResourceTypeNames.add(r.type.name);\n }\n }\n }\n return false;\n};\n"],"mappings":";;;AAmBA,SAAS,wBAAwB,GAA8C;CAC7E,OACE,EAAE,iBACF,0BAA0B,EAAE,kBAAkB,KAC9C,0BAA0B,EAAE,KAAK;AAErC;AAEA,SAAS,4BAA4B,GAA8C;CACjF,IAAI,CAAC,wBAAwB,CAAC,GAAG,OAAO;CACxC,IAAI,CAAC,EAAE,eAAe,OAAO;CAC7B,IAAI,EAAE,WAAW,KAAA,GAAW,OAAO;CACnC,KAAK,MAAM,KAAK,EAAE,QAChB,IAAI,uBAAuB,EAAE,KAAK,MAAM,uBAAuB,EAAE,KAAK,KAAK,CAAC,EAAE,eAC5E,OAAO;CACX,OAAO;AACT;AAGA,MAAM,2CAA2B,IAAI,IAAY;;AAGjD,MAAa,qCAAiE,MAAe;CAC3F,QAAQ,EAAE,KAAK,MAAf;EACE,KAAK,iBAAiB,eAAe;GACnC,IAAI,CAAC,wBAAwB,CAAC,GAAG,OAAO;GACxC,IAAI,EAAE,WAA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AO;OACF,IACL,EAAE,KAAK,KAAK,WAAW,mBAAmB,UAAU,KACpD,EAAE,KAAK,KAAK,WAAW,mBAAmB,SAAS,GAEnD,OAAO,4BAA4B,CAAC;OAC/B,IAAI,EAAE,KAAK,KAAK,WAAW,mBAAmB,WAAW,GAC9D,OAAO,wBAAwB,CAAC;OAC3B,IAAI,EAAE,KAAK,KAAK,WAAW,mBAAmB,aAAa,GAChE,OAAO,wBAAwB,CAAC;OAIhC,IAAI,CAAC,yBAAyB,IAAI,EAAE,KAAK,IAAI,GAAG;GAC9C,QAAQ,IAAI,4BAA4B,EAAE,KAAK,IAAI;GACnD,yBAAyB,IAAI,EAAE,KAAK,IAAI;EAC1C;CAEN;CACA,OAAO;AACT"}
@@ -1,8 +1,6 @@
1
- require("../_virtual/_rolldown/runtime.cjs");
2
1
  const require_types = require("./types.cjs");
3
2
  const require_timestamp = require("../proto-grpc/google/protobuf/timestamp.cjs");
4
3
  const require_api = require("../proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.cjs");
5
- const require_code = require("../proto-grpc/google/rpc/code.cjs");
6
4
  const require_errors = require("./errors.cjs");
7
5
  const require_config = require("./config.cjs");
8
6
  const require_api_client = require("../proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.cjs");
@@ -43,6 +41,8 @@ function isAfterVersion(version, target) {
43
41
  return suffix !== "";
44
42
  }
45
43
  var WireClientProviderImpl = class {
44
+ wireOpts;
45
+ clientConstructor;
46
46
  client = void 0;
47
47
  constructor(wireOpts, clientConstructor) {
48
48
  this.wireOpts = wireOpts;
@@ -58,6 +58,8 @@ var WireClientProviderImpl = class {
58
58
  };
59
59
  /** Abstract out low level networking and authorization details */
60
60
  var LLPlClient = class LLPlClient {
61
+ conf;
62
+ ops;
61
63
  /** Initial authorization information */
62
64
  authInformation;
63
65
  /** Will be executed by the client when it is required */
@@ -72,6 +74,7 @@ var LLPlClient = class LLPlClient {
72
74
  _serverInfo;
73
75
  _authMethodsSync;
74
76
  _status = "OK";
77
+ authProbeInFlight = false;
75
78
  statusListener;
76
79
  _wireProto = "grpc";
77
80
  _wireConn;
@@ -243,6 +246,24 @@ var LLPlClient = class LLPlClient {
243
246
  }
244
247
  });
245
248
  }
249
+ /**
250
+ * UNAUTHENTICATED covers both a dead session (must reset) and a per-request authorization failure
251
+ * such as a revoked resource signature (must not). Disambiguate by probing getSessionInfo — an
252
+ * authenticated call with no resource signature: success means the session is alive and the failure
253
+ * was resource-level; a probe that is itself Unauthenticated means real auth loss. Coalesced via
254
+ * authProbeInFlight so a burst of failures costs one probe.
255
+ */
256
+ async verifyThenMaybeEscalateUnauthenticated() {
257
+ if (this._status !== "OK" || this.authProbeInFlight) return;
258
+ this.authProbeInFlight = true;
259
+ try {
260
+ await this.getSessionInfo();
261
+ } catch (e) {
262
+ if (require_errors.isUnauthenticated(e)) this.updateStatus("Unauthenticated");
263
+ } finally {
264
+ this.authProbeInFlight = false;
265
+ }
266
+ }
246
267
  get status() {
247
268
  return this._status;
248
269
  }
@@ -253,7 +274,8 @@ var LLPlClient = class LLPlClient {
253
274
  (async () => {
254
275
  try {
255
276
  const ttl = BigInt(this.conf.authTTLSeconds);
256
- this.authInformation = { jwtToken: this.hasCapability("auth:v2") ? await this.refreshToken({ ttlSeconds: ttl }) : await this.getJwtToken(ttl) };
277
+ const token = this.hasCapability("auth:v2") ? await this.refreshToken({ ttlSeconds: ttl }) : await this.getJwtToken(ttl);
278
+ this.authInformation = { jwtToken: token };
257
279
  this.refreshTimestamp = require_auth.inferAuthRefreshTime(this.authInformation, this.conf.authMaxRefreshSeconds);
258
280
  if (this.onAuthUpdate) this.onAuthUpdate(this.authInformation);
259
281
  } catch (e) {
@@ -291,7 +313,7 @@ var LLPlClient = class LLPlClient {
291
313
  ...resOptions,
292
314
  status: response.status
293
315
  });
294
- if (respErr.error.code === require_code.Code.UNAUTHENTICATED) this.updateStatus("Unauthenticated");
316
+ if (respErr.error.code === 16) this.verifyThenMaybeEscalateUnauthenticated();
295
317
  return new Response(respErr.origBody, {
296
318
  ...resOptions,
297
319
  status: response.status
@@ -303,7 +325,7 @@ var LLPlClient = class LLPlClient {
303
325
  return (options, nextCall) => {
304
326
  return new _grpc_grpc_js.InterceptingCall(nextCall(options), { start: (metadata, listener, next) => {
305
327
  next(metadata, { onReceiveStatus: (status, next) => {
306
- if (status.code == _grpc_grpc_js.status.UNAUTHENTICATED) this.updateStatus("Unauthenticated");
328
+ if (status.code == _grpc_grpc_js.status.UNAUTHENTICATED) this.verifyThenMaybeEscalateUnauthenticated();
307
329
  if (status.code == _grpc_grpc_js.status.UNAVAILABLE) this.updateStatus("Disconnected");
308
330
  next(status);
309
331
  } });
@@ -338,7 +360,7 @@ var LLPlClient = class LLPlClient {
338
360
  }
339
361
  async getJwtToken(ttlSeconds, options) {
340
362
  const cl = this.clientProvider.get();
341
- const role = options?.role ?? require_api.AuthAPI_Role.UNSPECIFIED;
363
+ const role = options?.role ?? 0;
342
364
  if (cl instanceof require_api_client.PlatformClient) {
343
365
  const meta = {};
344
366
  if (options?.authorization) meta.authorization = options.authorization;
@@ -365,7 +387,7 @@ var LLPlClient = class LLPlClient {
365
387
  async loginBasic(user, password, opts = {}) {
366
388
  const cl = this.clientProvider.get();
367
389
  const ttl = opts.ttlSeconds ?? BigInt(this.conf.authTTLSeconds);
368
- const role = opts.role ?? require_api.AuthAPI_Role.UNSPECIFIED;
390
+ const role = opts.role ?? 0;
369
391
  if (cl instanceof require_api_client.PlatformClient) return (await cl.login({
370
392
  credentials: {
371
393
  oneofKind: "basic",
@@ -394,7 +416,7 @@ var LLPlClient = class LLPlClient {
394
416
  async loginWithToken(token, opts = {}) {
395
417
  const cl = this.clientProvider.get();
396
418
  const ttl = opts.ttlSeconds ?? BigInt(this.conf.authTTLSeconds);
397
- const role = opts.role ?? require_api.AuthAPI_Role.UNSPECIFIED;
419
+ const role = opts.role ?? 0;
398
420
  const bytes = typeof token === "string" ? Buffer.from(token, "utf8") : token;
399
421
  if (cl instanceof require_api_client.PlatformClient) return (await cl.login({
400
422
  credentials: {
@@ -434,13 +456,15 @@ var LLPlClient = class LLPlClient {
434
456
  const exp = (0, _milaboratories_ts_helpers.notEmpty)(resp.publicPkce.expiresAt, "beginSSOLogin: missing expiresAt");
435
457
  return {
436
458
  nonce: resp.publicPkce.nonce,
437
- expiresAt: require_timestamp.Timestamp.toDate(exp)
459
+ expiresAt: require_timestamp.Timestamp.toDate(exp),
460
+ clientSecret: resp.publicPkce.clientSecret
438
461
  };
439
462
  } else {
440
463
  const pkce = (0, _milaboratories_ts_helpers.notEmpty)((0, _milaboratories_ts_helpers.notEmpty)((await cl.POST("/v1/auth/sso/begin-login", { body: {} })).data, "REST: empty response for beginSSOLogin request").publicPkce, "REST: missing publicPkce in beginSSOLogin");
441
464
  return {
442
465
  nonce: pkce.nonce,
443
- expiresAt: new Date(pkce.expiresAt)
466
+ expiresAt: new Date(pkce.expiresAt),
467
+ clientSecret: pkce.clientSecret
444
468
  };
445
469
  }
446
470
  }
@@ -495,13 +519,12 @@ var LLPlClient = class LLPlClient {
495
519
  ]);
496
520
  }
497
521
  /**
498
- * True if the backend honors per-file `permissions` on workdir fill rules
499
- * (PR #1830 in milaboratory/pl). Backends before this change ignore the
500
- * requested mode and always land files at the canonical archive perm,
501
- * making `exec.builder().writeFile/addFile({ writable: true })` a no-op.
522
+ * True if the backend honors per-file `permissions` on workdir fill rules, so
523
+ * `exec.builder().writeFile/addFile({ writable: true })` takes effect. When false
524
+ * the requested mode is ignored and files land at the canonical archive perm.
502
525
  *
503
- * Tagged at 3.5.0 cut without the change, so [3, 5, 0] excludes the tagged
504
- * release but includes dev builds past the tag (e.g. "3.5.0-224-g0ca182").
526
+ * [3, 5, 0] excludes the tagged 3.5.0 release but includes dev builds past the
527
+ * tag (e.g. "3.5.0-224-g0ca182"), which is where the support lands.
505
528
  */
506
529
  get supportsWritableWorkdirFiles() {
507
530
  return isAfterVersion(this.serverInfo.coreVersion, [
@@ -624,6 +647,27 @@ var LLPlClient = class LLPlClient {
624
647
  for await (const msg of call.responses) responses.push(msg);
625
648
  return responses;
626
649
  }
650
+ /** Returns the authenticated caller's session id and effective role.
651
+ * Models the {@link getUserRoot} wrapper: gRPC unary with a REST fallback. */
652
+ async getSessionInfo() {
653
+ const cl = this.clientProvider.get();
654
+ if (cl instanceof require_api_client.PlatformClient) return (await cl.getSessionInfo({})).response;
655
+ else {
656
+ const resp = (0, _milaboratories_ts_helpers.notEmpty)((await cl.POST("/v1/auth/session-info", { body: {} })).data, "REST: empty response for getSessionInfo request");
657
+ return {
658
+ sessionId: Uint8Array.from(Buffer.from(resp.sessionId, "base64")),
659
+ role: resp.role
660
+ };
661
+ }
662
+ }
663
+ /** Lists the users known to the server — the recipient picker's source. A user
664
+ * becomes known on first login; provisioned users who have never logged in do not
665
+ * appear. gRPC-only (unary, no REST binding). */
666
+ async listUsers() {
667
+ const cl = this.clientProvider.get();
668
+ if (!(cl instanceof require_api_client.PlatformClient)) throw new Error("ListUsers requires gRPC wire protocol; REST is not supported");
669
+ return (await cl.listUsers({})).response.users;
670
+ }
627
671
  async txSync(txId) {
628
672
  const cl = this.clientProvider.get();
629
673
  if (cl instanceof require_api_client.PlatformClient) await cl.txSync({ txId: BigInt(txId) });