@milaboratories/pl-client 2.16.26 → 2.16.28

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 (212) hide show
  1. package/README.md +2 -1
  2. package/dist/core/PromiseTracker.cjs +1 -3
  3. package/dist/core/PromiseTracker.cjs.map +1 -1
  4. package/dist/core/PromiseTracker.d.ts.map +1 -1
  5. package/dist/core/PromiseTracker.js +1 -3
  6. package/dist/core/PromiseTracker.js.map +1 -1
  7. package/dist/core/StatefulPromise.cjs +4 -4
  8. package/dist/core/StatefulPromise.cjs.map +1 -1
  9. package/dist/core/StatefulPromise.d.ts +1 -1
  10. package/dist/core/StatefulPromise.d.ts.map +1 -1
  11. package/dist/core/StatefulPromise.js +4 -4
  12. package/dist/core/StatefulPromise.js.map +1 -1
  13. package/dist/core/advisory_locks.cjs +1 -1
  14. package/dist/core/advisory_locks.cjs.map +1 -1
  15. package/dist/core/advisory_locks.js +1 -1
  16. package/dist/core/advisory_locks.js.map +1 -1
  17. package/dist/core/auth.cjs.map +1 -1
  18. package/dist/core/auth.d.ts +1 -1
  19. package/dist/core/auth.js.map +1 -1
  20. package/dist/core/cache.d.ts +1 -1
  21. package/dist/core/client.cjs +14 -14
  22. package/dist/core/client.cjs.map +1 -1
  23. package/dist/core/client.d.ts +11 -11
  24. package/dist/core/client.d.ts.map +1 -1
  25. package/dist/core/client.js +14 -14
  26. package/dist/core/client.js.map +1 -1
  27. package/dist/core/config.cjs +39 -39
  28. package/dist/core/config.cjs.map +1 -1
  29. package/dist/core/config.d.ts +5 -5
  30. package/dist/core/config.js +39 -39
  31. package/dist/core/config.js.map +1 -1
  32. package/dist/core/default_client.cjs +23 -23
  33. package/dist/core/default_client.cjs.map +1 -1
  34. package/dist/core/default_client.d.ts +3 -3
  35. package/dist/core/default_client.js +23 -23
  36. package/dist/core/default_client.js.map +1 -1
  37. package/dist/core/driver.cjs +1 -1
  38. package/dist/core/driver.cjs.map +1 -1
  39. package/dist/core/driver.d.ts +5 -5
  40. package/dist/core/driver.js +1 -1
  41. package/dist/core/driver.js.map +1 -1
  42. package/dist/core/error_resource.cjs +2 -2
  43. package/dist/core/error_resource.cjs.map +1 -1
  44. package/dist/core/error_resource.d.ts +1 -1
  45. package/dist/core/error_resource.js +2 -2
  46. package/dist/core/error_resource.js.map +1 -1
  47. package/dist/core/errors.cjs +24 -24
  48. package/dist/core/errors.cjs.map +1 -1
  49. package/dist/core/errors.d.ts +1 -1
  50. package/dist/core/errors.d.ts.map +1 -1
  51. package/dist/core/errors.js +24 -24
  52. package/dist/core/errors.js.map +1 -1
  53. package/dist/core/final.cjs +43 -43
  54. package/dist/core/final.cjs.map +1 -1
  55. package/dist/core/final.d.ts +3 -3
  56. package/dist/core/final.d.ts.map +1 -1
  57. package/dist/core/final.js +43 -43
  58. package/dist/core/final.js.map +1 -1
  59. package/dist/core/ll_client.cjs +50 -43
  60. package/dist/core/ll_client.cjs.map +1 -1
  61. package/dist/core/ll_client.d.ts +9 -9
  62. package/dist/core/ll_client.d.ts.map +1 -1
  63. package/dist/core/ll_client.js +50 -43
  64. package/dist/core/ll_client.js.map +1 -1
  65. package/dist/core/ll_transaction.cjs +9 -9
  66. package/dist/core/ll_transaction.cjs.map +1 -1
  67. package/dist/core/ll_transaction.d.ts +7 -7
  68. package/dist/core/ll_transaction.d.ts.map +1 -1
  69. package/dist/core/ll_transaction.js +9 -9
  70. package/dist/core/ll_transaction.js.map +1 -1
  71. package/dist/core/stat.cjs.map +1 -1
  72. package/dist/core/stat.d.ts +1 -1
  73. package/dist/core/stat.js.map +1 -1
  74. package/dist/core/transaction.cjs +46 -46
  75. package/dist/core/transaction.cjs.map +1 -1
  76. package/dist/core/transaction.d.ts +7 -7
  77. package/dist/core/transaction.d.ts.map +1 -1
  78. package/dist/core/transaction.js +46 -46
  79. package/dist/core/transaction.js.map +1 -1
  80. package/dist/core/type_conversion.cjs +22 -22
  81. package/dist/core/type_conversion.cjs.map +1 -1
  82. package/dist/core/type_conversion.d.ts +3 -3
  83. package/dist/core/type_conversion.d.ts.map +1 -1
  84. package/dist/core/type_conversion.js +22 -22
  85. package/dist/core/type_conversion.js.map +1 -1
  86. package/dist/core/types.cjs +25 -25
  87. package/dist/core/types.cjs.map +1 -1
  88. package/dist/core/types.d.ts +7 -7
  89. package/dist/core/types.js +25 -25
  90. package/dist/core/types.js.map +1 -1
  91. package/dist/core/unauth_client.cjs +6 -4
  92. package/dist/core/unauth_client.cjs.map +1 -1
  93. package/dist/core/unauth_client.d.ts +4 -4
  94. package/dist/core/unauth_client.d.ts.map +1 -1
  95. package/dist/core/unauth_client.js +6 -4
  96. package/dist/core/unauth_client.js.map +1 -1
  97. package/dist/core/websocket_stream.cjs +22 -20
  98. package/dist/core/websocket_stream.cjs.map +1 -1
  99. package/dist/core/websocket_stream.d.ts +3 -3
  100. package/dist/core/websocket_stream.d.ts.map +1 -1
  101. package/dist/core/websocket_stream.js +22 -20
  102. package/dist/core/websocket_stream.js.map +1 -1
  103. package/dist/core/wire.d.ts +6 -6
  104. package/dist/core/wire.d.ts.map +1 -1
  105. package/dist/helpers/pl.cjs +19 -19
  106. package/dist/helpers/pl.cjs.map +1 -1
  107. package/dist/helpers/pl.d.ts +2 -2
  108. package/dist/helpers/pl.js +19 -19
  109. package/dist/helpers/pl.js.map +1 -1
  110. package/dist/helpers/poll.cjs +6 -6
  111. package/dist/helpers/poll.cjs.map +1 -1
  112. package/dist/helpers/poll.d.ts +4 -4
  113. package/dist/helpers/poll.d.ts.map +1 -1
  114. package/dist/helpers/poll.js +6 -6
  115. package/dist/helpers/poll.js.map +1 -1
  116. package/dist/helpers/retry_strategy.cjs +1 -1
  117. package/dist/helpers/retry_strategy.cjs.map +1 -1
  118. package/dist/helpers/retry_strategy.d.ts.map +1 -1
  119. package/dist/helpers/retry_strategy.js +1 -1
  120. package/dist/helpers/retry_strategy.js.map +1 -1
  121. package/dist/helpers/state_helpers.d.ts +2 -2
  122. package/dist/helpers/tx_helpers.cjs +2 -2
  123. package/dist/helpers/tx_helpers.cjs.map +1 -1
  124. package/dist/helpers/tx_helpers.d.ts +2 -2
  125. package/dist/helpers/tx_helpers.d.ts.map +1 -1
  126. package/dist/helpers/tx_helpers.js +2 -2
  127. package/dist/helpers/tx_helpers.js.map +1 -1
  128. package/dist/index.d.ts +16 -16
  129. package/dist/proto-grpc/google/protobuf/struct.d.ts +1 -1
  130. package/dist/proto-grpc/google/protobuf/struct.d.ts.map +1 -1
  131. package/dist/proto-rest/index.cjs +4 -5
  132. package/dist/proto-rest/index.cjs.map +1 -1
  133. package/dist/proto-rest/index.d.ts +4 -4
  134. package/dist/proto-rest/index.d.ts.map +1 -1
  135. package/dist/proto-rest/index.js +4 -5
  136. package/dist/proto-rest/index.js.map +1 -1
  137. package/dist/proto-rest/plapi.d.ts.map +1 -1
  138. package/dist/test/tcp-proxy.cjs +11 -10
  139. package/dist/test/tcp-proxy.cjs.map +1 -1
  140. package/dist/test/tcp-proxy.d.ts +1 -1
  141. package/dist/test/tcp-proxy.d.ts.map +1 -1
  142. package/dist/test/tcp-proxy.js +11 -10
  143. package/dist/test/tcp-proxy.js.map +1 -1
  144. package/dist/test/test_config.cjs +21 -17
  145. package/dist/test/test_config.cjs.map +1 -1
  146. package/dist/test/test_config.d.ts +6 -6
  147. package/dist/test/test_config.d.ts.map +1 -1
  148. package/dist/test/test_config.js +21 -17
  149. package/dist/test/test_config.js.map +1 -1
  150. package/dist/util/pl.cjs +1 -1
  151. package/dist/util/pl.cjs.map +1 -1
  152. package/dist/util/pl.js +1 -1
  153. package/dist/util/pl.js.map +1 -1
  154. package/dist/util/util.cjs +1 -1
  155. package/dist/util/util.cjs.map +1 -1
  156. package/dist/util/util.js +1 -1
  157. package/dist/util/util.js.map +1 -1
  158. package/package.json +23 -23
  159. package/src/core/PromiseTracker.ts +3 -4
  160. package/src/core/StatefulPromise.ts +17 -8
  161. package/src/core/abstract_stream.ts +3 -4
  162. package/src/core/advisory_locks.ts +1 -1
  163. package/src/core/auth.ts +2 -2
  164. package/src/core/cache.ts +1 -1
  165. package/src/core/client.test.ts +25 -21
  166. package/src/core/client.ts +54 -45
  167. package/src/core/config.test.ts +44 -44
  168. package/src/core/config.ts +49 -49
  169. package/src/core/connectivity.test.ts +69 -63
  170. package/src/core/default_client.ts +46 -46
  171. package/src/core/driver.ts +6 -6
  172. package/src/core/error.test.ts +5 -5
  173. package/src/core/error_resource.ts +3 -3
  174. package/src/core/errors.ts +39 -31
  175. package/src/core/final.ts +48 -55
  176. package/src/core/ll_client.test.ts +53 -36
  177. package/src/core/ll_client.ts +125 -81
  178. package/src/core/ll_transaction.test.ts +75 -49
  179. package/src/core/ll_transaction.ts +37 -35
  180. package/src/core/stat.ts +1 -1
  181. package/src/core/transaction.test.ts +65 -65
  182. package/src/core/transaction.ts +91 -84
  183. package/src/core/type_conversion.ts +30 -31
  184. package/src/core/types.test.ts +6 -6
  185. package/src/core/types.ts +35 -35
  186. package/src/core/unauth_client.test.ts +18 -14
  187. package/src/core/unauth_client.ts +14 -12
  188. package/src/core/websocket_stream.test.ts +52 -52
  189. package/src/core/websocket_stream.ts +41 -37
  190. package/src/core/wire.ts +10 -8
  191. package/src/helpers/pl.ts +22 -22
  192. package/src/helpers/poll.ts +13 -27
  193. package/src/helpers/retry_strategy.ts +2 -4
  194. package/src/helpers/rich_resource_types.test.ts +2 -2
  195. package/src/helpers/state_helpers.ts +3 -3
  196. package/src/helpers/tx_helpers.ts +9 -7
  197. package/src/index.ts +16 -16
  198. package/src/proto-grpc/google/protobuf/struct.ts +1 -1
  199. package/src/proto-rest/index.ts +17 -18
  200. package/src/proto-rest/plapi.ts +1472 -1472
  201. package/src/test/tcp-proxy.ts +55 -54
  202. package/src/test/test_config.test.ts +3 -3
  203. package/src/test/test_config.ts +51 -46
  204. package/src/util/pl.ts +1 -1
  205. package/src/util/util.test.ts +5 -5
  206. package/src/util/util.ts +1 -1
  207. package/dist/helpers/rich_resource_types.d.ts +0 -2
  208. package/dist/helpers/rich_resource_types.d.ts.map +0 -1
  209. package/dist/helpers/smart_accessors.d.ts +0 -2
  210. package/dist/helpers/smart_accessors.d.ts.map +0 -1
  211. package/src/helpers/rich_resource_types.ts +0 -84
  212. package/src/helpers/smart_accessors.ts +0 -146
@@ -6,14 +6,14 @@ var types = require('./types.cjs');
6
6
  var tsHelpers = require('@milaboratories/ts-helpers');
7
7
  var errors = require('./errors.cjs');
8
8
 
9
- const ResourceErrorField = 'resourceError';
9
+ const ResourceErrorField = "resourceError";
10
10
  function resourceIsDeleted(proto) {
11
11
  return proto.deletedTime !== undefined && proto.deletedTime.seconds !== 0n;
12
12
  }
13
13
  /** Throws "native" pl not found error, if resource is marked as deleted. */
14
14
  function protoToResource(proto) {
15
15
  if (resourceIsDeleted(proto))
16
- errors.throwPlNotFoundError('resource deleted');
16
+ errors.throwPlNotFoundError("resource deleted");
17
17
  return {
18
18
  id: proto.id,
19
19
  originalResourceId: proto.originalResourceId,
@@ -31,11 +31,11 @@ function protoToResource(proto) {
31
31
  function protoToResourceKind(proto) {
32
32
  switch (proto) {
33
33
  case api_types.Resource_Kind.STRUCTURAL:
34
- return 'Structural';
34
+ return "Structural";
35
35
  case api_types.Resource_Kind.VALUE:
36
- return 'Value';
36
+ return "Value";
37
37
  }
38
- throw new Error('invalid ResourceKind: ' + proto);
38
+ throw new Error("invalid ResourceKind: " + proto);
39
39
  }
40
40
  function protoToError(proto) {
41
41
  const f = proto.fields.find((f) => f?.id?.fieldName === ResourceErrorField);
@@ -54,46 +54,46 @@ function protoToField(proto) {
54
54
  function protoToFieldType(proto) {
55
55
  switch (proto) {
56
56
  case base_types.FieldType.INPUT:
57
- return 'Input';
57
+ return "Input";
58
58
  case base_types.FieldType.OUTPUT:
59
- return 'Output';
59
+ return "Output";
60
60
  case base_types.FieldType.SERVICE:
61
- return 'Service';
61
+ return "Service";
62
62
  case base_types.FieldType.ONE_TIME_WRITABLE:
63
- return 'OTW';
63
+ return "OTW";
64
64
  case base_types.FieldType.DYNAMIC:
65
- return 'Dynamic';
65
+ return "Dynamic";
66
66
  case base_types.FieldType.MULTIPLE_TIMES_WRITABLE:
67
- return 'MTW';
67
+ return "MTW";
68
68
  default:
69
- throw new Error('invalid FieldType: ' + proto);
69
+ throw new Error("invalid FieldType: " + proto);
70
70
  }
71
71
  }
72
72
  function protoToFieldStatus(proto) {
73
73
  switch (proto) {
74
74
  case api_types.Field_ValueStatus.EMPTY:
75
- return 'Empty';
75
+ return "Empty";
76
76
  case api_types.Field_ValueStatus.ASSIGNED:
77
- return 'Assigned';
77
+ return "Assigned";
78
78
  case api_types.Field_ValueStatus.RESOLVED:
79
- return 'Resolved';
79
+ return "Resolved";
80
80
  default:
81
- throw new Error('invalid FieldStatus: ' + proto);
81
+ throw new Error("invalid FieldStatus: " + proto);
82
82
  }
83
83
  }
84
84
  function fieldTypeToProto(type) {
85
85
  switch (type) {
86
- case 'Input':
86
+ case "Input":
87
87
  return base_types.FieldType.INPUT;
88
- case 'Output':
88
+ case "Output":
89
89
  return base_types.FieldType.OUTPUT;
90
- case 'Dynamic':
90
+ case "Dynamic":
91
91
  return base_types.FieldType.DYNAMIC;
92
- case 'Service':
92
+ case "Service":
93
93
  return base_types.FieldType.SERVICE;
94
- case 'MTW':
94
+ case "MTW":
95
95
  return base_types.FieldType.MULTIPLE_TIMES_WRITABLE;
96
- case 'OTW':
96
+ case "OTW":
97
97
  return base_types.FieldType.ONE_TIME_WRITABLE;
98
98
  default:
99
99
  return tsHelpers.assertNever(type);
@@ -1 +1 @@
1
- {"version":3,"file":"type_conversion.cjs","sources":["../../src/core/type_conversion.ts"],"sourcesContent":["import type {\n Field,\n Resource } 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 {\n NullResourceId,\n} 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":["throwPlNotFoundError","notEmpty","Resource_Kind","NullResourceId","GrpcFieldType","Field_ValueStatus","assertNever"],"mappings":";;;;;;;;AAuBA,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;QAAEA,2BAAoB,CAAC,kBAAkB,CAAC;IACtE,OAAO;QACL,EAAE,EAAE,KAAK,CAAC,EAAgB;QAC1B,kBAAkB,EAAE,KAAK,CAAC,kBAAwC;AAClE,QAAA,IAAI,EAAEC,kBAAQ,CAAC,KAAK,CAAC,IAAI,CAAC;QAC1B,IAAI,EAAE,KAAK,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iBAAiB;AACxC,QAAA;AACE,YAAA,OAAOE,qBAAW,CAAC,IAAI,CAAC;;AAE9B;;;;;;"}
1
+ {"version":3,"file":"type_conversion.cjs","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":["throwPlNotFoundError","notEmpty","Resource_Kind","NullResourceId","GrpcFieldType","Field_ValueStatus","assertNever"],"mappings":";;;;;;;;AAsBA,MAAM,kBAAkB,GAAG,eAAe;AAE1C,SAAS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AuB,GAAG,KAAK,CAAC;;AAEtD;AAEM,SAAU,gBAAgB,CAAC,IAAe,EAAA;IAC9C,QAAQ,IAAI;AACV,QAAA,KAAK,OAAO;YACV,OAAOD,oBAAa,CAAC,KAAK;AAC5B,QAAA,KAAK,QAAQ;YACX,OAAOA,oBAAa,CAAC,MAAM;AAC7B,QAAA,KAAK,SAAS;YACZ,OAAOA,oBAAa,CAAC,OAAO;AAC9B,QAAA,KAAK,SAAS;YACZ,OAAOA,oBAAa,CAAC,OAAO;AAC9B,QAAA,KAAK,KAAK;YACR,OAAOA,oBAAa,CAAC,uBAAuB;AAC9C,QAAA,KAAK,KAAK;YACR,OAAOA,oBAAa,CAAC,iBAAiB;AACxC,QAAA;AACE,YAAA,OAAOE,qBAAW,CAAC,IAAI,CAAC;;AAE9B;;;;;;"}
@@ -1,6 +1,6 @@
1
- import type { Field, Resource } from '../proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types';
2
- import { FieldType as GrpcFieldType } from '../proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types';
3
- import type { FieldData, FieldType, ResourceData } from './types';
1
+ import type { Field, Resource } from "../proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types";
2
+ import { FieldType as GrpcFieldType } from "../proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types";
3
+ import type { FieldData, FieldType, ResourceData } from "./types";
4
4
  /** Throws "native" pl not found error, if resource is marked as deleted. */
5
5
  export declare function protoToResource(proto: Resource): ResourceData;
6
6
  export declare function protoToField(proto: Field): FieldData;
@@ -1 +1 @@
1
- {"version":3,"file":"type_conversion.d.ts","sourceRoot":"","sources":["../../src/core/type_conversion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,KAAK,EACL,QAAQ,EAAE,MAAM,qEAAqE,CAAC;AAKxF,OAAO,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,sEAAsE,CAAC;AAClH,OAAO,KAAK,EACV,SAAS,EAGT,SAAS,EACT,YAAY,EAGb,MAAM,SAAS,CAAC;AAajB,4EAA4E;AAC5E,wBAAgB,eAAe,CAAC,KAAK,EAAE,QAAQ,GAAG,YAAY,CAe7D;AAkBD,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,CASpD;AAkCD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,SAAS,GAAG,aAAa,CAiB/D"}
1
+ {"version":3,"file":"type_conversion.d.ts","sourceRoot":"","sources":["../../src/core/type_conversion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,KAAK,EACL,QAAQ,EACT,MAAM,qEAAqE,CAAC;AAK7E,OAAO,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,sEAAsE,CAAC;AAClH,OAAO,KAAK,EACV,SAAS,EAGT,SAAS,EACT,YAAY,EAGb,MAAM,SAAS,CAAC;AAWjB,4EAA4E;AAC5E,wBAAgB,eAAe,CAAC,KAAK,EAAE,QAAQ,GAAG,YAAY,CAe7D;AAkBD,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,CASpD;AAkCD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,SAAS,GAAG,aAAa,CAiB/D"}
@@ -4,14 +4,14 @@ import { NullResourceId } from './types.js';
4
4
  import { notEmpty, assertNever } from '@milaboratories/ts-helpers';
5
5
  import { throwPlNotFoundError } from './errors.js';
6
6
 
7
- const ResourceErrorField = 'resourceError';
7
+ const ResourceErrorField = "resourceError";
8
8
  function resourceIsDeleted(proto) {
9
9
  return proto.deletedTime !== undefined && proto.deletedTime.seconds !== 0n;
10
10
  }
11
11
  /** Throws "native" pl not found error, if resource is marked as deleted. */
12
12
  function protoToResource(proto) {
13
13
  if (resourceIsDeleted(proto))
14
- throwPlNotFoundError('resource deleted');
14
+ throwPlNotFoundError("resource deleted");
15
15
  return {
16
16
  id: proto.id,
17
17
  originalResourceId: proto.originalResourceId,
@@ -29,11 +29,11 @@ function protoToResource(proto) {
29
29
  function protoToResourceKind(proto) {
30
30
  switch (proto) {
31
31
  case Resource_Kind.STRUCTURAL:
32
- return 'Structural';
32
+ return "Structural";
33
33
  case Resource_Kind.VALUE:
34
- return 'Value';
34
+ return "Value";
35
35
  }
36
- throw new Error('invalid ResourceKind: ' + proto);
36
+ throw new Error("invalid ResourceKind: " + proto);
37
37
  }
38
38
  function protoToError(proto) {
39
39
  const f = proto.fields.find((f) => f?.id?.fieldName === ResourceErrorField);
@@ -52,46 +52,46 @@ function protoToField(proto) {
52
52
  function protoToFieldType(proto) {
53
53
  switch (proto) {
54
54
  case FieldType.INPUT:
55
- return 'Input';
55
+ return "Input";
56
56
  case FieldType.OUTPUT:
57
- return 'Output';
57
+ return "Output";
58
58
  case FieldType.SERVICE:
59
- return 'Service';
59
+ return "Service";
60
60
  case FieldType.ONE_TIME_WRITABLE:
61
- return 'OTW';
61
+ return "OTW";
62
62
  case FieldType.DYNAMIC:
63
- return 'Dynamic';
63
+ return "Dynamic";
64
64
  case FieldType.MULTIPLE_TIMES_WRITABLE:
65
- return 'MTW';
65
+ return "MTW";
66
66
  default:
67
- throw new Error('invalid FieldType: ' + proto);
67
+ throw new Error("invalid FieldType: " + proto);
68
68
  }
69
69
  }
70
70
  function protoToFieldStatus(proto) {
71
71
  switch (proto) {
72
72
  case Field_ValueStatus.EMPTY:
73
- return 'Empty';
73
+ return "Empty";
74
74
  case Field_ValueStatus.ASSIGNED:
75
- return 'Assigned';
75
+ return "Assigned";
76
76
  case Field_ValueStatus.RESOLVED:
77
- return 'Resolved';
77
+ return "Resolved";
78
78
  default:
79
- throw new Error('invalid FieldStatus: ' + proto);
79
+ throw new Error("invalid FieldStatus: " + proto);
80
80
  }
81
81
  }
82
82
  function fieldTypeToProto(type) {
83
83
  switch (type) {
84
- case 'Input':
84
+ case "Input":
85
85
  return FieldType.INPUT;
86
- case 'Output':
86
+ case "Output":
87
87
  return FieldType.OUTPUT;
88
- case 'Dynamic':
88
+ case "Dynamic":
89
89
  return FieldType.DYNAMIC;
90
- case 'Service':
90
+ case "Service":
91
91
  return FieldType.SERVICE;
92
- case 'MTW':
92
+ case "MTW":
93
93
  return FieldType.MULTIPLE_TIMES_WRITABLE;
94
- case 'OTW':
94
+ case "OTW":
95
95
  return FieldType.ONE_TIME_WRITABLE;
96
96
  default:
97
97
  return assertNever(type);
@@ -1 +1 @@
1
- {"version":3,"file":"type_conversion.js","sources":["../../src/core/type_conversion.ts"],"sourcesContent":["import type {\n Field,\n Resource } 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 {\n NullResourceId,\n} 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":";;;;;;AAuBA,MAAM,kBAAkB,GAAG,e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AG,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","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;AAEA,SAAS,mBAAmB,CAAC,KA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AC,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;;;;"}
@@ -11,7 +11,7 @@ function isNotNullResourceId(resourceId) {
11
11
  }
12
12
  function ensureResourceIdNotNull(resourceId) {
13
13
  if (!isNotNullResourceId(resourceId))
14
- throw new Error('null resource id');
14
+ throw new Error("null resource id");
15
15
  return resourceId;
16
16
  }
17
17
  function isAnyResourceId(resourceId) {
@@ -70,15 +70,15 @@ function isLocalResourceId(id) {
70
70
  return (id & ResourceIdLocalMask) !== 0n;
71
71
  }
72
72
  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));
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));
82
82
  }
83
83
  function createGlobalResourceId(isRoot, unmaskedId) {
84
84
  return ((isRoot ? ResourceIdRootMask : 0n) | unmaskedId);
@@ -90,22 +90,22 @@ function checkLocalityOfResourceId(resourceId, expectedTxId) {
90
90
  if (!isLocalResourceId(resourceId))
91
91
  return;
92
92
  if (extractTxId(resourceId) !== expectedTxId)
93
- throw Error('local id from another transaction, globalize id before leaking it from the transaction');
93
+ throw Error("local id from another transaction, globalize id before leaking it from the transaction");
94
94
  }
95
95
  function resourceIdToString(resourceId) {
96
96
  if (isNullResourceId(resourceId))
97
- return 'XX:0x0';
97
+ return "XX:0x0";
98
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
- + ']');
99
+ return ((isRootResourceId(resourceId) ? "R" : "N") +
100
+ "L:0x" +
101
+ (LocalIdMask & resourceId).toString(16) +
102
+ "[0x" +
103
+ extractTxId(resourceId).toString(16) +
104
+ "]");
105
105
  else
106
- return ((isRootResourceId(resourceId) ? 'R' : 'N')
107
- + 'G:0x'
108
- + (NoFlagsIdMask & resourceId).toString(16));
106
+ return ((isRootResourceId(resourceId) ? "R" : "N") +
107
+ "G:0x" +
108
+ (NoFlagsIdMask & resourceId).toString(16));
109
109
  }
110
110
  const resourceIdRegexp = /^(?:(?<xx>XX)|(?<rn>[XRN])(?<lg>[XLG])):0x(?<rid>[0-9a-fA-F]+)(?:\[0x(?<txid>[0-9a-fA-F]+)])?$/;
111
111
  function resourceIdFromString(str) {
@@ -115,10 +115,10 @@ function resourceIdFromString(str) {
115
115
  const { xx, rn, lg, rid, txid } = match.groups;
116
116
  if (xx)
117
117
  return NullResourceId;
118
- if (lg === 'L')
119
- return createLocalResourceId(rn === 'R', Number.parseInt(rid, 16), Number.parseInt(txid, 16));
118
+ if (lg === "L")
119
+ return createLocalResourceId(rn === "R", Number.parseInt(rid, 16), Number.parseInt(txid, 16));
120
120
  else
121
- return createGlobalResourceId(rn === 'R', BigInt('0x' + rid));
121
+ return createGlobalResourceId(rn === "R", BigInt("0x" + rid));
122
122
  }
123
123
  /** Converts bigint to global resource id */
124
124
  function bigintToResourceId(resourceId) {
@@ -129,7 +129,7 @@ function bigintToResourceId(resourceId) {
129
129
  return resourceId;
130
130
  }
131
131
  function stringifyWithResourceId(object) {
132
- return JSON.stringify(object, (key, value) => typeof value === 'bigint' ? resourceIdToString(value) : value);
132
+ return JSON.stringify(object, (key, value) => typeof value === "bigint" ? resourceIdToString(value) : value);
133
133
  }
134
134
 
135
135
  exports.MaxLocalId = MaxLocalId;
@@ -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,EAAgB,EAAA;IACnD,OAAO,CAAA,EAAG,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,OAAO,CAAA,CAAE;AACnC;AAEM,SAAU,kBAAkB,CAAC,KAAmB,EAAE,KAAmB,EAAA;AACzE,IAAA,OAAO,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,OAAO,KAAK,KAAK,CAAC,OAAO;AACrE;AAuBM,SAAU,wBAAwB,CAAC,EAAgB,EAAA;IACvD,MAAM,EACJ,EAAE,EACF,kBAAkB,EAClB,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,YAAY,EACZ,aAAa,EACb,aAAa,EACb,KAAK,GACN,GAAG,EAAE;IACN,OAAO;QACL,EAAE;QACF,kBAAkB;QAClB,IAAI;QACJ,IAAI;QACJ,IAAI;QACJ,KAAK;QACL,YA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AE,QAAA,OAAO,SAAS;AACpC,IAAA,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,MAAO;AAC/C,IAAA,IAAI,EAAE;AAAE,QAAA,OAAO,cAAc;IAC7B,IAAI,EAAE,KAAK,GAAG;QACZ,OAAO,qBAAqB,CAAC,EAAE,KAAK,GAAG,EAAE,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;;AAC1F,QAAA,OAAO,sBAAsB,CAAC,EAAE,KAAK,GAAG,EAAE,MAAM,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC;AACpE;AAEA;AACM,SAAU,kBAAkB,CAAC,UAAkB,EAAA;IACnD,IAAI,iBAAiB,CAAC,UAAU,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,CAAA,mBAAA,EAAsB,kBAAkB,CAAC,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","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,EAAgB,EAAA;IACnD,OAAO,CAAA,EAAG,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,OAAO,CAAA,CAAE;AACnC;AAEM,SAAU,kBAAkB,CAAC,KAAmB,EAAE,KAAmB,EAAA;AACzE,IAAA,OAAO,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,OAAO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SAAS,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,KAAK,KACvC,OAAO,KAAK,KAAK,QAAQ,GAAG,kBAAkB,CAAC,KAA8B,CAAC,GAAG,KAAK,CACvF;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -3,11 +3,11 @@ type BrandResourceId<B> = bigint & {
3
3
  [__resource_id_type__]: B;
4
4
  };
5
5
  /** Global resource id */
6
- export type ResourceId = BrandResourceId<'global'>;
6
+ export type ResourceId = BrandResourceId<"global">;
7
7
  /** Null resource id */
8
- export type NullResourceId = BrandResourceId<'null'>;
8
+ export type NullResourceId = BrandResourceId<"null">;
9
9
  /** Local resource id */
10
- export type LocalResourceId = BrandResourceId<'local'>;
10
+ export type LocalResourceId = BrandResourceId<"local">;
11
11
  /** Any non-null resource id */
12
12
  export type AnyResourceId = ResourceId | LocalResourceId;
13
13
  /** Any resource id */
@@ -19,10 +19,10 @@ export declare function isNullResourceId(resourceId: bigint): resourceId is Null
19
19
  export declare function isNotNullResourceId(resourceId: OptionalResourceId): resourceId is ResourceId;
20
20
  export declare function ensureResourceIdNotNull(resourceId: OptionalResourceId): ResourceId;
21
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';
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
26
  export interface ResourceType {
27
27
  readonly name: string;
28
28
  readonly version: string;
@@ -9,7 +9,7 @@ function isNotNullResourceId(resourceId) {
9
9
  }
10
10
  function ensureResourceIdNotNull(resourceId) {
11
11
  if (!isNotNullResourceId(resourceId))
12
- throw new Error('null resource id');
12
+ throw new Error("null resource id");
13
13
  return resourceId;
14
14
  }
15
15
  function isAnyResourceId(resourceId) {
@@ -68,15 +68,15 @@ function isLocalResourceId(id) {
68
68
  return (id & ResourceIdLocalMask) !== 0n;
69
69
  }
70
70
  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));
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));
80
80
  }
81
81
  function createGlobalResourceId(isRoot, unmaskedId) {
82
82
  return ((isRoot ? ResourceIdRootMask : 0n) | unmaskedId);
@@ -88,22 +88,22 @@ function checkLocalityOfResourceId(resourceId, expectedTxId) {
88
88
  if (!isLocalResourceId(resourceId))
89
89
  return;
90
90
  if (extractTxId(resourceId) !== expectedTxId)
91
- throw Error('local id from another transaction, globalize id before leaking it from the transaction');
91
+ throw Error("local id from another transaction, globalize id before leaking it from the transaction");
92
92
  }
93
93
  function resourceIdToString(resourceId) {
94
94
  if (isNullResourceId(resourceId))
95
- return 'XX:0x0';
95
+ return "XX:0x0";
96
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
- + ']');
97
+ return ((isRootResourceId(resourceId) ? "R" : "N") +
98
+ "L:0x" +
99
+ (LocalIdMask & resourceId).toString(16) +
100
+ "[0x" +
101
+ extractTxId(resourceId).toString(16) +
102
+ "]");
103
103
  else
104
- return ((isRootResourceId(resourceId) ? 'R' : 'N')
105
- + 'G:0x'
106
- + (NoFlagsIdMask & resourceId).toString(16));
104
+ return ((isRootResourceId(resourceId) ? "R" : "N") +
105
+ "G:0x" +
106
+ (NoFlagsIdMask & resourceId).toString(16));
107
107
  }
108
108
  const resourceIdRegexp = /^(?:(?<xx>XX)|(?<rn>[XRN])(?<lg>[XLG])):0x(?<rid>[0-9a-fA-F]+)(?:\[0x(?<txid>[0-9a-fA-F]+)])?$/;
109
109
  function resourceIdFromString(str) {
@@ -113,10 +113,10 @@ function resourceIdFromString(str) {
113
113
  const { xx, rn, lg, rid, txid } = match.groups;
114
114
  if (xx)
115
115
  return NullResourceId;
116
- if (lg === 'L')
117
- return createLocalResourceId(rn === 'R', Number.parseInt(rid, 16), Number.parseInt(txid, 16));
116
+ if (lg === "L")
117
+ return createLocalResourceId(rn === "R", Number.parseInt(rid, 16), Number.parseInt(txid, 16));
118
118
  else
119
- return createGlobalResourceId(rn === 'R', BigInt('0x' + rid));
119
+ return createGlobalResourceId(rn === "R", BigInt("0x" + rid));
120
120
  }
121
121
  /** Converts bigint to global resource id */
122
122
  function bigintToResourceId(resourceId) {
@@ -127,7 +127,7 @@ function bigintToResourceId(resourceId) {
127
127
  return resourceId;
128
128
  }
129
129
  function stringifyWithResourceId(object) {
130
- return JSON.stringify(object, (key, value) => typeof value === 'bigint' ? resourceIdToString(value) : value);
130
+ return JSON.stringify(object, (key, value) => typeof value === "bigint" ? resourceIdToString(value) : value);
131
131
  }
132
132
 
133
133
  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 };
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","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":[],"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,EAAgB,EAAA;IACn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AM,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.js","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":[],"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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