@milaboratories/pl-client 2.17.7 → 2.17.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (276) hide show
  1. package/dist/_virtual/_rolldown/runtime.cjs +43 -0
  2. package/dist/_virtual/_rolldown/runtime.js +18 -0
  3. package/dist/core/PromiseTracker.cjs +33 -33
  4. package/dist/core/PromiseTracker.cjs.map +1 -1
  5. package/dist/core/PromiseTracker.d.ts +10 -7
  6. package/dist/core/PromiseTracker.js +33 -31
  7. package/dist/core/PromiseTracker.js.map +1 -1
  8. package/dist/core/StatefulPromise.cjs +60 -61
  9. package/dist/core/StatefulPromise.cjs.map +1 -1
  10. package/dist/core/StatefulPromise.js +60 -60
  11. package/dist/core/StatefulPromise.js.map +1 -1
  12. package/dist/core/abstract_stream.d.ts +18 -15
  13. package/dist/core/advisory_locks.cjs +42 -49
  14. package/dist/core/advisory_locks.cjs.map +1 -1
  15. package/dist/core/advisory_locks.js +42 -48
  16. package/dist/core/advisory_locks.js.map +1 -1
  17. package/dist/core/auth.cjs +10 -15
  18. package/dist/core/auth.cjs.map +1 -1
  19. package/dist/core/auth.d.ts +7 -3
  20. package/dist/core/auth.js +10 -13
  21. package/dist/core/auth.js.map +1 -1
  22. package/dist/core/cache.d.ts +11 -7
  23. package/dist/core/client.cjs +255 -306
  24. package/dist/core/client.cjs.map +1 -1
  25. package/dist/core/client.d.ts +72 -68
  26. package/dist/core/client.js +253 -285
  27. package/dist/core/client.js.map +1 -1
  28. package/dist/core/config.cjs +81 -99
  29. package/dist/core/config.cjs.map +1 -1
  30. package/dist/core/config.d.ts +93 -90
  31. package/dist/core/config.js +81 -98
  32. package/dist/core/config.js.map +1 -1
  33. package/dist/core/default_client.cjs +84 -125
  34. package/dist/core/default_client.cjs.map +1 -1
  35. package/dist/core/default_client.d.ts +9 -6
  36. package/dist/core/default_client.js +78 -103
  37. package/dist/core/default_client.js.map +1 -1
  38. package/dist/core/driver.cjs +12 -16
  39. package/dist/core/driver.cjs.map +1 -1
  40. package/dist/core/driver.d.ts +18 -14
  41. package/dist/core/driver.js +12 -15
  42. package/dist/core/driver.js.map +1 -1
  43. package/dist/core/error_resource.cjs +5 -4
  44. package/dist/core/error_resource.cjs.map +1 -1
  45. package/dist/core/error_resource.js +5 -3
  46. package/dist/core/error_resource.js.map +1 -1
  47. package/dist/core/errors.cjs +104 -140
  48. package/dist/core/errors.cjs.map +1 -1
  49. package/dist/core/errors.d.ts +34 -30
  50. package/dist/core/errors.js +102 -137
  51. package/dist/core/errors.js.map +1 -1
  52. package/dist/core/final.cjs +63 -89
  53. package/dist/core/final.cjs.map +1 -1
  54. package/dist/core/final.d.ts +8 -4
  55. package/dist/core/final.js +63 -87
  56. package/dist/core/final.js.map +1 -1
  57. package/dist/core/ll_client.cjs +416 -521
  58. package/dist/core/ll_client.cjs.map +1 -1
  59. package/dist/core/ll_client.d.ts +100 -97
  60. package/dist/core/ll_client.js +415 -519
  61. package/dist/core/ll_client.js.map +1 -1
  62. package/dist/core/ll_transaction.cjs +206 -240
  63. package/dist/core/ll_transaction.cjs.map +1 -1
  64. package/dist/core/ll_transaction.d.ts +50 -52
  65. package/dist/core/ll_transaction.js +205 -238
  66. package/dist/core/ll_transaction.js.map +1 -1
  67. package/dist/core/stat.cjs +64 -63
  68. package/dist/core/stat.cjs.map +1 -1
  69. package/dist/core/stat.d.ts +35 -36
  70. package/dist/core/stat.js +64 -62
  71. package/dist/core/stat.js.map +1 -1
  72. package/dist/core/transaction.cjs +613 -650
  73. package/dist/core/transaction.cjs.map +1 -1
  74. package/dist/core/transaction.d.ts +165 -162
  75. package/dist/core/transaction.js +612 -648
  76. package/dist/core/transaction.js.map +1 -1
  77. package/dist/core/type_conversion.cjs +62 -83
  78. package/dist/core/type_conversion.cjs.map +1 -1
  79. package/dist/core/type_conversion.js +61 -81
  80. package/dist/core/type_conversion.js.map +1 -1
  81. package/dist/core/types.cjs +56 -86
  82. package/dist/core/types.cjs.map +1 -1
  83. package/dist/core/types.d.ts +63 -62
  84. package/dist/core/types.js +54 -83
  85. package/dist/core/types.js.map +1 -1
  86. package/dist/core/unauth_client.cjs +35 -41
  87. package/dist/core/unauth_client.cjs.map +1 -1
  88. package/dist/core/unauth_client.d.ts +18 -14
  89. package/dist/core/unauth_client.js +34 -39
  90. package/dist/core/unauth_client.js.map +1 -1
  91. package/dist/core/websocket_stream.cjs +280 -349
  92. package/dist/core/websocket_stream.cjs.map +1 -1
  93. package/dist/core/websocket_stream.js +278 -347
  94. package/dist/core/websocket_stream.js.map +1 -1
  95. package/dist/core/wire.d.ts +21 -17
  96. package/dist/helpers/pl.cjs +71 -73
  97. package/dist/helpers/pl.cjs.map +1 -1
  98. package/dist/helpers/pl.d.ts +40 -41
  99. package/dist/helpers/pl.js +66 -46
  100. package/dist/helpers/pl.js.map +1 -1
  101. package/dist/helpers/poll.cjs +99 -134
  102. package/dist/helpers/poll.cjs.map +1 -1
  103. package/dist/helpers/poll.d.ts +37 -34
  104. package/dist/helpers/poll.js +97 -113
  105. package/dist/helpers/poll.js.map +1 -1
  106. package/dist/helpers/retry_strategy.cjs +82 -87
  107. package/dist/helpers/retry_strategy.cjs.map +1 -1
  108. package/dist/helpers/retry_strategy.js +83 -86
  109. package/dist/helpers/retry_strategy.js.map +1 -1
  110. package/dist/helpers/tx_helpers.cjs +21 -20
  111. package/dist/helpers/tx_helpers.cjs.map +1 -1
  112. package/dist/helpers/tx_helpers.d.ts +11 -7
  113. package/dist/helpers/tx_helpers.js +20 -18
  114. package/dist/helpers/tx_helpers.js.map +1 -1
  115. package/dist/index.cjs +117 -106
  116. package/dist/index.d.ts +17 -17
  117. package/dist/index.js +17 -19
  118. package/dist/proto-grpc/github.com/googleapis/googleapis/google/rpc/status.cjs +72 -66
  119. package/dist/proto-grpc/github.com/googleapis/googleapis/google/rpc/status.cjs.map +1 -1
  120. package/dist/proto-grpc/github.com/googleapis/googleapis/google/rpc/status.d.ts +35 -37
  121. package/dist/proto-grpc/github.com/googleapis/googleapis/google/rpc/status.js +71 -64
  122. package/dist/proto-grpc/github.com/googleapis/googleapis/google/rpc/status.js.map +1 -1
  123. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.cjs +12611 -12866
  124. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.cjs.map +1 -1
  125. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.cjs +226 -226
  126. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.cjs.map +1 -1
  127. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.d.ts +281 -330
  128. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.js +225 -224
  129. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.js.map +1 -1
  130. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.d.ts +2640 -4294
  131. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.js +12608 -12706
  132. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.js.map +1 -1
  133. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.cjs +1230 -1089
  134. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.cjs.map +1 -1
  135. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.d.ts +393 -420
  136. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.js +1228 -1083
  137. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.js.map +1 -1
  138. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.cjs +142 -143
  139. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.cjs.map +1 -1
  140. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.d.ts +62 -64
  141. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.js +140 -141
  142. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.js.map +1 -1
  143. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/resource_types.cjs +572 -487
  144. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/resource_types.cjs.map +1 -1
  145. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/resource_types.d.ts +125 -228
  146. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/resource_types.js +572 -485
  147. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/resource_types.js.map +1 -1
  148. package/dist/proto-grpc/google/protobuf/any.cjs +131 -146
  149. package/dist/proto-grpc/google/protobuf/any.cjs.map +1 -1
  150. package/dist/proto-grpc/google/protobuf/any.d.ts +78 -84
  151. package/dist/proto-grpc/google/protobuf/any.js +130 -144
  152. package/dist/proto-grpc/google/protobuf/any.js.map +1 -1
  153. package/dist/proto-grpc/google/protobuf/duration.cjs +92 -100
  154. package/dist/proto-grpc/google/protobuf/duration.cjs.map +1 -1
  155. package/dist/proto-grpc/google/protobuf/duration.d.ts +38 -43
  156. package/dist/proto-grpc/google/protobuf/duration.js +91 -98
  157. package/dist/proto-grpc/google/protobuf/duration.js.map +1 -1
  158. package/dist/proto-grpc/google/protobuf/timestamp.cjs +117 -128
  159. package/dist/proto-grpc/google/protobuf/timestamp.cjs.map +1 -1
  160. package/dist/proto-grpc/google/protobuf/timestamp.d.ts +50 -55
  161. package/dist/proto-grpc/google/protobuf/timestamp.js +116 -126
  162. package/dist/proto-grpc/google/protobuf/timestamp.js.map +1 -1
  163. package/dist/proto-grpc/google/rpc/code.cjs +223 -238
  164. package/dist/proto-grpc/google/rpc/code.cjs.map +1 -1
  165. package/dist/proto-grpc/google/rpc/code.d.ts +209 -206
  166. package/dist/proto-grpc/google/rpc/code.js +221 -237
  167. package/dist/proto-grpc/google/rpc/code.js.map +1 -1
  168. package/dist/proto-rest/index.cjs +67 -66
  169. package/dist/proto-rest/index.cjs.map +1 -1
  170. package/dist/proto-rest/index.d.ts +24 -18
  171. package/dist/proto-rest/index.js +61 -65
  172. package/dist/proto-rest/index.js.map +1 -1
  173. package/dist/proto-rest/plapi.d.ts +1400 -1477
  174. package/dist/test/tcp-proxy.cjs +100 -126
  175. package/dist/test/tcp-proxy.cjs.map +1 -1
  176. package/dist/test/tcp-proxy.d.ts +17 -13
  177. package/dist/test/tcp-proxy.js +97 -104
  178. package/dist/test/tcp-proxy.js.map +1 -1
  179. package/dist/test/test_config.cjs +145 -194
  180. package/dist/test/test_config.cjs.map +1 -1
  181. package/dist/test/test_config.d.ts +34 -30
  182. package/dist/test/test_config.js +138 -166
  183. package/dist/test/test_config.js.map +1 -1
  184. package/dist/util/pl.cjs +4 -3
  185. package/dist/util/pl.cjs.map +1 -1
  186. package/dist/util/pl.js +4 -2
  187. package/dist/util/pl.js.map +1 -1
  188. package/dist/util/util.cjs +7 -10
  189. package/dist/util/util.cjs.map +1 -1
  190. package/dist/util/util.js +7 -9
  191. package/dist/util/util.js.map +1 -1
  192. package/package.json +8 -8
  193. package/src/core/errors.ts +1 -1
  194. package/src/core/transaction.ts +123 -133
  195. package/src/core/websocket_stream.ts +10 -1
  196. package/dist/__external/.pnpm/@rollup_plugin-typescript@12.3.0_rollup@4.52.4_tslib@2.8.1_typescript@5.6.3/__external/tslib/tslib.es6.cjs +0 -61
  197. package/dist/__external/.pnpm/@rollup_plugin-typescript@12.3.0_rollup@4.52.4_tslib@2.8.1_typescript@5.6.3/__external/tslib/tslib.es6.cjs.map +0 -1
  198. package/dist/__external/.pnpm/@rollup_plugin-typescript@12.3.0_rollup@4.52.4_tslib@2.8.1_typescript@5.6.3/__external/tslib/tslib.es6.js +0 -58
  199. package/dist/__external/.pnpm/@rollup_plugin-typescript@12.3.0_rollup@4.52.4_tslib@2.8.1_typescript@5.6.3/__external/tslib/tslib.es6.js.map +0 -1
  200. package/dist/core/PromiseTracker.d.ts.map +0 -1
  201. package/dist/core/StatefulPromise.d.ts +0 -39
  202. package/dist/core/StatefulPromise.d.ts.map +0 -1
  203. package/dist/core/abstract_stream.d.ts.map +0 -1
  204. package/dist/core/advisory_locks.d.ts +0 -10
  205. package/dist/core/advisory_locks.d.ts.map +0 -1
  206. package/dist/core/auth.d.ts.map +0 -1
  207. package/dist/core/cache.d.ts.map +0 -1
  208. package/dist/core/client.d.ts.map +0 -1
  209. package/dist/core/config.d.ts.map +0 -1
  210. package/dist/core/default_client.d.ts.map +0 -1
  211. package/dist/core/driver.d.ts.map +0 -1
  212. package/dist/core/error_resource.d.ts +0 -6
  213. package/dist/core/error_resource.d.ts.map +0 -1
  214. package/dist/core/errors.d.ts.map +0 -1
  215. package/dist/core/final.d.ts.map +0 -1
  216. package/dist/core/ll_client.d.ts.map +0 -1
  217. package/dist/core/ll_transaction.d.ts.map +0 -1
  218. package/dist/core/stat.d.ts.map +0 -1
  219. package/dist/core/transaction.d.ts.map +0 -1
  220. package/dist/core/type_conversion.d.ts +0 -8
  221. package/dist/core/type_conversion.d.ts.map +0 -1
  222. package/dist/core/types.d.ts.map +0 -1
  223. package/dist/core/unauth_client.d.ts.map +0 -1
  224. package/dist/core/websocket_stream.d.ts +0 -67
  225. package/dist/core/websocket_stream.d.ts.map +0 -1
  226. package/dist/core/wire.d.ts.map +0 -1
  227. package/dist/helpers/pl.d.ts.map +0 -1
  228. package/dist/helpers/poll.d.ts.map +0 -1
  229. package/dist/helpers/retry_strategy.d.ts +0 -24
  230. package/dist/helpers/retry_strategy.d.ts.map +0 -1
  231. package/dist/helpers/state_helpers.d.ts +0 -3
  232. package/dist/helpers/state_helpers.d.ts.map +0 -1
  233. package/dist/helpers/tx_helpers.d.ts.map +0 -1
  234. package/dist/index.cjs.map +0 -1
  235. package/dist/index.d.ts.map +0 -1
  236. package/dist/index.js.map +0 -1
  237. package/dist/proto-grpc/github.com/googleapis/googleapis/google/rpc/status.d.ts.map +0 -1
  238. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.d.ts.map +0 -1
  239. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.d.ts.map +0 -1
  240. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.d.ts.map +0 -1
  241. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.d.ts.map +0 -1
  242. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/import.d.ts +0 -106
  243. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/import.d.ts.map +0 -1
  244. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/resource_types.d.ts.map +0 -1
  245. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/ws-test.d.ts +0 -73
  246. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/ws-test.d.ts.map +0 -1
  247. package/dist/proto-grpc/google/api/http.d.ts +0 -456
  248. package/dist/proto-grpc/google/api/http.d.ts.map +0 -1
  249. package/dist/proto-grpc/google/protobuf/any.d.ts.map +0 -1
  250. package/dist/proto-grpc/google/protobuf/descriptor.d.ts +0 -2340
  251. package/dist/proto-grpc/google/protobuf/descriptor.d.ts.map +0 -1
  252. package/dist/proto-grpc/google/protobuf/duration.d.ts.map +0 -1
  253. package/dist/proto-grpc/google/protobuf/empty.d.ts +0 -32
  254. package/dist/proto-grpc/google/protobuf/empty.d.ts.map +0 -1
  255. package/dist/proto-grpc/google/protobuf/struct.d.ts +0 -187
  256. package/dist/proto-grpc/google/protobuf/struct.d.ts.map +0 -1
  257. package/dist/proto-grpc/google/protobuf/timestamp.d.ts.map +0 -1
  258. package/dist/proto-grpc/google/protobuf/wrappers.d.ts +0 -308
  259. package/dist/proto-grpc/google/protobuf/wrappers.d.ts.map +0 -1
  260. package/dist/proto-grpc/google/rpc/code.d.ts.map +0 -1
  261. package/dist/proto-grpc/google/rpc/error_details.d.ts +0 -654
  262. package/dist/proto-grpc/google/rpc/error_details.d.ts.map +0 -1
  263. package/dist/proto-grpc/google/rpc/http.d.ts +0 -121
  264. package/dist/proto-grpc/google/rpc/http.d.ts.map +0 -1
  265. package/dist/proto-grpc/google/rpc/status.d.ts +0 -55
  266. package/dist/proto-grpc/google/rpc/status.d.ts.map +0 -1
  267. package/dist/proto-rest/index.d.ts.map +0 -1
  268. package/dist/proto-rest/plapi.d.ts.map +0 -1
  269. package/dist/test/tcp-proxy.d.ts.map +0 -1
  270. package/dist/test/test_config.d.ts.map +0 -1
  271. package/dist/util/branding.d.ts +0 -7
  272. package/dist/util/branding.d.ts.map +0 -1
  273. package/dist/util/pl.d.ts +0 -9
  274. package/dist/util/pl.d.ts.map +0 -1
  275. package/dist/util/util.d.ts +0 -2
  276. package/dist/util/util.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"type_conversion.js","sources":["../../src/core/type_conversion.ts"],"sourcesContent":["import type {\n Field,\n Resource,\n} from \"../proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types\";\nimport {\n Field_ValueStatus,\n Resource_Kind,\n} from \"../proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types\";\nimport { FieldType as GrpcFieldType } from \"../proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types\";\nimport type {\n FieldData,\n FieldStatus,\n OptionalResourceId,\n FieldType,\n ResourceData,\n ResourceId,\n ResourceKind,\n} from \"./types\";\nimport { NullResourceId } from \"./types\";\nimport { assertNever, notEmpty } from \"@milaboratories/ts-helpers\";\nimport { throwPlNotFoundError } from \"./errors\";\n\nconst ResourceErrorField = \"resourceError\";\n\nfunction resourceIsDeleted(proto: Resource): boolean {\n return proto.deletedTime !== undefined && proto.deletedTime.seconds !== 0n;\n}\n\n/** Throws \"native\" pl not found error, if resource is marked as deleted. */\nexport function protoToResource(proto: Resource): ResourceData {\n if (resourceIsDeleted(proto)) throwPlNotFoundError(\"resource deleted\");\n return {\n id: proto.id as ResourceId,\n originalResourceId: proto.originalResourceId as OptionalResourceId,\n type: notEmpty(proto.type),\n data: proto.data,\n inputsLocked: proto.inputsLocked,\n outputsLocked: proto.outputsLocked,\n resourceReady: proto.resourceReady,\n kind: protoToResourceKind(proto.kind),\n error: protoToError(proto),\n final: proto.isFinal,\n fields: proto.fields?.filter((f) => f.id!.fieldName !== ResourceErrorField).map(protoToField),\n };\n}\n\nfunction protoToResourceKind(proto: Resource_Kind): ResourceKind {\n switch (proto) {\n case Resource_Kind.STRUCTURAL:\n return \"Structural\";\n case Resource_Kind.VALUE:\n return \"Value\";\n }\n\n throw new Error(\"invalid ResourceKind: \" + proto);\n}\n\nfunction protoToError(proto: Resource): OptionalResourceId {\n const f = proto.fields.find((f) => f?.id?.fieldName === ResourceErrorField);\n return (f?.error ?? NullResourceId) as OptionalResourceId;\n}\n\nexport function protoToField(proto: Field): FieldData {\n return {\n name: notEmpty(proto.id?.fieldName),\n type: protoToFieldType(proto.type),\n status: protoToFieldStatus(proto.valueStatus),\n value: proto.value as OptionalResourceId,\n error: proto.error as OptionalResourceId,\n valueIsFinal: proto.valueIsFinal,\n };\n}\n\nfunction protoToFieldType(proto: GrpcFieldType): FieldType {\n switch (proto) {\n case GrpcFieldType.INPUT:\n return \"Input\";\n case GrpcFieldType.OUTPUT:\n return \"Output\";\n case GrpcFieldType.SERVICE:\n return \"Service\";\n case GrpcFieldType.ONE_TIME_WRITABLE:\n return \"OTW\";\n case GrpcFieldType.DYNAMIC:\n return \"Dynamic\";\n case GrpcFieldType.MULTIPLE_TIMES_WRITABLE:\n return \"MTW\";\n default:\n throw new Error(\"invalid FieldType: \" + proto);\n }\n}\n\nfunction protoToFieldStatus(proto: Field_ValueStatus): FieldStatus {\n switch (proto) {\n case Field_ValueStatus.EMPTY:\n return \"Empty\";\n case Field_ValueStatus.ASSIGNED:\n return \"Assigned\";\n case Field_ValueStatus.RESOLVED:\n return \"Resolved\";\n default:\n throw new Error(\"invalid FieldStatus: \" + proto);\n }\n}\n\nexport function fieldTypeToProto(type: FieldType): GrpcFieldType {\n switch (type) {\n case \"Input\":\n return GrpcFieldType.INPUT;\n case \"Output\":\n return GrpcFieldType.OUTPUT;\n case \"Dynamic\":\n return GrpcFieldType.DYNAMIC;\n case \"Service\":\n return GrpcFieldType.SERVICE;\n case \"MTW\":\n return GrpcFieldType.MULTIPLE_TIMES_WRITABLE;\n case \"OTW\":\n return GrpcFieldType.ONE_TIME_WRITABLE;\n default:\n return assertNever(type);\n }\n}\n"],"names":["GrpcFieldType"],"mappings":";;;;;;AAsBA,MAAM,kBAAkB,GAAG,eAAe;AAE1C,SAAS,iBAAiB,CAAC,KAAe,EAAA;AACxC,IAAA,OAAO,KAAK,CAAC,WAAW,KAAK,SAAS,IAAI,KAAK,CAAC,WAAW,CAAC,OAAO,KAAK,EAAE;AAC5E;AAEA;AACM,SAAU,eAAe,CAAC,KAAe,EAAA;IAC7C,IAAI,iBAAiB,CAAC,KAAK,CAAC;QAAE,oBAAoB,CAAC,kBAAkB,CAAC;IACtE,OAAO;QACL,EAAE,EAAE,KAAK,CAAC,EAAgB;QAC1B,kBAAkB,EAAE,KAAK,CAAC,kBAAwC;AAClE,QAAA,IAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC;QAC1B,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,YAAY,EAAE,KAAK,CAAC,YAAY;QAChC,aAAa,EAAE,KAAK,CAAC,aAAa;QAClC,aAAa,EAAE,KAAK,CAAC,aAAa;AAClC,QAAA,IAAI,EAAE,mBAAmB,CAAC,KAAK,CAAC,IAAI,CAAC;AACrC,QAAA,KAAK,EAAE,YAAY,CAAC,KAAK,CAAC;QAC1B,KAAK,EAAE,KAAK,CAAC,OAAO;QACpB,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAG,CAAC,SAAS,KAAK,kBAAkB,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC;KAC9F;AACH;AA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YAAA,MAAM,IAAI,KAAK,CAAC,qBAAqB,GAAG,KAAK,CAAC;;AAEpD;AAEA,SAAS,kBAAkB,CAAC,KAAwB,EAAA;IAClD,QAAQ,KAAK;QACX,KAAK,iBAAiB,CAAC,KAAK;AAC1B,YAAA,OAAO,OAAO;QAChB,KAAK,iBAAiB,CAAC,QAAQ;AAC7B,YAAA,OAAO,UAAU;QACnB,KAAK,iBAAiB,CAAC,QAAQ;AAC7B,YAAA,OAAO,UAAU;AACnB,QAAA;AACE,YAAA,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,KAAK,CAAC;;AAEtD;AAEM,SAAU,gBAAgB,CAAC,IAAe,EAAA;IAC9C,QAAQ,IAAI;AACV,QAAA,KAAK,OAAO;YACV,OAAOA,SAAa,CAAC,KAAK;AAC5B,QAAA,KAAK,QAAQ;YACX,OAAOA,SAAa,CAAC,MAAM;AAC7B,QAAA,KAAK,SAAS;YACZ,OAAOA,SAAa,CAAC,OAAO;AAC9B,QAAA,KAAK,SAAS;YACZ,OAAOA,SAAa,CAAC,OAAO;AAC9B,QAAA,KAAK,KAAK;YACR,OAAOA,SAAa,CAAC,uBAAuB;AAC9C,QAAA,KAAK,KAAK;YACR,OAAOA,SAAa,CAAC,iBAAiB;AACxC,QAAA;AACE,YAAA,OAAO,WAAW,CAAC,IAAI,CAAC;;AAE9B;;;;"}
1
+ {"version":3,"file":"type_conversion.js","names":["GrpcFieldType"],"sources":["../../src/core/type_conversion.ts"],"sourcesContent":["import type {\n Field,\n Resource,\n} from \"../proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types\";\nimport {\n Field_ValueStatus,\n Resource_Kind,\n} from \"../proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types\";\nimport { FieldType as GrpcFieldType } from \"../proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types\";\nimport type {\n FieldData,\n FieldStatus,\n OptionalResourceId,\n FieldType,\n ResourceData,\n ResourceId,\n ResourceKind,\n} from \"./types\";\nimport { NullResourceId } from \"./types\";\nimport { assertNever, notEmpty } from \"@milaboratories/ts-helpers\";\nimport { throwPlNotFoundError } from \"./errors\";\n\nconst ResourceErrorField = \"resourceError\";\n\nfunction resourceIsDeleted(proto: Resource): boolean {\n return proto.deletedTime !== undefined && proto.deletedTime.seconds !== 0n;\n}\n\n/** Throws \"native\" pl not found error, if resource is marked as deleted. */\nexport function protoToResource(proto: Resource): ResourceData {\n if (resourceIsDeleted(proto)) throwPlNotFoundError(\"resource deleted\");\n return {\n id: proto.id as ResourceId,\n originalResourceId: proto.originalResourceId as OptionalResourceId,\n type: notEmpty(proto.type),\n data: proto.data,\n inputsLocked: proto.inputsLocked,\n outputsLocked: proto.outputsLocked,\n resourceReady: proto.resourceReady,\n kind: protoToResourceKind(proto.kind),\n error: protoToError(proto),\n final: proto.isFinal,\n fields: proto.fields?.filter((f) => f.id!.fieldName !== ResourceErrorField).map(protoToField),\n };\n}\n\nfunction protoToResourceKind(proto: Resource_Kind): ResourceKind {\n switch (proto) {\n case Resource_Kind.STRUCTURAL:\n return \"Structural\";\n case Resource_Kind.VALUE:\n return \"Value\";\n }\n\n throw new Error(\"invalid ResourceKind: \" + proto);\n}\n\nfunction protoToError(proto: Resource): OptionalResourceId {\n const f = proto.fields.find((f) => f?.id?.fieldName === ResourceErrorField);\n return (f?.error ?? NullResourceId) as OptionalResourceId;\n}\n\nexport function protoToField(proto: Field): FieldData {\n return {\n name: notEmpty(proto.id?.fieldName),\n type: protoToFieldType(proto.type),\n status: protoToFieldStatus(proto.valueStatus),\n value: proto.value as OptionalResourceId,\n error: proto.error as OptionalResourceId,\n valueIsFinal: proto.valueIsFinal,\n };\n}\n\nfunction protoToFieldType(proto: GrpcFieldType): FieldType {\n switch (proto) {\n case GrpcFieldType.INPUT:\n return \"Input\";\n case GrpcFieldType.OUTPUT:\n return \"Output\";\n case GrpcFieldType.SERVICE:\n return \"Service\";\n case GrpcFieldType.ONE_TIME_WRITABLE:\n return \"OTW\";\n case GrpcFieldType.DYNAMIC:\n return \"Dynamic\";\n case GrpcFieldType.MULTIPLE_TIMES_WRITABLE:\n return \"MTW\";\n default:\n throw new Error(\"invalid FieldType: \" + proto);\n }\n}\n\nfunction protoToFieldStatus(proto: Field_ValueStatus): FieldStatus {\n switch (proto) {\n case Field_ValueStatus.EMPTY:\n return \"Empty\";\n case Field_ValueStatus.ASSIGNED:\n return \"Assigned\";\n case Field_ValueStatus.RESOLVED:\n return \"Resolved\";\n default:\n throw new Error(\"invalid FieldStatus: \" + proto);\n }\n}\n\nexport function fieldTypeToProto(type: FieldType): GrpcFieldType {\n switch (type) {\n case \"Input\":\n return GrpcFieldType.INPUT;\n case \"Output\":\n return GrpcFieldType.OUTPUT;\n case \"Dynamic\":\n return GrpcFieldType.DYNAMIC;\n case \"Service\":\n return GrpcFieldType.SERVICE;\n case \"MTW\":\n return GrpcFieldType.MULTIPLE_TIMES_WRITABLE;\n case \"OTW\":\n return GrpcFieldType.ONE_TIME_WRITABLE;\n default:\n return assertNever(type);\n }\n}\n"],"mappings":";;;;;;;AAsBA,MAAM,qBAAqB;AAE3B,SAAS,kBAAkB,OAA0B;AACnD,QAAO,MAAM,gBAAgB,UAAa,MAAM,YAAY,YAAY;;;AAI1E,SAAgB,gBAAgB,OAA+B;AAC7D,KAAI,kBAAkB,MAAM,CAAE,sBAAqB,mBAAmB;AACtE,QAAO;EACL,IAAI,MAAM;EACV,oBAAoB,MAAM;EAC1B,MAAM,SAAS,MAAM,KAAK;EAC1B,MAAM,MAAM;EACZ,cAAc,MAAM;EACpB,eAAe,MAAM;EACrB,eAAe,MAAM;EACrB,MAAM,oBAAoB,MAAM,KAAK;EACrC,OAAO,aAAa,MAAM;EAC1B,OAAO,MAAM;EACb,QAAQ,MAAM,QAAQ,QAAQ,MAAM,EAAE,GAAI,cAAc,mBAAmB,CAAC,IAAI,aAAa;EAC9F;;AAGH,SAAS,oBAAoB,OAAoC;AAC/D,SAAQ,OAAR;EACE,KAAK,cAAc,WACjB,QAAO;EACT,KAAK,cAAc,MACjB,QAAO;;AAGX,OAAM,IAAI,MAAM,2BAA2B,MAAM;;AAGnD,SAAS,aAAa,OAAqC;AAEzD,QADU,MAAM,OAAO,MAAM,MAAM,GAAG,IAAI,cAAc,mBAAmB,EAChE,SAAS;;AAGtB,SAAgB,aAAa,OAAyB;AACpD,QAAO;EACL,MAAM,SAAS,MAAM,IAAI,UAAU;EACnC,MAAM,iBAAiB,MAAM,KAAK;EAClC,QAAQ,mBAAmB,MAAM,YAAY;EAC7C,OAAO,MAAM;EACb,OAAO,MAAM;EACb,cAAc,MAAM;EACrB;;AAGH,SAAS,iBAAiB,OAAiC;AACzD,SAAQ,OAAR;EACE,KAAKA,UAAc,MACjB,QAAO;EACT,KAAKA,UAAc,OACjB,QAAO;EACT,KAAKA,UAAc,QACjB,QAAO;EACT,KAAKA,UAAc,kBACjB,QAAO;EACT,KAAKA,UAAc,QACjB,QAAO;EACT,KAAKA,UAAc,wBACjB,QAAO;EACT,QACE,OAAM,IAAI,MAAM,wBAAwB,MAAM;;;AAIpD,SAAS,mBAAmB,OAAuC;AACjE,SAAQ,OAAR;EACE,KAAK,kBAAkB,MACrB,QAAO;EACT,KAAK,kBAAkB,SACrB,QAAO;EACT,KAAK,kBAAkB,SACrB,QAAO;EACT,QACE,OAAM,IAAI,MAAM,0BAA0B,MAAM;;;AAItD,SAAgB,iBAAiB,MAAgC;AAC/D,SAAQ,MAAR;EACE,KAAK,QACH,QAAOA,UAAc;EACvB,KAAK,SACH,QAAOA,UAAc;EACvB,KAAK,UACH,QAAOA,UAAc;EACvB,KAAK,UACH,QAAOA,UAAc;EACvB,KAAK,MACH,QAAOA,UAAc;EACvB,KAAK,MACH,QAAOA,UAAc;EACvB,QACE,QAAO,YAAY,KAAK"}
@@ -1,137 +1,107 @@
1
- 'use strict';
2
-
3
- var tsHelpers = require('@milaboratories/ts-helpers');
1
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
+ let _milaboratories_ts_helpers = require("@milaboratories/ts-helpers");
4
3
 
4
+ //#region src/core/types.ts
5
5
  const NullResourceId = 0n;
6
6
  function isNullResourceId(resourceId) {
7
- return resourceId === NullResourceId;
7
+ return resourceId === NullResourceId;
8
8
  }
9
9
  function isNotNullResourceId(resourceId) {
10
- return resourceId !== NullResourceId;
10
+ return resourceId !== NullResourceId;
11
11
  }
12
12
  function ensureResourceIdNotNull(resourceId) {
13
- if (!isNotNullResourceId(resourceId))
14
- throw new Error("null resource id");
15
- return resourceId;
13
+ if (!isNotNullResourceId(resourceId)) throw new Error("null resource id");
14
+ return resourceId;
16
15
  }
17
16
  function isAnyResourceId(resourceId) {
18
- return resourceId !== 0n;
17
+ return resourceId !== 0n;
19
18
  }
20
19
  function resourceType(name, version) {
21
- return { name, version };
20
+ return {
21
+ name,
22
+ version
23
+ };
22
24
  }
23
25
  function resourceTypeToString(rt) {
24
- return `${rt.name}:${rt.version}`;
26
+ return `${rt.name}:${rt.version}`;
25
27
  }
26
28
  function resourceTypesEqual(type1, type2) {
27
- return type1.name === type2.name && type1.version === type2.version;
29
+ return type1.name === type2.name && type1.version === type2.version;
28
30
  }
29
31
  function extractBasicResourceData(rd) {
30
- const { id, originalResourceId, kind, type, data, error, inputsLocked, outputsLocked, resourceReady, final, } = rd;
31
- return {
32
- id,
33
- originalResourceId,
34
- kind,
35
- type,
36
- data,
37
- error,
38
- inputsLocked,
39
- outputsLocked,
40
- resourceReady,
41
- final,
42
- };
32
+ const { id, originalResourceId, kind, type, data, error, inputsLocked, outputsLocked, resourceReady, final } = rd;
33
+ return {
34
+ id,
35
+ originalResourceId,
36
+ kind,
37
+ type,
38
+ data,
39
+ error,
40
+ inputsLocked,
41
+ outputsLocked,
42
+ resourceReady,
43
+ final
44
+ };
43
45
  }
44
46
  const jsonToData = (data) => Buffer.from(JSON.stringify(data));
45
- const resDataToJson = (res) => tsHelpers.cachedDeserialize(tsHelpers.notEmpty(res.data));
47
+ const resDataToJson = (res) => (0, _milaboratories_ts_helpers.cachedDeserialize)((0, _milaboratories_ts_helpers.notEmpty)(res.data));
46
48
  function getField(r, name) {
47
- return tsHelpers.notEmpty(r.fields.find((f) => f.name === name));
48
- }
49
- //
50
- // Local / Global ResourceId arithmetics
51
- //
52
- // Note: txId and other numerical values are made numbers but not bigint intentionally,
53
- // after implementing security model based on signed resource ids this will make
54
- // much more sense
49
+ return (0, _milaboratories_ts_helpers.notEmpty)(r.fields.find((f) => f.name === name));
50
+ }
55
51
  const ResourceIdRootMask = 1n << 63n;
56
52
  const ResourceIdLocalMask = 1n << 62n;
57
- const NoFlagsIdMask = 0x3fffffffffffffffn;
53
+ const NoFlagsIdMask = 4611686018427387903n;
58
54
  const LocalResourceIdTxIdOffset = 24n;
59
- const MaxLocalId = 0xffffff;
60
- const MaxTxId = 0xffffffff;
55
+ const MaxLocalId = 16777215;
56
+ const MaxTxId = 4294967295;
61
57
  /** Mask valid after applying shift */
62
58
  const TxIdMask = BigInt(MaxTxId);
63
59
  const LocalIdMask = BigInt(MaxLocalId);
64
- // /** Basically removes embedded tx id */
65
- // const LocalIdCleanMask = 0xFF00000000FFFFFFn;
66
60
  function isRootResourceId(id) {
67
- return (id & ResourceIdRootMask) !== 0n;
61
+ return (id & ResourceIdRootMask) !== 0n;
68
62
  }
69
63
  function isLocalResourceId(id) {
70
- return (id & ResourceIdLocalMask) !== 0n;
64
+ return (id & ResourceIdLocalMask) !== 0n;
71
65
  }
72
66
  function createLocalResourceId(isRoot, localCounterValue, localTxId) {
73
- if (localCounterValue > MaxLocalId ||
74
- localTxId > MaxTxId ||
75
- localCounterValue < 0 ||
76
- localTxId <= 0)
77
- throw Error("wrong local id or tx id");
78
- return ((isRoot ? ResourceIdRootMask : 0n) |
79
- ResourceIdLocalMask |
80
- BigInt(localCounterValue) |
81
- (BigInt(localTxId) << LocalResourceIdTxIdOffset));
67
+ if (localCounterValue > MaxLocalId || localTxId > MaxTxId || localCounterValue < 0 || localTxId <= 0) throw Error("wrong local id or tx id");
68
+ return (isRoot ? ResourceIdRootMask : 0n) | ResourceIdLocalMask | BigInt(localCounterValue) | BigInt(localTxId) << LocalResourceIdTxIdOffset;
82
69
  }
83
70
  function createGlobalResourceId(isRoot, unmaskedId) {
84
- return ((isRoot ? ResourceIdRootMask : 0n) | unmaskedId);
71
+ return (isRoot ? ResourceIdRootMask : 0n) | unmaskedId;
85
72
  }
86
73
  function extractTxId(localResourceId) {
87
- return Number((localResourceId >> LocalResourceIdTxIdOffset) & TxIdMask);
74
+ return Number(localResourceId >> LocalResourceIdTxIdOffset & TxIdMask);
88
75
  }
89
76
  function checkLocalityOfResourceId(resourceId, expectedTxId) {
90
- if (!isLocalResourceId(resourceId))
91
- return;
92
- if (extractTxId(resourceId) !== expectedTxId)
93
- throw Error("local id from another transaction, globalize id before leaking it from the transaction");
77
+ if (!isLocalResourceId(resourceId)) return;
78
+ if (extractTxId(resourceId) !== expectedTxId) throw Error("local id from another transaction, globalize id before leaking it from the transaction");
94
79
  }
95
80
  function resourceIdToString(resourceId) {
96
- if (isNullResourceId(resourceId))
97
- return "XX:0x0";
98
- if (isLocalResourceId(resourceId))
99
- return ((isRootResourceId(resourceId) ? "R" : "N") +
100
- "L:0x" +
101
- (LocalIdMask & resourceId).toString(16) +
102
- "[0x" +
103
- extractTxId(resourceId).toString(16) +
104
- "]");
105
- else
106
- return ((isRootResourceId(resourceId) ? "R" : "N") +
107
- "G:0x" +
108
- (NoFlagsIdMask & resourceId).toString(16));
81
+ if (isNullResourceId(resourceId)) return "XX:0x0";
82
+ if (isLocalResourceId(resourceId)) return (isRootResourceId(resourceId) ? "R" : "N") + "L:0x" + (LocalIdMask & resourceId).toString(16) + "[0x" + extractTxId(resourceId).toString(16) + "]";
83
+ else return (isRootResourceId(resourceId) ? "R" : "N") + "G:0x" + (NoFlagsIdMask & resourceId).toString(16);
109
84
  }
110
85
  const resourceIdRegexp = /^(?:(?<xx>XX)|(?<rn>[XRN])(?<lg>[XLG])):0x(?<rid>[0-9a-fA-F]+)(?:\[0x(?<txid>[0-9a-fA-F]+)])?$/;
111
86
  function resourceIdFromString(str) {
112
- const match = str.match(resourceIdRegexp);
113
- if (match === null)
114
- return undefined;
115
- const { xx, rn, lg, rid, txid } = match.groups;
116
- if (xx)
117
- return NullResourceId;
118
- if (lg === "L")
119
- return createLocalResourceId(rn === "R", Number.parseInt(rid, 16), Number.parseInt(txid, 16));
120
- else
121
- return createGlobalResourceId(rn === "R", BigInt("0x" + rid));
87
+ const match = str.match(resourceIdRegexp);
88
+ if (match === null) return void 0;
89
+ const { xx, rn, lg, rid, txid } = match.groups;
90
+ if (xx) return NullResourceId;
91
+ if (lg === "L") return createLocalResourceId(rn === "R", Number.parseInt(rid, 16), Number.parseInt(txid, 16));
92
+ else return createGlobalResourceId(rn === "R", BigInt("0x" + rid));
122
93
  }
123
94
  /** Converts bigint to global resource id */
124
95
  function bigintToResourceId(resourceId) {
125
- if (isLocalResourceId(resourceId))
126
- throw new Error(`Local resource id: ${resourceIdToString(resourceId)}`);
127
- if (isNullResourceId(resourceId))
128
- throw new Error(`Null resource id.`);
129
- return resourceId;
96
+ if (isLocalResourceId(resourceId)) throw new Error(`Local resource id: ${resourceIdToString(resourceId)}`);
97
+ if (isNullResourceId(resourceId)) throw new Error(`Null resource id.`);
98
+ return resourceId;
130
99
  }
131
100
  function stringifyWithResourceId(object) {
132
- return JSON.stringify(object, (key, value) => typeof value === "bigint" ? resourceIdToString(value) : value);
101
+ return JSON.stringify(object, (key, value) => typeof value === "bigint" ? resourceIdToString(value) : value);
133
102
  }
134
103
 
104
+ //#endregion
135
105
  exports.MaxLocalId = MaxLocalId;
136
106
  exports.MaxTxId = MaxTxId;
137
107
  exports.NullResourceId = NullResourceId;
@@ -156,4 +126,4 @@ exports.resourceType = resourceType;
156
126
  exports.resourceTypeToString = resourceTypeToString;
157
127
  exports.resourceTypesEqual = resourceTypesEqual;
158
128
  exports.stringifyWithResourceId = stringifyWithResourceId;
159
- //# sourceMappingURL=types.cjs.map
129
+ //# sourceMappingURL=types.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.cjs","sources":["../../src/core/types.ts"],"sourcesContent":["import { cachedDeserialize, notEmpty } from \"@milaboratories/ts-helpers\";\n\n// more details here: https://egghead.io/blog/using-branded-types-in-typescript\ndeclare const __resource_id_type__: unique symbol;\ntype BrandResourceId<B> = bigint & { [__resource_id_type__]: B };\n\n/** Global resource id */\nexport type ResourceId = BrandResourceId<\"global\">;\n\n/** Null resource id */\nexport type NullResourceId = BrandResourceId<\"null\">;\n\n/** Local resource id */\nexport type LocalResourceId = BrandResourceId<\"local\">;\n\n/** Any non-null resource id */\nexport type AnyResourceId = ResourceId | LocalResourceId;\n\n/** Any resource id */\nexport type OptionalResourceId = NullResourceId | ResourceId;\n\n/** All possible resource flavours */\nexport type OptionalAnyResourceId = NullResourceId | ResourceId | LocalResourceId;\n\nexport const NullResourceId = 0n as NullResourceId;\n\nexport function isNullResourceId(resourceId: bigint): resourceId is NullResourceId {\n return resourceId === NullResourceId;\n}\n\nexport function isNotNullResourceId(resourceId: OptionalResourceId): resourceId is ResourceId {\n return resourceId !== NullResourceId;\n}\n\nexport function ensureResourceIdNotNull(resourceId: OptionalResourceId): ResourceId {\n if (!isNotNullResourceId(resourceId)) throw new Error(\"null resource id\");\n return resourceId;\n}\n\nexport function isAnyResourceId(resourceId: bigint): resourceId is AnyResourceId {\n return resourceId !== 0n;\n}\n\n// see local / global resource logic below...\n\nexport type ResourceKind = \"Structural\" | \"Value\";\n\nexport type FieldType = \"Input\" | \"Output\" | \"Service\" | \"OTW\" | \"Dynamic\" | \"MTW\";\n\nexport type FutureFieldType = \"Output\" | \"Input\" | \"Service\";\n\nexport type FieldStatus = \"Empty\" | \"Assigned\" | \"Resolved\";\n\nexport interface ResourceType {\n readonly name: string;\n readonly version: string;\n}\n\nexport function resourceType(name: string, version: string): ResourceType {\n return { name, version };\n}\n\nexport function resourceTypeToString(rt: ResourceType): string {\n return `${rt.name}:${rt.version}`;\n}\n\nexport function resourceTypesEqual(type1: ResourceType, type2: ResourceType): boolean {\n return type1.name === type2.name && type1.version === type2.version;\n}\n\n/** Readonly fields here marks properties of resource that can't change according to pl's state machine. */\nexport type BasicResourceData = {\n readonly id: ResourceId;\n readonly originalResourceId: OptionalResourceId;\n\n readonly kind: ResourceKind;\n readonly type: ResourceType;\n\n readonly data?: Uint8Array;\n\n readonly error: OptionalResourceId;\n\n readonly inputsLocked: boolean;\n readonly outputsLocked: boolean;\n readonly resourceReady: boolean;\n\n /** This value is derived from resource state by the server and can be used as\n * a robust criteria to determine resource is in final state. */\n readonly final: boolean;\n};\n\nexport function extractBasicResourceData(rd: ResourceData): BasicResourceData {\n const {\n id,\n originalResourceId,\n kind,\n type,\n data,\n error,\n inputsLocked,\n outputsLocked,\n resourceReady,\n final,\n } = rd;\n return {\n id,\n originalResourceId,\n kind,\n type,\n data,\n error,\n inputsLocked,\n outputsLocked,\n resourceReady,\n final,\n };\n}\n\nexport const jsonToData = (data: unknown) => Buffer.from(JSON.stringify(data));\n\nexport const resDataToJson = (res: ResourceData) => cachedDeserialize(notEmpty(res.data));\n\nexport type ResourceData = BasicResourceData & {\n readonly fields: FieldData[];\n};\n\nexport function getField(r: ResourceData, name: string): FieldData {\n return notEmpty(r.fields.find((f) => f.name === name));\n}\n\nexport type FieldData = {\n readonly name: string;\n readonly type: FieldType;\n readonly status: FieldStatus;\n readonly value: OptionalResourceId;\n readonly error: OptionalResourceId;\n\n /** True if value the fields points to is in final state. */\n readonly valueIsFinal: boolean;\n};\n\n//\n// Local / Global ResourceId arithmetics\n//\n\n// Note: txId and other numerical values are made numbers but not bigint intentionally,\n// after implementing security model based on signed resource ids this will make\n// much more sense\n\nconst ResourceIdRootMask = 1n << 63n;\nconst ResourceIdLocalMask = 1n << 62n;\nconst NoFlagsIdMask = 0x3fffffffffffffffn;\nconst LocalResourceIdTxIdOffset = 24n;\nexport const MaxLocalId = 0xffffff;\nexport const MaxTxId = 0xffffffff;\n/** Mask valid after applying shift */\nconst TxIdMask = BigInt(MaxTxId);\nconst LocalIdMask = BigInt(MaxLocalId);\n\n// /** Basically removes embedded tx id */\n// const LocalIdCleanMask = 0xFF00000000FFFFFFn;\n\nexport function isRootResourceId(id: bigint) {\n return (id & ResourceIdRootMask) !== 0n;\n}\n\nexport function isLocalResourceId(id: bigint): id is LocalResourceId {\n return (id & ResourceIdLocalMask) !== 0n;\n}\n\nexport function createLocalResourceId(\n isRoot: boolean,\n localCounterValue: number,\n localTxId: number,\n): LocalResourceId {\n if (\n localCounterValue > MaxLocalId ||\n localTxId > MaxTxId ||\n localCounterValue < 0 ||\n localTxId <= 0\n )\n throw Error(\"wrong local id or tx id\");\n return ((isRoot ? ResourceIdRootMask : 0n) |\n ResourceIdLocalMask |\n BigInt(localCounterValue) |\n (BigInt(localTxId) << LocalResourceIdTxIdOffset)) as LocalResourceId;\n}\n\nexport function createGlobalResourceId(isRoot: boolean, unmaskedId: bigint): ResourceId {\n return ((isRoot ? ResourceIdRootMask : 0n) | unmaskedId) as ResourceId;\n}\n\nexport function extractTxId(localResourceId: LocalResourceId): number {\n return Number((localResourceId >> LocalResourceIdTxIdOffset) & TxIdMask);\n}\n\nexport function checkLocalityOfResourceId(resourceId: AnyResourceId, expectedTxId: number): void {\n if (!isLocalResourceId(resourceId)) return;\n if (extractTxId(resourceId) !== expectedTxId)\n throw Error(\n \"local id from another transaction, globalize id before leaking it from the transaction\",\n );\n}\n\nexport function resourceIdToString(resourceId: OptionalAnyResourceId): string {\n if (isNullResourceId(resourceId)) return \"XX:0x0\";\n if (isLocalResourceId(resourceId))\n return (\n (isRootResourceId(resourceId) ? \"R\" : \"N\") +\n \"L:0x\" +\n (LocalIdMask & resourceId).toString(16) +\n \"[0x\" +\n extractTxId(resourceId).toString(16) +\n \"]\"\n );\n else\n return (\n (isRootResourceId(resourceId) ? \"R\" : \"N\") +\n \"G:0x\" +\n (NoFlagsIdMask & resourceId).toString(16)\n );\n}\n\nconst resourceIdRegexp =\n /^(?:(?<xx>XX)|(?<rn>[XRN])(?<lg>[XLG])):0x(?<rid>[0-9a-fA-F]+)(?:\\[0x(?<txid>[0-9a-fA-F]+)])?$/;\n\nexport function resourceIdFromString(str: string): OptionalAnyResourceId | undefined {\n const match = str.match(resourceIdRegexp);\n if (match === null) return undefined;\n const { xx, rn, lg, rid, txid } = match.groups!;\n if (xx) return NullResourceId;\n if (lg === \"L\")\n return createLocalResourceId(rn === \"R\", Number.parseInt(rid, 16), Number.parseInt(txid, 16));\n else return createGlobalResourceId(rn === \"R\", BigInt(\"0x\" + rid));\n}\n\n/** Converts bigint to global resource id */\nexport function bigintToResourceId(resourceId: bigint): ResourceId {\n if (isLocalResourceId(resourceId))\n throw new Error(`Local resource id: ${resourceIdToString(resourceId)}`);\n if (isNullResourceId(resourceId)) throw new Error(`Null resource id.`);\n return resourceId as ResourceId;\n}\n\nexport function stringifyWithResourceId(object: unknown): string {\n return JSON.stringify(object, (key, value) =>\n typeof value === \"bigint\" ? resourceIdToString(value as OptionalAnyResourceId) : value,\n );\n}\n"],"names":["cachedDeserialize","notEmpty"],"mappings":";;;;AAwBO,MAAM,cAAc,GAAG;AAExB,SAAU,gBAAgB,CAAC,UAAkB,EAAA;IACjD,OAAO,UAAU,KAAK,cAAc;AACtC;AAEM,SAAU,mBAAmB,CAAC,UAA8B,EAAA;IAChE,OAAO,UAAU,KAAK,cAAc;AACtC;AAEM,SAAU,uBAAuB,CAAC,UAA8B,EAAA;AACpE,IAAA,IAAI,CAAC,mBAAmB,CAAC,UAAU,CAAC;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC;AACzE,IAAA,OAAO,UAAU;AACnB;AAEM,SAAU,eAAe,CAAC,UAAkB,EAAA;IAChD,OAAO,UAAU,KAAK,EAAE;AAC1B;AAiBM,SAAU,YAAY,CAAC,IAAY,EAAE,OAAe,EAAA;AACxD,IAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE;AAC1B;AAEM,SAAU,oBAAoB,CAAC,E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,UAAU,CAAC,CAAA,CAAE,CAAC;IACzE,IAAI,gBAAgB,CAAC,UAAU,CAAC;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,CAAA,iBAAA,CAAmB,CAAC;AACtE,IAAA,OAAO,UAAwB;AACjC;AAEM,SAAU,uBAAuB,CAAC,MAAe,EAAA;AACrD,IAAA,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,KAAK,KACvC,OAAO,KAAK,KAAK,QAAQ,GAAG,kBAAkB,CAAC,KAA8B,CAAC,GAAG,KAAK,CACvF;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"types.cjs","names":[],"sources":["../../src/core/types.ts"],"sourcesContent":["import { cachedDeserialize, notEmpty } from \"@milaboratories/ts-helpers\";\n\n// more details here: https://egghead.io/blog/using-branded-types-in-typescript\ndeclare const __resource_id_type__: unique symbol;\ntype BrandResourceId<B> = bigint & { [__resource_id_type__]: B };\n\n/** Global resource id */\nexport type ResourceId = BrandResourceId<\"global\">;\n\n/** Null resource id */\nexport type NullResourceId = BrandResourceId<\"null\">;\n\n/** Local resource id */\nexport type LocalResourceId = BrandResourceId<\"local\">;\n\n/** Any non-null resource id */\nexport type AnyResourceId = ResourceId | LocalResourceId;\n\n/** Any resource id */\nexport type OptionalResourceId = NullResourceId | ResourceId;\n\n/** All possible resource flavours */\nexport type OptionalAnyResourceId = NullResourceId | ResourceId | LocalResourceId;\n\nexport const NullResourceId = 0n as NullResourceId;\n\nexport function isNullResourceId(resourceId: bigint): resourceId is NullResourceId {\n return resourceId === NullResourceId;\n}\n\nexport function isNotNullResourceId(resourceId: OptionalResourceId): resourceId is ResourceId {\n return resourceId !== NullResourceId;\n}\n\nexport function ensureResourceIdNotNull(resourceId: OptionalResourceId): ResourceId {\n if (!isNotNullResourceId(resourceId)) throw new Error(\"null resource id\");\n return resourceId;\n}\n\nexport function isAnyResourceId(resourceId: bigint): resourceId is AnyResourceId {\n return resourceId !== 0n;\n}\n\n// see local / global resource logic below...\n\nexport type ResourceKind = \"Structural\" | \"Value\";\n\nexport type FieldType = \"Input\" | \"Output\" | \"Service\" | \"OTW\" | \"Dynamic\" | \"MTW\";\n\nexport type FutureFieldType = \"Output\" | \"Input\" | \"Service\";\n\nexport type FieldStatus = \"Empty\" | \"Assigned\" | \"Resolved\";\n\nexport interface ResourceType {\n readonly name: string;\n readonly version: string;\n}\n\nexport function resourceType(name: string, version: string): ResourceType {\n return { name, version };\n}\n\nexport function resourceTypeToString(rt: ResourceType): string {\n return `${rt.name}:${rt.version}`;\n}\n\nexport function resourceTypesEqual(type1: ResourceType, type2: ResourceType): boolean {\n return type1.name === type2.name && type1.version === type2.version;\n}\n\n/** Readonly fields here marks properties of resource that can't change according to pl's state machine. */\nexport type BasicResourceData = {\n readonly id: ResourceId;\n readonly originalResourceId: OptionalResourceId;\n\n readonly kind: ResourceKind;\n readonly type: ResourceType;\n\n readonly data?: Uint8Array;\n\n readonly error: OptionalResourceId;\n\n readonly inputsLocked: boolean;\n readonly outputsLocked: boolean;\n readonly resourceReady: boolean;\n\n /** This value is derived from resource state by the server and can be used as\n * a robust criteria to determine resource is in final state. */\n readonly final: boolean;\n};\n\nexport function extractBasicResourceData(rd: ResourceData): BasicResourceData {\n const {\n id,\n originalResourceId,\n kind,\n type,\n data,\n error,\n inputsLocked,\n outputsLocked,\n resourceReady,\n final,\n } = rd;\n return {\n id,\n originalResourceId,\n kind,\n type,\n data,\n error,\n inputsLocked,\n outputsLocked,\n resourceReady,\n final,\n };\n}\n\nexport const jsonToData = (data: unknown) => Buffer.from(JSON.stringify(data));\n\nexport const resDataToJson = (res: ResourceData) => cachedDeserialize(notEmpty(res.data));\n\nexport type ResourceData = BasicResourceData & {\n readonly fields: FieldData[];\n};\n\nexport function getField(r: ResourceData, name: string): FieldData {\n return notEmpty(r.fields.find((f) => f.name === name));\n}\n\nexport type FieldData = {\n readonly name: string;\n readonly type: FieldType;\n readonly status: FieldStatus;\n readonly value: OptionalResourceId;\n readonly error: OptionalResourceId;\n\n /** True if value the fields points to is in final state. */\n readonly valueIsFinal: boolean;\n};\n\n//\n// Local / Global ResourceId arithmetics\n//\n\n// Note: txId and other numerical values are made numbers but not bigint intentionally,\n// after implementing security model based on signed resource ids this will make\n// much more sense\n\nconst ResourceIdRootMask = 1n << 63n;\nconst ResourceIdLocalMask = 1n << 62n;\nconst NoFlagsIdMask = 0x3fffffffffffffffn;\nconst LocalResourceIdTxIdOffset = 24n;\nexport const MaxLocalId = 0xffffff;\nexport const MaxTxId = 0xffffffff;\n/** Mask valid after applying shift */\nconst TxIdMask = BigInt(MaxTxId);\nconst LocalIdMask = BigInt(MaxLocalId);\n\n// /** Basically removes embedded tx id */\n// const LocalIdCleanMask = 0xFF00000000FFFFFFn;\n\nexport function isRootResourceId(id: bigint) {\n return (id & ResourceIdRootMask) !== 0n;\n}\n\nexport function isLocalResourceId(id: bigint): id is LocalResourceId {\n return (id & ResourceIdLocalMask) !== 0n;\n}\n\nexport function createLocalResourceId(\n isRoot: boolean,\n localCounterValue: number,\n localTxId: number,\n): LocalResourceId {\n if (\n localCounterValue > MaxLocalId ||\n localTxId > MaxTxId ||\n localCounterValue < 0 ||\n localTxId <= 0\n )\n throw Error(\"wrong local id or tx id\");\n return ((isRoot ? ResourceIdRootMask : 0n) |\n ResourceIdLocalMask |\n BigInt(localCounterValue) |\n (BigInt(localTxId) << LocalResourceIdTxIdOffset)) as LocalResourceId;\n}\n\nexport function createGlobalResourceId(isRoot: boolean, unmaskedId: bigint): ResourceId {\n return ((isRoot ? ResourceIdRootMask : 0n) | unmaskedId) as ResourceId;\n}\n\nexport function extractTxId(localResourceId: LocalResourceId): number {\n return Number((localResourceId >> LocalResourceIdTxIdOffset) & TxIdMask);\n}\n\nexport function checkLocalityOfResourceId(resourceId: AnyResourceId, expectedTxId: number): void {\n if (!isLocalResourceId(resourceId)) return;\n if (extractTxId(resourceId) !== expectedTxId)\n throw Error(\n \"local id from another transaction, globalize id before leaking it from the transaction\",\n );\n}\n\nexport function resourceIdToString(resourceId: OptionalAnyResourceId): string {\n if (isNullResourceId(resourceId)) return \"XX:0x0\";\n if (isLocalResourceId(resourceId))\n return (\n (isRootResourceId(resourceId) ? \"R\" : \"N\") +\n \"L:0x\" +\n (LocalIdMask & resourceId).toString(16) +\n \"[0x\" +\n extractTxId(resourceId).toString(16) +\n \"]\"\n );\n else\n return (\n (isRootResourceId(resourceId) ? \"R\" : \"N\") +\n \"G:0x\" +\n (NoFlagsIdMask & resourceId).toString(16)\n );\n}\n\nconst resourceIdRegexp =\n /^(?:(?<xx>XX)|(?<rn>[XRN])(?<lg>[XLG])):0x(?<rid>[0-9a-fA-F]+)(?:\\[0x(?<txid>[0-9a-fA-F]+)])?$/;\n\nexport function resourceIdFromString(str: string): OptionalAnyResourceId | undefined {\n const match = str.match(resourceIdRegexp);\n if (match === null) return undefined;\n const { xx, rn, lg, rid, txid } = match.groups!;\n if (xx) return NullResourceId;\n if (lg === \"L\")\n return createLocalResourceId(rn === \"R\", Number.parseInt(rid, 16), Number.parseInt(txid, 16));\n else return createGlobalResourceId(rn === \"R\", BigInt(\"0x\" + rid));\n}\n\n/** Converts bigint to global resource id */\nexport function bigintToResourceId(resourceId: bigint): ResourceId {\n if (isLocalResourceId(resourceId))\n throw new Error(`Local resource id: ${resourceIdToString(resourceId)}`);\n if (isNullResourceId(resourceId)) throw new Error(`Null resource id.`);\n return resourceId as ResourceId;\n}\n\nexport function stringifyWithResourceId(object: unknown): string {\n return JSON.stringify(object, (key, value) =>\n typeof value === \"bigint\" ? resourceIdToString(value as OptionalAnyResourceId) : value,\n );\n}\n"],"mappings":";;;;AAwBA,MAAa,iBAAiB;AAE9B,SAAgB,iBAAiB,YAAkD;AACjF,QAAO,eAAe;;AAGxB,SAAgB,oBAAoB,YAA0D;AAC5F,QAAO,eAAe;;AAGxB,SAAgB,wBAAwB,YAA4C;AAClF,KAAI,CAAC,oBAAoB,WAAW,CAAE,OAAM,IAA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 //#region src/core/types.d.ts
1
2
  declare const __resource_id_type__: unique symbol;
2
3
  type BrandResourceId<B> = bigint & {
3
- [__resource_id_type__]: B;
4
+ [__resource_id_type__]: B;
4
5
  };
5
6
  /** Global resource id */
6
- export type ResourceId = BrandResourceId<"global">;
7
+ type ResourceId = BrandResourceId<"global">;
7
8
  /** Null resource id */
8
- export type NullResourceId = BrandResourceId<"null">;
9
+ type NullResourceId = BrandResourceId<"null">;
9
10
  /** Local resource id */
10
- export type LocalResourceId = BrandResourceId<"local">;
11
+ type LocalResourceId = BrandResourceId<"local">;
11
12
  /** Any non-null resource id */
12
- export type AnyResourceId = ResourceId | LocalResourceId;
13
+ type AnyResourceId = ResourceId | LocalResourceId;
13
14
  /** Any resource id */
14
- export type OptionalResourceId = NullResourceId | ResourceId;
15
+ type OptionalResourceId = NullResourceId | ResourceId;
15
16
  /** All possible resource flavours */
16
- export type OptionalAnyResourceId = NullResourceId | ResourceId | LocalResourceId;
17
- export declare const NullResourceId: NullResourceId;
18
- export declare function isNullResourceId(resourceId: bigint): resourceId is NullResourceId;
19
- export declare function isNotNullResourceId(resourceId: OptionalResourceId): resourceId is ResourceId;
20
- export declare function ensureResourceIdNotNull(resourceId: OptionalResourceId): ResourceId;
21
- export declare function isAnyResourceId(resourceId: bigint): resourceId is AnyResourceId;
22
- export type ResourceKind = "Structural" | "Value";
23
- export type FieldType = "Input" | "Output" | "Service" | "OTW" | "Dynamic" | "MTW";
24
- export type FutureFieldType = "Output" | "Input" | "Service";
25
- export type FieldStatus = "Empty" | "Assigned" | "Resolved";
26
- export interface ResourceType {
27
- readonly name: string;
28
- readonly version: string;
17
+ type OptionalAnyResourceId = NullResourceId | ResourceId | LocalResourceId;
18
+ declare const NullResourceId: NullResourceId;
19
+ declare function isNullResourceId(resourceId: bigint): resourceId is NullResourceId;
20
+ declare function isNotNullResourceId(resourceId: OptionalResourceId): resourceId is ResourceId;
21
+ declare function ensureResourceIdNotNull(resourceId: OptionalResourceId): ResourceId;
22
+ declare function isAnyResourceId(resourceId: bigint): resourceId is AnyResourceId;
23
+ type ResourceKind = "Structural" | "Value";
24
+ type FieldType = "Input" | "Output" | "Service" | "OTW" | "Dynamic" | "MTW";
25
+ type FutureFieldType = "Output" | "Input" | "Service";
26
+ type FieldStatus = "Empty" | "Assigned" | "Resolved";
27
+ interface ResourceType {
28
+ readonly name: string;
29
+ readonly version: string;
29
30
  }
30
- export declare function resourceType(name: string, version: string): ResourceType;
31
- export declare function resourceTypeToString(rt: ResourceType): string;
32
- export declare function resourceTypesEqual(type1: ResourceType, type2: ResourceType): boolean;
31
+ declare function resourceType(name: string, version: string): ResourceType;
32
+ declare function resourceTypeToString(rt: ResourceType): string;
33
+ declare function resourceTypesEqual(type1: ResourceType, type2: ResourceType): boolean;
33
34
  /** Readonly fields here marks properties of resource that can't change according to pl's state machine. */
34
- export type BasicResourceData = {
35
- readonly id: ResourceId;
36
- readonly originalResourceId: OptionalResourceId;
37
- readonly kind: ResourceKind;
38
- readonly type: ResourceType;
39
- readonly data?: Uint8Array;
40
- readonly error: OptionalResourceId;
41
- readonly inputsLocked: boolean;
42
- readonly outputsLocked: boolean;
43
- readonly resourceReady: boolean;
44
- /** This value is derived from resource state by the server and can be used as
45
- * a robust criteria to determine resource is in final state. */
46
- readonly final: boolean;
35
+ type BasicResourceData = {
36
+ readonly id: ResourceId;
37
+ readonly originalResourceId: OptionalResourceId;
38
+ readonly kind: ResourceKind;
39
+ readonly type: ResourceType;
40
+ readonly data?: Uint8Array;
41
+ readonly error: OptionalResourceId;
42
+ readonly inputsLocked: boolean;
43
+ readonly outputsLocked: boolean;
44
+ readonly resourceReady: boolean;
45
+ /** This value is derived from resource state by the server and can be used as
46
+ * a robust criteria to determine resource is in final state. */
47
+ readonly final: boolean;
47
48
  };
48
- export declare function extractBasicResourceData(rd: ResourceData): BasicResourceData;
49
- export declare const jsonToData: (data: unknown) => Buffer;
50
- export declare const resDataToJson: (res: ResourceData) => unknown;
51
- export type ResourceData = BasicResourceData & {
52
- readonly fields: FieldData[];
49
+ declare function extractBasicResourceData(rd: ResourceData): BasicResourceData;
50
+ declare const jsonToData: (data: unknown) => Buffer<ArrayBuffer>;
51
+ declare const resDataToJson: (res: ResourceData) => unknown;
52
+ type ResourceData = BasicResourceData & {
53
+ readonly fields: FieldData[];
53
54
  };
54
- export declare function getField(r: ResourceData, name: string): FieldData;
55
- export type FieldData = {
56
- readonly name: string;
57
- readonly type: FieldType;
58
- readonly status: FieldStatus;
59
- readonly value: OptionalResourceId;
60
- readonly error: OptionalResourceId;
61
- /** True if value the fields points to is in final state. */
62
- readonly valueIsFinal: boolean;
55
+ declare function getField(r: ResourceData, name: string): FieldData;
56
+ type FieldData = {
57
+ readonly name: string;
58
+ readonly type: FieldType;
59
+ readonly status: FieldStatus;
60
+ readonly value: OptionalResourceId;
61
+ readonly error: OptionalResourceId; /** True if value the fields points to is in final state. */
62
+ readonly valueIsFinal: boolean;
63
63
  };
64
- export declare const MaxLocalId = 16777215;
65
- export declare const MaxTxId = 4294967295;
66
- export declare function isRootResourceId(id: bigint): boolean;
67
- export declare function isLocalResourceId(id: bigint): id is LocalResourceId;
68
- export declare function createLocalResourceId(isRoot: boolean, localCounterValue: number, localTxId: number): LocalResourceId;
69
- export declare function createGlobalResourceId(isRoot: boolean, unmaskedId: bigint): ResourceId;
70
- export declare function extractTxId(localResourceId: LocalResourceId): number;
71
- export declare function checkLocalityOfResourceId(resourceId: AnyResourceId, expectedTxId: number): void;
72
- export declare function resourceIdToString(resourceId: OptionalAnyResourceId): string;
73
- export declare function resourceIdFromString(str: string): OptionalAnyResourceId | undefined;
64
+ declare const MaxLocalId = 16777215;
65
+ declare const MaxTxId = 4294967295;
66
+ declare function isRootResourceId(id: bigint): boolean;
67
+ declare function isLocalResourceId(id: bigint): id is LocalResourceId;
68
+ declare function createLocalResourceId(isRoot: boolean, localCounterValue: number, localTxId: number): LocalResourceId;
69
+ declare function createGlobalResourceId(isRoot: boolean, unmaskedId: bigint): ResourceId;
70
+ declare function extractTxId(localResourceId: LocalResourceId): number;
71
+ declare function checkLocalityOfResourceId(resourceId: AnyResourceId, expectedTxId: number): void;
72
+ declare function resourceIdToString(resourceId: OptionalAnyResourceId): string;
73
+ declare function resourceIdFromString(str: string): OptionalAnyResourceId | undefined;
74
74
  /** Converts bigint to global resource id */
75
- export declare function bigintToResourceId(resourceId: bigint): ResourceId;
76
- export declare function stringifyWithResourceId(object: unknown): string;
77
- export {};
75
+ declare function bigintToResourceId(resourceId: bigint): ResourceId;
76
+ declare function stringifyWithResourceId(object: unknown): string;
77
+ //#endregion
78
+ export { AnyResourceId, BasicResourceData, FieldData, FieldStatus, FieldType, FutureFieldType, LocalResourceId, MaxLocalId, MaxTxId, NullResourceId, OptionalAnyResourceId, OptionalResourceId, ResourceData, ResourceId, ResourceKind, ResourceType, bigintToResourceId, checkLocalityOfResourceId, createGlobalResourceId, createLocalResourceId, ensureResourceIdNotNull, extractBasicResourceData, extractTxId, getField, isAnyResourceId, isLocalResourceId, isNotNullResourceId, isNullResourceId, isRootResourceId, jsonToData, resDataToJson, resourceIdFromString, resourceIdToString, resourceType, resourceTypeToString, resourceTypesEqual, stringifyWithResourceId };
78
79
  //# sourceMappingURL=types.d.ts.map
@@ -1,134 +1,105 @@
1
- import { cachedDeserialize, notEmpty } from '@milaboratories/ts-helpers';
1
+ import { cachedDeserialize, notEmpty } from "@milaboratories/ts-helpers";
2
2
 
3
+ //#region src/core/types.ts
3
4
  const NullResourceId = 0n;
4
5
  function isNullResourceId(resourceId) {
5
- return resourceId === NullResourceId;
6
+ return resourceId === NullResourceId;
6
7
  }
7
8
  function isNotNullResourceId(resourceId) {
8
- return resourceId !== NullResourceId;
9
+ return resourceId !== NullResourceId;
9
10
  }
10
11
  function ensureResourceIdNotNull(resourceId) {
11
- if (!isNotNullResourceId(resourceId))
12
- throw new Error("null resource id");
13
- return resourceId;
12
+ if (!isNotNullResourceId(resourceId)) throw new Error("null resource id");
13
+ return resourceId;
14
14
  }
15
15
  function isAnyResourceId(resourceId) {
16
- return resourceId !== 0n;
16
+ return resourceId !== 0n;
17
17
  }
18
18
  function resourceType(name, version) {
19
- return { name, version };
19
+ return {
20
+ name,
21
+ version
22
+ };
20
23
  }
21
24
  function resourceTypeToString(rt) {
22
- return `${rt.name}:${rt.version}`;
25
+ return `${rt.name}:${rt.version}`;
23
26
  }
24
27
  function resourceTypesEqual(type1, type2) {
25
- return type1.name === type2.name && type1.version === type2.version;
28
+ return type1.name === type2.name && type1.version === type2.version;
26
29
  }
27
30
  function extractBasicResourceData(rd) {
28
- const { id, originalResourceId, kind, type, data, error, inputsLocked, outputsLocked, resourceReady, final, } = rd;
29
- return {
30
- id,
31
- originalResourceId,
32
- kind,
33
- type,
34
- data,
35
- error,
36
- inputsLocked,
37
- outputsLocked,
38
- resourceReady,
39
- final,
40
- };
31
+ const { id, originalResourceId, kind, type, data, error, inputsLocked, outputsLocked, resourceReady, final } = rd;
32
+ return {
33
+ id,
34
+ originalResourceId,
35
+ kind,
36
+ type,
37
+ data,
38
+ error,
39
+ inputsLocked,
40
+ outputsLocked,
41
+ resourceReady,
42
+ final
43
+ };
41
44
  }
42
45
  const jsonToData = (data) => Buffer.from(JSON.stringify(data));
43
46
  const resDataToJson = (res) => cachedDeserialize(notEmpty(res.data));
44
47
  function getField(r, name) {
45
- return notEmpty(r.fields.find((f) => f.name === name));
46
- }
47
- //
48
- // Local / Global ResourceId arithmetics
49
- //
50
- // Note: txId and other numerical values are made numbers but not bigint intentionally,
51
- // after implementing security model based on signed resource ids this will make
52
- // much more sense
48
+ return notEmpty(r.fields.find((f) => f.name === name));
49
+ }
53
50
  const ResourceIdRootMask = 1n << 63n;
54
51
  const ResourceIdLocalMask = 1n << 62n;
55
- const NoFlagsIdMask = 0x3fffffffffffffffn;
52
+ const NoFlagsIdMask = 4611686018427387903n;
56
53
  const LocalResourceIdTxIdOffset = 24n;
57
- const MaxLocalId = 0xffffff;
58
- const MaxTxId = 0xffffffff;
54
+ const MaxLocalId = 16777215;
55
+ const MaxTxId = 4294967295;
59
56
  /** Mask valid after applying shift */
60
57
  const TxIdMask = BigInt(MaxTxId);
61
58
  const LocalIdMask = BigInt(MaxLocalId);
62
- // /** Basically removes embedded tx id */
63
- // const LocalIdCleanMask = 0xFF00000000FFFFFFn;
64
59
  function isRootResourceId(id) {
65
- return (id & ResourceIdRootMask) !== 0n;
60
+ return (id & ResourceIdRootMask) !== 0n;
66
61
  }
67
62
  function isLocalResourceId(id) {
68
- return (id & ResourceIdLocalMask) !== 0n;
63
+ return (id & ResourceIdLocalMask) !== 0n;
69
64
  }
70
65
  function createLocalResourceId(isRoot, localCounterValue, localTxId) {
71
- if (localCounterValue > MaxLocalId ||
72
- localTxId > MaxTxId ||
73
- localCounterValue < 0 ||
74
- localTxId <= 0)
75
- throw Error("wrong local id or tx id");
76
- return ((isRoot ? ResourceIdRootMask : 0n) |
77
- ResourceIdLocalMask |
78
- BigInt(localCounterValue) |
79
- (BigInt(localTxId) << LocalResourceIdTxIdOffset));
66
+ if (localCounterValue > MaxLocalId || localTxId > MaxTxId || localCounterValue < 0 || localTxId <= 0) throw Error("wrong local id or tx id");
67
+ return (isRoot ? ResourceIdRootMask : 0n) | ResourceIdLocalMask | BigInt(localCounterValue) | BigInt(localTxId) << LocalResourceIdTxIdOffset;
80
68
  }
81
69
  function createGlobalResourceId(isRoot, unmaskedId) {
82
- return ((isRoot ? ResourceIdRootMask : 0n) | unmaskedId);
70
+ return (isRoot ? ResourceIdRootMask : 0n) | unmaskedId;
83
71
  }
84
72
  function extractTxId(localResourceId) {
85
- return Number((localResourceId >> LocalResourceIdTxIdOffset) & TxIdMask);
73
+ return Number(localResourceId >> LocalResourceIdTxIdOffset & TxIdMask);
86
74
  }
87
75
  function checkLocalityOfResourceId(resourceId, expectedTxId) {
88
- if (!isLocalResourceId(resourceId))
89
- return;
90
- if (extractTxId(resourceId) !== expectedTxId)
91
- throw Error("local id from another transaction, globalize id before leaking it from the transaction");
76
+ if (!isLocalResourceId(resourceId)) return;
77
+ if (extractTxId(resourceId) !== expectedTxId) throw Error("local id from another transaction, globalize id before leaking it from the transaction");
92
78
  }
93
79
  function resourceIdToString(resourceId) {
94
- if (isNullResourceId(resourceId))
95
- return "XX:0x0";
96
- if (isLocalResourceId(resourceId))
97
- return ((isRootResourceId(resourceId) ? "R" : "N") +
98
- "L:0x" +
99
- (LocalIdMask & resourceId).toString(16) +
100
- "[0x" +
101
- extractTxId(resourceId).toString(16) +
102
- "]");
103
- else
104
- return ((isRootResourceId(resourceId) ? "R" : "N") +
105
- "G:0x" +
106
- (NoFlagsIdMask & resourceId).toString(16));
80
+ if (isNullResourceId(resourceId)) return "XX:0x0";
81
+ if (isLocalResourceId(resourceId)) return (isRootResourceId(resourceId) ? "R" : "N") + "L:0x" + (LocalIdMask & resourceId).toString(16) + "[0x" + extractTxId(resourceId).toString(16) + "]";
82
+ else return (isRootResourceId(resourceId) ? "R" : "N") + "G:0x" + (NoFlagsIdMask & resourceId).toString(16);
107
83
  }
108
84
  const resourceIdRegexp = /^(?:(?<xx>XX)|(?<rn>[XRN])(?<lg>[XLG])):0x(?<rid>[0-9a-fA-F]+)(?:\[0x(?<txid>[0-9a-fA-F]+)])?$/;
109
85
  function resourceIdFromString(str) {
110
- const match = str.match(resourceIdRegexp);
111
- if (match === null)
112
- return undefined;
113
- const { xx, rn, lg, rid, txid } = match.groups;
114
- if (xx)
115
- return NullResourceId;
116
- if (lg === "L")
117
- return createLocalResourceId(rn === "R", Number.parseInt(rid, 16), Number.parseInt(txid, 16));
118
- else
119
- return createGlobalResourceId(rn === "R", BigInt("0x" + rid));
86
+ const match = str.match(resourceIdRegexp);
87
+ if (match === null) return void 0;
88
+ const { xx, rn, lg, rid, txid } = match.groups;
89
+ if (xx) return NullResourceId;
90
+ if (lg === "L") return createLocalResourceId(rn === "R", Number.parseInt(rid, 16), Number.parseInt(txid, 16));
91
+ else return createGlobalResourceId(rn === "R", BigInt("0x" + rid));
120
92
  }
121
93
  /** Converts bigint to global resource id */
122
94
  function bigintToResourceId(resourceId) {
123
- if (isLocalResourceId(resourceId))
124
- throw new Error(`Local resource id: ${resourceIdToString(resourceId)}`);
125
- if (isNullResourceId(resourceId))
126
- throw new Error(`Null resource id.`);
127
- return resourceId;
95
+ if (isLocalResourceId(resourceId)) throw new Error(`Local resource id: ${resourceIdToString(resourceId)}`);
96
+ if (isNullResourceId(resourceId)) throw new Error(`Null resource id.`);
97
+ return resourceId;
128
98
  }
129
99
  function stringifyWithResourceId(object) {
130
- return JSON.stringify(object, (key, value) => typeof value === "bigint" ? resourceIdToString(value) : value);
100
+ return JSON.stringify(object, (key, value) => typeof value === "bigint" ? resourceIdToString(value) : value);
131
101
  }
132
102
 
103
+ //#endregion
133
104
  export { MaxLocalId, MaxTxId, NullResourceId, bigintToResourceId, checkLocalityOfResourceId, createGlobalResourceId, createLocalResourceId, ensureResourceIdNotNull, extractBasicResourceData, extractTxId, getField, isAnyResourceId, isLocalResourceId, isNotNullResourceId, isNullResourceId, isRootResourceId, jsonToData, resDataToJson, resourceIdFromString, resourceIdToString, resourceType, resourceTypeToString, resourceTypesEqual, stringifyWithResourceId };
134
- //# sourceMappingURL=types.js.map
105
+ //# sourceMappingURL=types.js.map