@milaboratories/pl-client 2.11.8 → 2.11.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 (242) hide show
  1. package/dist/core/auth.cjs +24 -0
  2. package/dist/core/auth.cjs.map +1 -0
  3. package/dist/core/auth.d.ts +0 -1
  4. package/dist/core/auth.js +21 -0
  5. package/dist/core/auth.js.map +1 -0
  6. package/dist/core/cache.d.ts +0 -1
  7. package/dist/core/client.cjs +288 -0
  8. package/dist/core/client.cjs.map +1 -0
  9. package/dist/core/client.d.ts +0 -1
  10. package/dist/core/client.js +267 -0
  11. package/dist/core/client.js.map +1 -0
  12. package/dist/core/config.cjs +111 -0
  13. package/dist/core/config.cjs.map +1 -0
  14. package/dist/core/config.d.ts +0 -1
  15. package/dist/core/config.js +95 -0
  16. package/dist/core/config.js.map +1 -0
  17. package/dist/core/default_client.cjs +143 -0
  18. package/dist/core/default_client.cjs.map +1 -0
  19. package/dist/core/default_client.d.ts +0 -1
  20. package/dist/core/default_client.js +120 -0
  21. package/dist/core/default_client.js.map +1 -0
  22. package/dist/core/driver.cjs +14 -0
  23. package/dist/core/driver.cjs.map +1 -0
  24. package/dist/core/driver.d.ts +0 -1
  25. package/dist/core/driver.js +12 -0
  26. package/dist/core/driver.js.map +1 -0
  27. package/dist/core/error_resource.cjs +9 -0
  28. package/dist/core/error_resource.cjs.map +1 -0
  29. package/dist/core/error_resource.d.ts +0 -1
  30. package/dist/core/error_resource.js +7 -0
  31. package/dist/core/error_resource.js.map +1 -0
  32. package/dist/core/errors.cjs +106 -0
  33. package/dist/core/errors.cjs.map +1 -0
  34. package/dist/core/errors.d.ts +0 -1
  35. package/dist/core/errors.js +93 -0
  36. package/dist/core/errors.js.map +1 -0
  37. package/dist/core/final.cjs +98 -0
  38. package/dist/core/final.cjs.map +1 -0
  39. package/dist/core/final.d.ts +0 -1
  40. package/dist/core/final.js +96 -0
  41. package/dist/core/final.js.map +1 -0
  42. package/dist/core/grpc.d.ts +0 -1
  43. package/dist/core/http.d.ts +1 -1
  44. package/dist/core/ll_client.cjs +266 -0
  45. package/dist/core/ll_client.cjs.map +1 -0
  46. package/dist/core/ll_client.d.ts +0 -1
  47. package/dist/core/ll_client.js +264 -0
  48. package/dist/core/ll_client.js.map +1 -0
  49. package/dist/core/ll_transaction.cjs +236 -0
  50. package/dist/core/ll_transaction.cjs.map +1 -0
  51. package/dist/core/ll_transaction.d.ts +0 -1
  52. package/dist/core/ll_transaction.js +233 -0
  53. package/dist/core/ll_transaction.js.map +1 -0
  54. package/dist/core/stat.cjs +74 -0
  55. package/dist/core/stat.cjs.map +1 -0
  56. package/dist/core/stat.d.ts +0 -1
  57. package/dist/core/stat.js +70 -0
  58. package/dist/core/stat.js.map +1 -0
  59. package/dist/core/transaction.cjs +626 -0
  60. package/dist/core/transaction.cjs.map +1 -0
  61. package/dist/core/transaction.d.ts +0 -1
  62. package/dist/core/transaction.js +613 -0
  63. package/dist/core/transaction.js.map +1 -0
  64. package/dist/core/type_conversion.cjs +106 -0
  65. package/dist/core/type_conversion.cjs.map +1 -0
  66. package/dist/core/type_conversion.d.ts +0 -1
  67. package/dist/core/type_conversion.js +102 -0
  68. package/dist/core/type_conversion.js.map +1 -0
  69. package/dist/core/types.cjs +159 -0
  70. package/dist/core/types.cjs.map +1 -0
  71. package/dist/core/types.d.ts +0 -1
  72. package/dist/core/types.js +134 -0
  73. package/dist/core/types.js.map +1 -0
  74. package/dist/core/unauth_client.cjs +43 -0
  75. package/dist/core/unauth_client.cjs.map +1 -0
  76. package/dist/core/unauth_client.d.ts +0 -1
  77. package/dist/core/unauth_client.js +41 -0
  78. package/dist/core/unauth_client.js.map +1 -0
  79. package/dist/helpers/pl.cjs +124 -0
  80. package/dist/helpers/pl.cjs.map +1 -0
  81. package/dist/helpers/pl.d.ts +0 -1
  82. package/dist/helpers/pl.js +94 -0
  83. package/dist/helpers/pl.js.map +1 -0
  84. package/dist/helpers/poll.cjs +148 -0
  85. package/dist/helpers/poll.cjs.map +1 -0
  86. package/dist/helpers/poll.d.ts +0 -1
  87. package/dist/helpers/poll.js +123 -0
  88. package/dist/helpers/poll.js.map +1 -0
  89. package/dist/helpers/rich_resource_types.d.ts +1 -1
  90. package/dist/helpers/smart_accessors.d.ts +1 -1
  91. package/dist/helpers/state_helpers.d.ts +0 -1
  92. package/dist/helpers/tx_helpers.cjs +25 -0
  93. package/dist/helpers/tx_helpers.cjs.map +1 -0
  94. package/dist/helpers/tx_helpers.d.ts +0 -1
  95. package/dist/helpers/tx_helpers.js +23 -0
  96. package/dist/helpers/tx_helpers.js.map +1 -0
  97. package/dist/index.cjs +99 -0
  98. package/dist/index.cjs.map +1 -0
  99. package/dist/index.d.ts +0 -1
  100. package/dist/index.js +16 -1
  101. package/dist/index.js.map +1 -1
  102. package/dist/proto/github.com/googleapis/googleapis/google/rpc/status.cjs +71 -0
  103. package/dist/proto/github.com/googleapis/googleapis/google/rpc/status.cjs.map +1 -0
  104. package/dist/proto/github.com/googleapis/googleapis/google/rpc/status.d.ts +0 -1
  105. package/dist/proto/github.com/googleapis/googleapis/google/rpc/status.js +69 -0
  106. package/dist/proto/github.com/googleapis/googleapis/google/rpc/status.js.map +1 -0
  107. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.d.ts +3 -5
  108. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.d.ts +0 -1
  109. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.client.d.ts +3 -5
  110. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.d.ts +0 -1
  111. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.client.d.ts +3 -5
  112. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.d.ts +0 -1
  113. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client.d.ts +3 -5
  114. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.d.ts +0 -1
  115. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.cjs +12238 -0
  116. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.cjs.map +1 -0
  117. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.client.cjs +223 -0
  118. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.client.cjs.map +1 -0
  119. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.client.d.ts +3 -5
  120. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.client.js +221 -0
  121. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.client.js.map +1 -0
  122. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.d.ts +0 -1
  123. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.js +12086 -0
  124. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.js.map +1 -0
  125. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api_types.cjs +1127 -0
  126. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api_types.cjs.map +1 -0
  127. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api_types.d.ts +0 -1
  128. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api_types.js +1113 -0
  129. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api_types.js.map +1 -0
  130. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/base_types.cjs +152 -0
  131. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/base_types.cjs.map +1 -0
  132. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/base_types.d.ts +0 -1
  133. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/base_types.js +149 -0
  134. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/base_types.js.map +1 -0
  135. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/import.d.ts +0 -1
  136. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/resource_types.cjs +500 -0
  137. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/resource_types.cjs.map +1 -0
  138. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/resource_types.d.ts +0 -1
  139. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/resource_types.js +496 -0
  140. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/resource_types.js.map +1 -0
  141. package/dist/proto/google/api/http.d.ts +0 -1
  142. package/dist/proto/google/protobuf/any.cjs +151 -0
  143. package/dist/proto/google/protobuf/any.cjs.map +1 -0
  144. package/dist/proto/google/protobuf/any.d.ts +0 -1
  145. package/dist/proto/google/protobuf/any.js +149 -0
  146. package/dist/proto/google/protobuf/any.js.map +1 -0
  147. package/dist/proto/google/protobuf/descriptor.d.ts +0 -1
  148. package/dist/proto/google/protobuf/duration.cjs +105 -0
  149. package/dist/proto/google/protobuf/duration.cjs.map +1 -0
  150. package/dist/proto/google/protobuf/duration.d.ts +0 -1
  151. package/dist/proto/google/protobuf/duration.js +103 -0
  152. package/dist/proto/google/protobuf/duration.js.map +1 -0
  153. package/dist/proto/google/protobuf/empty.d.ts +0 -1
  154. package/dist/proto/google/protobuf/struct.d.ts +0 -1
  155. package/dist/proto/google/protobuf/timestamp.cjs +133 -0
  156. package/dist/proto/google/protobuf/timestamp.cjs.map +1 -0
  157. package/dist/proto/google/protobuf/timestamp.d.ts +0 -1
  158. package/dist/proto/google/protobuf/timestamp.js +131 -0
  159. package/dist/proto/google/protobuf/timestamp.js.map +1 -0
  160. package/dist/proto/google/protobuf/wrappers.d.ts +0 -1
  161. package/dist/test/test_config.cjs +149 -0
  162. package/dist/test/test_config.cjs.map +1 -0
  163. package/dist/test/test_config.d.ts +0 -1
  164. package/dist/test/test_config.js +123 -0
  165. package/dist/test/test_config.js.map +1 -0
  166. package/dist/util/branding.d.ts +0 -1
  167. package/dist/util/pl.cjs +8 -0
  168. package/dist/util/pl.cjs.map +1 -0
  169. package/dist/util/pl.d.ts +0 -1
  170. package/dist/util/pl.js +6 -0
  171. package/dist/util/pl.js.map +1 -0
  172. package/dist/util/util.cjs +17 -0
  173. package/dist/util/util.cjs.map +1 -0
  174. package/dist/util/util.d.ts +0 -1
  175. package/dist/util/util.js +15 -0
  176. package/dist/util/util.js.map +1 -0
  177. package/package.json +14 -11
  178. package/src/core/client.test.ts +1 -0
  179. package/src/core/config.test.ts +1 -0
  180. package/src/core/error.test.ts +1 -0
  181. package/src/core/ll_client.test.ts +1 -0
  182. package/src/core/ll_transaction.test.ts +1 -0
  183. package/src/core/transaction.test.ts +1 -0
  184. package/src/core/types.test.ts +1 -0
  185. package/src/core/unauth_client.test.ts +1 -0
  186. package/src/helpers/rich_resource_types.test.ts +2 -0
  187. package/src/test/test_config.test.ts +1 -0
  188. package/src/util/util.test.ts +1 -0
  189. package/dist/core/auth.d.ts.map +0 -1
  190. package/dist/core/cache.d.ts.map +0 -1
  191. package/dist/core/client.d.ts.map +0 -1
  192. package/dist/core/config.d.ts.map +0 -1
  193. package/dist/core/default_client.d.ts.map +0 -1
  194. package/dist/core/driver.d.ts.map +0 -1
  195. package/dist/core/error_resource.d.ts.map +0 -1
  196. package/dist/core/errors.d.ts.map +0 -1
  197. package/dist/core/final.d.ts.map +0 -1
  198. package/dist/core/grpc.d.ts.map +0 -1
  199. package/dist/core/http.d.ts.map +0 -1
  200. package/dist/core/ll_client.d.ts.map +0 -1
  201. package/dist/core/ll_transaction.d.ts.map +0 -1
  202. package/dist/core/stat.d.ts.map +0 -1
  203. package/dist/core/transaction.d.ts.map +0 -1
  204. package/dist/core/type_conversion.d.ts.map +0 -1
  205. package/dist/core/types.d.ts.map +0 -1
  206. package/dist/core/unauth_client.d.ts.map +0 -1
  207. package/dist/helpers/pl.d.ts.map +0 -1
  208. package/dist/helpers/poll.d.ts.map +0 -1
  209. package/dist/helpers/rich_resource_types.d.ts.map +0 -1
  210. package/dist/helpers/smart_accessors.d.ts.map +0 -1
  211. package/dist/helpers/state_helpers.d.ts.map +0 -1
  212. package/dist/helpers/tx_helpers.d.ts.map +0 -1
  213. package/dist/index.d.ts.map +0 -1
  214. package/dist/index.mjs +0 -14537
  215. package/dist/index.mjs.map +0 -1
  216. package/dist/proto/github.com/googleapis/googleapis/google/rpc/status.d.ts.map +0 -1
  217. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.d.ts.map +0 -1
  218. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.d.ts.map +0 -1
  219. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.client.d.ts.map +0 -1
  220. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.d.ts.map +0 -1
  221. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.client.d.ts.map +0 -1
  222. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.d.ts.map +0 -1
  223. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client.d.ts.map +0 -1
  224. package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.d.ts.map +0 -1
  225. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.client.d.ts.map +0 -1
  226. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.d.ts.map +0 -1
  227. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api_types.d.ts.map +0 -1
  228. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/base_types.d.ts.map +0 -1
  229. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/import.d.ts.map +0 -1
  230. package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/resource_types.d.ts.map +0 -1
  231. package/dist/proto/google/api/http.d.ts.map +0 -1
  232. package/dist/proto/google/protobuf/any.d.ts.map +0 -1
  233. package/dist/proto/google/protobuf/descriptor.d.ts.map +0 -1
  234. package/dist/proto/google/protobuf/duration.d.ts.map +0 -1
  235. package/dist/proto/google/protobuf/empty.d.ts.map +0 -1
  236. package/dist/proto/google/protobuf/struct.d.ts.map +0 -1
  237. package/dist/proto/google/protobuf/timestamp.d.ts.map +0 -1
  238. package/dist/proto/google/protobuf/wrappers.d.ts.map +0 -1
  239. package/dist/test/test_config.d.ts.map +0 -1
  240. package/dist/util/branding.d.ts.map +0 -1
  241. package/dist/util/pl.d.ts.map +0 -1
  242. package/dist/util/util.d.ts.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction.js","sources":["../../src/core/transaction.ts"],"sourcesContent":["// TODO: fix this\n/* eslint-disable no-prototype-builtins */\nimport type {\n AnyResourceId,\n LocalResourceId,\n OptionalResourceId,\n BasicResourceData,\n FieldData,\n FieldType,\n ResourceData,\n ResourceId,\n ResourceType,\n FutureFieldType } from './types';\nimport {\n createLocalResourceId,\n ensureResourceIdNotNull,\n MaxTxId,\n isLocalResourceId,\n extractBasicResourceData,\n isNullResourceId,\n} from './types';\nimport type {\n ClientMessageRequest,\n LLPlTransaction,\n OneOfKind,\n ServerMessageResponse,\n} from './ll_transaction';\nimport { TxAPI_Open_Request_WritableTx } from '../proto/github.com/milaboratory/pl/plapi/plapiproto/api';\nimport type { NonUndefined } from 'utility-types';\nimport { toBytes } from '../util/util';\nimport { fieldTypeToProto, protoToField, protoToResource } from './type_conversion';\nimport { canonicalJsonBytes, canonicalJsonGzBytes, deepFreeze, notEmpty } from '@milaboratories/ts-helpers';\nimport { isNotFoundError } from './errors';\nimport type { FinalResourceDataPredicate } from './final';\nimport type { LRUCache } from 'lru-cache';\nimport type { ResourceDataCacheRecord } from './cache';\nimport type { TxStat } from './stat';\nimport { initialTxStatWithoutTime } from './stat';\nimport type { ErrorResourceData } from './error_resource';\nimport { ErrorResourceType } from './error_resource';\nimport { JsonGzObject, JsonObject } from '../helpers/pl';\n\n/** Reference to resource, used only within transaction */\nexport interface ResourceRef {\n /** Global resource id of newly created resources, become available only\n * after response for the corresponding creation request is received. */\n readonly globalId: Promise<ResourceId>;\n\n /** Transaction-local resource id is assigned right after resource creation\n * request is sent, and can be used right away */\n readonly localId: LocalResourceId;\n}\n\n/** Key-Value pair from resource-attached KV storage */\nexport interface KeyValue {\n key: string;\n value: Uint8Array;\n}\n\n/** Key-Value pair from resource-attached KV storage */\nexport interface KeyValueString {\n key: string;\n value: string;\n}\n\ninterface _FieldId<RId> {\n /** Parent resource id */\n resourceId: RId;\n /** Field name */\n fieldName: string;\n}\n\nexport type FieldId = _FieldId<ResourceId>;\nexport type FieldRef = _FieldId<ResourceRef>;\nexport type LocalFieldId = _FieldId<LocalResourceId>;\nexport type AnyFieldId = FieldId | LocalFieldId;\n\nexport type AnyResourceRef = ResourceRef | ResourceId;\nexport type AnyFieldRef = _FieldId<AnyResourceRef>; // FieldRef | FieldId\nexport type AnyRef = AnyResourceRef | AnyFieldRef;\n\nexport function isField(ref: AnyRef): ref is AnyFieldRef {\n return ref.hasOwnProperty('resourceId') && ref.hasOwnProperty('fieldName');\n}\n\nexport function isResource(ref: AnyRef): ref is AnyResourceRef {\n return (\n typeof ref === 'bigint' || (ref.hasOwnProperty('globalId') && ref.hasOwnProperty('localId'))\n );\n}\n\nexport function isResourceId(ref: AnyRef): ref is ResourceId {\n return typeof ref === 'bigint' && !isLocalResourceId(ref) && !isNullResourceId(ref);\n}\n\nexport function isFieldRef(ref: AnyFieldRef): ref is FieldRef {\n return isResourceRef(ref.resourceId);\n}\n\nexport function isResourceRef(ref: AnyResourceRef): ref is ResourceRef {\n return ref.hasOwnProperty('globalId') && ref.hasOwnProperty('localId');\n}\n\nexport function toFieldId(ref: AnyFieldRef): AnyFieldId {\n if (isFieldRef(ref)) return { resourceId: ref.resourceId.localId, fieldName: ref.fieldName };\n else return ref as FieldId;\n}\n\nexport async function toGlobalFieldId(ref: AnyFieldRef): Promise<FieldId> {\n if (isFieldRef(ref))\n return { resourceId: await ref.resourceId.globalId, fieldName: ref.fieldName };\n else return ref as FieldId;\n}\n\nexport function toResourceId(ref: AnyResourceRef): AnyResourceId {\n if (isResourceRef(ref)) return ref.localId;\n else return ref;\n}\n\nexport async function toGlobalResourceId(ref: AnyResourceRef): Promise<ResourceId> {\n if (isResourceRef(ref)) return await ref.globalId;\n else return ref;\n}\n\nexport function field(resourceId: AnyResourceRef, fieldName: string): AnyFieldRef {\n return { resourceId, fieldName };\n}\n\n/** If transaction commit failed due to write conflicts */\nexport class TxCommitConflict extends Error {\n name = 'TxCommitConflict';\n}\n\nasync function notFoundToUndefined<T>(cb: () => Promise<T>): Promise<T | undefined> {\n try {\n return await cb();\n } catch (e) {\n if (isNotFoundError(e)) return undefined;\n throw e;\n }\n}\n\n/**\n * Each platform transaction has 3 stages:\n * - initialization (txOpen message -> txInfo response)\n * - communication (create resources, fields, references and so on)\n * - finalization (txCommit or txDiscard message)\n *\n * This class encapsulates finalization stage and provides ready-to-communication transaction object.\n * */\nexport class PlTransaction {\n private readonly globalTxId: Promise<bigint>;\n private readonly localTxId: number = PlTransaction.nextLocalTxId();\n\n /** Used in caching */\n private readonly txOpenTimestamp = Date.now();\n\n private localResourceIdCounter = 0;\n\n /** Store logical tx open / closed state to prevent invalid sequence of requests.\n * True means output stream was completed.\n * Contract: there must be no async operations between setting this field to true and sending complete signal to stream. */\n private _completed = false;\n\n /** Void operation futures are placed into this pool, and corresponding method return immediately.\n * This is done to save number of round-trips. Next operation producing result will also await those\n * pending ops, to throw any pending errors. */\n private pendingVoidOps: Promise<void>[] = [];\n\n private globalTxIdWasAwaited: boolean = false;\n\n private readonly _startTime = Date.now();\n private readonly _stat = initialTxStatWithoutTime();\n public get stat(): TxStat {\n return {\n ...this._stat,\n timeMs: Date.now() - this._startTime,\n };\n }\n\n constructor(\n private readonly ll: LLPlTransaction,\n public readonly name: string,\n public readonly writable: boolean,\n private readonly _clientRoot: OptionalResourceId,\n private readonly finalPredicate: FinalResourceDataPredicate,\n private readonly sharedResourceDataCache: LRUCache<ResourceId, ResourceDataCacheRecord>,\n private readonly enableFormattedErrors: boolean = false,\n ) {\n // initiating transaction\n this.globalTxId = this.sendSingleAndParse(\n {\n oneofKind: 'txOpen',\n txOpen: {\n name,\n enableFormattedErrors,\n writable: writable\n ? TxAPI_Open_Request_WritableTx.WRITABLE\n : TxAPI_Open_Request_WritableTx.NOT_WRITABLE,\n },\n },\n (r) => notEmpty(r.txOpen.tx?.id),\n );\n\n // To avoid floating promise\n this.globalTxId.catch((err) => {\n if (!this.globalTxIdWasAwaited) {\n console.warn(err);\n }\n });\n\n // Adding stats\n this._stat.txCount++;\n }\n\n private async drainAndAwaitPendingOps(): Promise<void> {\n if (this.pendingVoidOps.length === 0) return;\n\n // drain pending operations into temp array\n const pending = this.pendingVoidOps;\n this.pendingVoidOps = [];\n // awaiting these pending operations first, to catch any errors\n await Promise.all(pending);\n }\n\n private async sendSingleAndParse<Kind extends NonUndefined<ClientMessageRequest['oneofKind']>, T>(\n r: OneOfKind<ClientMessageRequest, Kind>,\n parser: (resp: OneOfKind<ServerMessageResponse, Kind>) => T,\n ): Promise<T> {\n // pushing operation packet to server\n const rawResponsePromise = this.ll.send(r, false);\n\n await this.drainAndAwaitPendingOps();\n // awaiting our result, and parsing the response\n return parser(await rawResponsePromise);\n }\n\n private async sendMultiAndParse<Kind extends NonUndefined<ClientMessageRequest['oneofKind']>, T>(\n r: OneOfKind<ClientMessageRequest, Kind>,\n parser: (resp: OneOfKind<ServerMessageResponse, Kind>[]) => T,\n ): Promise<T> {\n // pushing operation packet to server\n const rawResponsePromise = this.ll.send(r, true);\n\n await this.drainAndAwaitPendingOps();\n // awaiting our result, and parsing the response\n return parser(await rawResponsePromise);\n }\n\n private async sendVoidSync<Kind extends NonUndefined<ClientMessageRequest['oneofKind']>>(\n r: OneOfKind<ClientMessageRequest, Kind>,\n ): Promise<void> {\n await this.ll.send(r, false);\n }\n\n /** Requests sent with this method should never produce recoverable errors */\n private sendVoidAsync<Kind extends NonUndefined<ClientMessageRequest['oneofKind']>>(\n r: OneOfKind<ClientMessageRequest, Kind>,\n ): void {\n this.pendingVoidOps.push(this.sendVoidSync(r));\n }\n\n private checkTxOpen() {\n if (this._completed) throw new Error('Transaction already closed');\n }\n\n public get completed() {\n return this._completed;\n }\n\n /** Commit & closes transaction. {@link TxCommitConflict} is thrown on\n * commit conflicts. */\n public async commit() {\n this.checkTxOpen();\n\n // tx will accept no requests after this one\n this._completed = true;\n\n if (!this.writable) {\n // no need to explicitly commit or reject read-only tx\n const completeResult = this.ll.complete();\n await this.drainAndAwaitPendingOps();\n await completeResult;\n await this.ll.await();\n } else {\n // @TODO, also floating promises\n const commitResponse = this.sendSingleAndParse(\n { oneofKind: 'txCommit', txCommit: {} },\n (r) => r.txCommit.success,\n );\n\n // send closing frame right after commit to save some time on round-trips\n const completeResult = this.ll.complete();\n\n // now when we pushed all packets into the stream, we should wait for any\n // pending void operations from before, to catch any errors\n await this.drainAndAwaitPendingOps();\n\n if (!(await commitResponse)) throw new TxCommitConflict();\n\n await completeResult;\n\n // await event-loop completion\n await this.ll.await();\n }\n }\n\n public async discard() {\n this.checkTxOpen();\n\n // tx will accept no requests after this one\n this._completed = true;\n\n const discardResponse = this.sendVoidSync({ oneofKind: 'txDiscard', txDiscard: {} });\n // send closing frame right after commit to save some time on round-trips\n const completeResult = this.ll.complete();\n\n // now when we pushed all packets into the stream, we should wait for any\n // pending void operations from before, to catch any errors\n await this.drainAndAwaitPendingOps();\n\n await discardResponse;\n await completeResult;\n await this.ll.await();\n }\n\n //\n // Main tx methods\n //\n\n public get clientRoot(): ResourceId {\n return ensureResourceIdNotNull(this._clientRoot);\n }\n\n //\n // Resources\n //\n\n public createSingleton(\n name: string,\n type: ResourceType,\n errorIfExists: boolean = false,\n ): ResourceRef {\n const localId = this.nextLocalResourceId(false);\n\n const globalId = this.sendSingleAndParse(\n {\n oneofKind: 'resourceCreateSingleton',\n resourceCreateSingleton: {\n type,\n id: localId,\n data: Buffer.from(name),\n errorIfExists,\n },\n },\n (r) => r.resourceCreateSingleton.resourceId as ResourceId,\n );\n\n return { globalId, localId };\n }\n\n public async getSingleton(name: string, loadFields: true): Promise<ResourceData>;\n public async getSingleton(name: string, loadFields: false): Promise<BasicResourceData>;\n public async getSingleton(\n name: string,\n loadFields: boolean = true,\n ): Promise<BasicResourceData | ResourceData> {\n return await this.sendSingleAndParse(\n {\n oneofKind: 'resourceGetSingleton',\n resourceGetSingleton: {\n data: Buffer.from(name),\n loadFields,\n },\n },\n (r) => protoToResource(notEmpty(r.resourceGetSingleton.resource)),\n );\n }\n\n private createResource<Kind extends NonUndefined<ClientMessageRequest['oneofKind']>>(\n root: boolean,\n req: (localId: LocalResourceId) => OneOfKind<ClientMessageRequest, Kind>,\n parser: (resp: OneOfKind<ServerMessageResponse, Kind>) => bigint,\n ): ResourceRef {\n const localId = this.nextLocalResourceId(root);\n\n const globalId = this.sendSingleAndParse(req(localId), (r) => parser(r) as ResourceId);\n\n return { globalId, localId };\n }\n\n public createRoot(type: ResourceType): ResourceRef {\n this._stat.rootsCreated++;\n return this.createResource(\n true,\n (localId) => ({ oneofKind: 'resourceCreateRoot', resourceCreateRoot: { type, id: localId } }),\n (r) => r.resourceCreateRoot.resourceId,\n );\n }\n\n public createStruct(type: ResourceType, data?: Uint8Array | string): ResourceRef {\n this._stat.structsCreated++;\n this._stat.structsCreatedDataBytes += data?.length ?? 0;\n return this.createResource(\n false,\n (localId) => ({\n oneofKind: 'resourceCreateStruct',\n resourceCreateStruct: {\n type,\n id: localId,\n data: data === undefined ? undefined : typeof data === 'string' ? Buffer.from(data) : data,\n },\n }),\n (r) => r.resourceCreateStruct.resourceId,\n );\n }\n\n public createEphemeral(type: ResourceType, data?: Uint8Array | string): ResourceRef {\n this._stat.ephemeralsCreated++;\n this._stat.ephemeralsCreatedDataBytes += data?.length ?? 0;\n return this.createResource(\n false,\n (localId) => ({\n oneofKind: 'resourceCreateEphemeral',\n resourceCreateEphemeral: {\n type,\n id: localId,\n data: data === undefined ? undefined : typeof data === 'string' ? Buffer.from(data) : data,\n },\n }),\n (r) => r.resourceCreateEphemeral.resourceId,\n );\n }\n\n public createValue(\n type: ResourceType,\n data: Uint8Array | string,\n errorIfExists: boolean = false,\n ): ResourceRef {\n this._stat.valuesCreated++;\n this._stat.valuesCreatedDataBytes += data?.length ?? 0;\n return this.createResource(\n false,\n (localId) => ({\n oneofKind: 'resourceCreateValue',\n resourceCreateValue: {\n type,\n id: localId,\n data: typeof data === 'string' ? Buffer.from(data) : data,\n errorIfExists,\n },\n }),\n (r) => r.resourceCreateValue.resourceId,\n );\n }\n\n public createJsonValue(data: unknown): ResourceRef {\n const jsonData = canonicalJsonBytes(data);\n return this.createValue(JsonObject, jsonData, false);\n }\n\n public createJsonGzValue(data: unknown, minSizeToGzip: number | undefined = 16_384): ResourceRef {\n const { data: jsonData, isGzipped } = canonicalJsonGzBytes(data, minSizeToGzip);\n return this.createValue(isGzipped ? JsonGzObject : JsonObject, jsonData, false);\n }\n\n public createError(message: string): ResourceRef {\n return this.createValue(ErrorResourceType, JSON.stringify({ message } satisfies ErrorResourceData));\n }\n\n public setResourceName(name: string, rId: AnyResourceRef): void {\n this.sendVoidAsync({\n oneofKind: 'resourceNameSet',\n resourceNameSet: { resourceId: toResourceId(rId), name },\n });\n }\n\n public deleteResourceName(name: string): void {\n this.sendVoidAsync({ oneofKind: 'resourceNameDelete', resourceNameDelete: { name } });\n }\n\n public async getResourceByName(name: string): Promise<ResourceId> {\n return await this.sendSingleAndParse(\n { oneofKind: 'resourceNameGet', resourceNameGet: { name } },\n (r) => ensureResourceIdNotNull(r.resourceNameGet.resourceId as OptionalResourceId),\n );\n }\n\n public async checkResourceNameExists(name: string): Promise<boolean> {\n return await this.sendSingleAndParse(\n { oneofKind: 'resourceNameExists', resourceNameExists: { name } },\n (r) => r.resourceNameExists.exists,\n );\n }\n\n public removeResource(rId: ResourceId): void {\n this.sendVoidAsync({ oneofKind: 'resourceRemove', resourceRemove: { id: rId } });\n }\n\n public async resourceExists(rId: ResourceId): Promise<boolean> {\n return await this.sendSingleAndParse(\n { oneofKind: 'resourceExists', resourceExists: { resourceId: rId } },\n (r) => r.resourceExists.exists,\n );\n }\n\n /** This method may return stale resource state from cache if resource was removed */\n public async getResourceData(rId: AnyResourceRef, loadFields: true): Promise<ResourceData>;\n /** This method may return stale resource state from cache if resource was removed */\n public async getResourceData(rId: AnyResourceRef, loadFields: false): Promise<BasicResourceData>;\n /** This method may return stale resource state from cache if resource was removed */\n public async getResourceData(\n rId: AnyResourceRef,\n loadFields: boolean\n ): Promise<BasicResourceData | ResourceData>;\n /** This method may return stale resource state from cache if ignoreCache == false if resource was removed */\n public async getResourceData(\n rId: AnyResourceRef,\n loadFields: true,\n ignoreCache: boolean\n ): Promise<ResourceData>;\n /** This method may return stale resource state from cache if ignoreCache == false if resource was removed */\n public async getResourceData(\n rId: AnyResourceRef,\n loadFields: false,\n ignoreCache: boolean\n ): Promise<BasicResourceData>;\n /** This method may return stale resource state from cache if ignoreCache == false if resource was removed */\n public async getResourceData(\n rId: AnyResourceRef,\n loadFields: boolean,\n ignoreCache: boolean\n ): Promise<BasicResourceData | ResourceData>;\n public async getResourceData(\n rId: AnyResourceRef,\n loadFields: boolean = true,\n ignoreCache: boolean = false,\n ): Promise<BasicResourceData | ResourceData> {\n if (!ignoreCache && !isResourceRef(rId) && !isLocalResourceId(rId)) {\n // checking if we can return result from cache\n const fromCache = this.sharedResourceDataCache.get(rId);\n if (fromCache && fromCache.cacheTxOpenTimestamp < this.txOpenTimestamp) {\n if (!loadFields) {\n this._stat.rGetDataCacheHits++;\n this._stat.rGetDataCacheBytes += fromCache.basicData.data?.length ?? 0;\n return fromCache.basicData;\n } else if (fromCache.data) {\n this._stat.rGetDataCacheHits++;\n this._stat.rGetDataCacheBytes += fromCache.basicData.data?.length ?? 0;\n this._stat.rGetDataCacheFields += fromCache.data.fields.length;\n return fromCache.data;\n }\n }\n }\n\n const result = await this.sendSingleAndParse(\n {\n oneofKind: 'resourceGet',\n resourceGet: { resourceId: toResourceId(rId), loadFields: loadFields },\n },\n (r) => protoToResource(notEmpty(r.resourceGet.resource)),\n );\n\n this._stat.rGetDataNetRequests++;\n this._stat.rGetDataNetBytes += result.data?.length ?? 0;\n this._stat.rGetDataNetFields += result.fields.length;\n\n // we will cache only final resource data states\n // caching result even if we were ignore the cache\n if (!isResourceRef(rId) && !isLocalResourceId(rId) && this.finalPredicate(result)) {\n deepFreeze(result);\n const fromCache = this.sharedResourceDataCache.get(rId);\n if (fromCache) {\n if (loadFields && !fromCache.data) {\n fromCache.data = result;\n // updating timestamp becuse we updated the record\n fromCache.cacheTxOpenTimestamp = this.txOpenTimestamp;\n }\n } else {\n const basicData = extractBasicResourceData(result);\n deepFreeze(basicData);\n if (loadFields)\n this.sharedResourceDataCache.set(rId, {\n basicData,\n data: result,\n cacheTxOpenTimestamp: this.txOpenTimestamp,\n });\n else\n this.sharedResourceDataCache.set(rId, {\n basicData,\n data: undefined,\n cacheTxOpenTimestamp: this.txOpenTimestamp,\n });\n }\n }\n\n return result;\n }\n\n public async getResourceDataIfExists(\n rId: AnyResourceRef,\n loadFields: true\n ): Promise<ResourceData | undefined>;\n public async getResourceDataIfExists(\n rId: AnyResourceRef,\n loadFields: false\n ): Promise<BasicResourceData | undefined>;\n public async getResourceDataIfExists(\n rId: AnyResourceRef,\n loadFields: boolean\n ): Promise<BasicResourceData | ResourceData | undefined>;\n public async getResourceDataIfExists(\n rId: AnyResourceRef,\n loadFields: boolean = true,\n ): Promise<BasicResourceData | ResourceData | undefined> {\n // calling this mehtod will ignore cache, because user intention is to detect resource absence\n // which cache will prevent\n const result = await notFoundToUndefined(\n async () => await this.getResourceData(rId, loadFields, true),\n );\n\n // cleaning cache record if resorce was removed from the db\n if (result === undefined && !isResourceRef(rId) && !isLocalResourceId(rId))\n this.sharedResourceDataCache.delete(rId);\n\n return result;\n }\n\n /**\n * Inform platform that resource will not get any new input fields.\n * This is required, when client creates resource without schema and wants\n * controller to start calculations.\n * Most controllers will not start calculations even when all inputs\n * have their values, if inputs list is not locked.\n */\n public lockInputs(rId: AnyResourceRef): void {\n this._stat.inputsLocked++;\n this.sendVoidAsync({\n oneofKind: 'resourceLockInputs',\n resourceLockInputs: { resourceId: toResourceId(rId) },\n });\n }\n\n /**\n * Inform platform that resource will not get any new output fields.\n * This is required for resource to pass deduplication.\n */\n public lockOutputs(rId: AnyResourceRef): void {\n this._stat.outputsLocked++;\n this.sendVoidAsync({\n oneofKind: 'resourceLockOutputs',\n resourceLockOutputs: { resourceId: toResourceId(rId) },\n });\n }\n\n public lock(rID: AnyResourceRef): void {\n this.lockInputs(rID);\n this.lockOutputs(rID);\n }\n\n public setResourceError(rId: AnyResourceRef, ref: AnyResourceRef): void {\n this.sendVoidAsync({\n oneofKind: 'resourceSetError',\n resourceSetError: { resourceId: toResourceId(rId), errorResourceId: toResourceId(ref) },\n });\n }\n\n //\n // Fields\n //\n\n public createField(fId: AnyFieldRef, fieldType: FieldType, value?: AnyRef): void {\n this._stat.fieldsCreated++;\n this.sendVoidAsync({\n oneofKind: 'fieldCreate',\n fieldCreate: { type: fieldTypeToProto(fieldType), id: toFieldId(fId) },\n });\n if (value !== undefined) this.setField(fId, value);\n }\n\n public async fieldExists(fId: AnyFieldRef): Promise<boolean> {\n return await this.sendSingleAndParse(\n {\n oneofKind: 'fieldExists',\n fieldExists: { field: toFieldId(fId) },\n },\n (r) => r.fieldExists.exists,\n );\n }\n\n public setField(fId: AnyFieldRef, ref: AnyRef): void {\n this._stat.fieldsSet++;\n if (isResource(ref))\n this.sendVoidAsync({\n oneofKind: 'fieldSet',\n fieldSet: {\n field: toFieldId(fId),\n value: {\n resourceId: toResourceId(ref),\n fieldName: '', // default value, read as undefined\n },\n },\n });\n else\n this.sendVoidAsync({\n oneofKind: 'fieldSet',\n fieldSet: {\n field: toFieldId(fId),\n value: toFieldId(ref),\n },\n });\n }\n\n public setFieldError(fId: AnyFieldRef, ref: AnyResourceRef): void {\n this._stat.fieldsSet++;\n this.sendVoidAsync({\n oneofKind: 'fieldSetError',\n fieldSetError: { field: toFieldId(fId), errResourceId: toResourceId(ref) },\n });\n }\n\n public async getField(fId: AnyFieldRef): Promise<FieldData> {\n this._stat.fieldsGet++;\n return await this.sendSingleAndParse(\n { oneofKind: 'fieldGet', fieldGet: { field: toFieldId(fId) } },\n (r) => protoToField(notEmpty(r.fieldGet.field)),\n );\n }\n\n public async getFieldIfExists(fId: AnyFieldRef): Promise<FieldData | undefined> {\n return notFoundToUndefined(async () => await this.getField(fId));\n }\n\n public resetField(fId: AnyFieldRef): void {\n this.sendVoidAsync({ oneofKind: 'fieldReset', fieldReset: { field: toFieldId(fId) } });\n }\n\n public removeField(fId: AnyFieldRef): void {\n this.sendVoidAsync({ oneofKind: 'fieldRemove', fieldRemove: { field: toFieldId(fId) } });\n }\n\n //\n // KV\n //\n\n public async listKeyValues(rId: AnyResourceRef): Promise<KeyValue[]> {\n const result = await this.sendMultiAndParse(\n {\n oneofKind: 'resourceKeyValueList',\n resourceKeyValueList: { resourceId: toResourceId(rId), startFrom: '', limit: 0 },\n },\n (r) => r.map((e) => e.resourceKeyValueList.record!),\n );\n\n this._stat.kvListRequests++;\n this._stat.kvListEntries += result.length;\n for (const kv of result) this._stat.kvListBytes += kv.key.length + kv.value.length;\n\n return result;\n }\n\n public async listKeyValuesString(rId: AnyResourceRef): Promise<KeyValueString[]> {\n return (await this.listKeyValues(rId)).map(({ key, value }) => ({\n key,\n value: Buffer.from(value).toString(),\n }));\n }\n\n public async listKeyValuesIfResourceExists(rId: AnyResourceRef): Promise<KeyValue[] | undefined> {\n return notFoundToUndefined(async () => await this.listKeyValues(rId));\n }\n\n public async listKeyValuesStringIfResourceExists(\n rId: AnyResourceRef,\n ): Promise<KeyValueString[] | undefined> {\n return notFoundToUndefined(async () => await this.listKeyValuesString(rId));\n }\n\n public setKValue(rId: AnyResourceRef, key: string, value: Uint8Array | string): void {\n this._stat.kvSetRequests++;\n this._stat.kvSetBytes++;\n this.sendVoidAsync({\n oneofKind: 'resourceKeyValueSet',\n resourceKeyValueSet: {\n resourceId: toResourceId(rId),\n key,\n value: toBytes(value),\n },\n });\n }\n\n public deleteKValue(rId: AnyResourceRef, key: string): void {\n this.sendVoidAsync({\n oneofKind: 'resourceKeyValueDelete',\n resourceKeyValueDelete: {\n resourceId: toResourceId(rId),\n key,\n },\n });\n }\n\n public async getKValue(rId: AnyResourceRef, key: string): Promise<Uint8Array> {\n const result = await this.sendSingleAndParse(\n {\n oneofKind: 'resourceKeyValueGet',\n resourceKeyValueGet: { resourceId: toResourceId(rId), key },\n },\n (r) => r.resourceKeyValueGet.value,\n );\n\n this._stat.kvGetRequests++;\n this._stat.kvGetBytes += result.length;\n\n return result;\n }\n\n public async getKValueString(rId: AnyResourceRef, key: string): Promise<string> {\n return Buffer.from(await this.getKValue(rId, key)).toString();\n }\n\n public async getKValueJson<T>(rId: AnyResourceRef, key: string): Promise<T> {\n return JSON.parse(await this.getKValueString(rId, key)) as T;\n }\n\n public async getKValueIfExists(\n rId: AnyResourceRef,\n key: string,\n ): Promise<Uint8Array | undefined> {\n const result = await this.sendSingleAndParse(\n {\n oneofKind: 'resourceKeyValueGetIfExists',\n resourceKeyValueGetIfExists: { resourceId: toResourceId(rId), key },\n },\n (r) =>\n r.resourceKeyValueGetIfExists.exists ? r.resourceKeyValueGetIfExists.value : undefined,\n );\n\n this._stat.kvGetRequests++;\n this._stat.kvGetBytes += result?.length ?? 0;\n\n return result;\n }\n\n public async getKValueStringIfExists(\n rId: AnyResourceRef,\n key: string,\n ): Promise<string | undefined> {\n const data = await this.getKValueIfExists(rId, key);\n return data === undefined ? undefined : Buffer.from(data).toString();\n }\n\n public async getKValueJsonIfExists<T>(rId: AnyResourceRef, key: string): Promise<T | undefined> {\n const str = await this.getKValueString(rId, key);\n if (str === undefined) return undefined;\n return JSON.parse(str) as T;\n }\n\n //\n // Cache\n //\n // TODO\n\n //\n // High level ops\n //\n\n /** Resolves existing or create first level resource from */\n public getFutureFieldValue(rId: AnyRef, fieldName: string, fieldType: FutureFieldType): FieldRef {\n const data = Buffer.from(JSON.stringify({ fieldName, fieldType }));\n const getFieldResource = this.createEphemeral({ name: 'json/getField', version: '1' }, data);\n this.setField({ resourceId: getFieldResource, fieldName: 'resource' }, rId);\n return { resourceId: getFieldResource, fieldName: 'result' };\n }\n\n //\n // Technical\n //\n\n public async getGlobalTxId() {\n this.globalTxIdWasAwaited = true;\n return await this.globalTxId;\n }\n\n /** Closes output event stream */\n public async complete() {\n if (this._completed) return;\n this._completed = true;\n const completeResult = this.ll.complete();\n await this.drainAndAwaitPendingOps();\n await completeResult;\n }\n\n /** Await incoming message loop termination and throw\n * any leftover errors if it was unsuccessful */\n public async await() {\n await this.ll.await();\n }\n\n //\n // Helpers\n //\n\n private nextLocalResourceId(root: boolean): LocalResourceId {\n return createLocalResourceId(root, ++this.localResourceIdCounter, this.localTxId);\n }\n\n private static localTxIdCounter = 0;\n\n private static nextLocalTxId() {\n PlTransaction.localTxIdCounter++;\n if (PlTransaction.localTxIdCounter === MaxTxId) PlTransaction.localTxIdCounter = 1;\n return PlTransaction.localTxIdCounter;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;AAiFM,SAAU,OAAO,CAAC,GAAW,EAAA;AACjC,IAAA,OAAO,GAAG,CAAC,cAAc,CAAC,YAAY,CAAC,IAAI,GAAG,CAAC,cAAc,CAAC,WAAW,CAAC;AAC5E;AAEM,SAAU,UAAU,CAAC,GAAW,EAAA;IACpC,QACE,OAAO,GAAG,KAAK,QAAQ,KAAK,GAAG,CAAC,cAAc,CAAC,UAAU,CAAC,IAAI,GAAG,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;AAEhG;AAEM,SAAU,YAAY,CAAC,GAAW,EAAA;AACtC,IAAA,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC;AACrF;AAEM,SA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C,UAAU;IAC9B;;AAGO,IAAA,MAAM,QAAQ,GAAA;QACnB,IAAI,IAAI,CAAC,UAAU;YAAE;AACrB,QAAA,IAAI,CAAC,UAAU,GAAG,IAAI;QACtB,MAAM,cAAc,GAAG,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE;AACzC,QAAA,MAAM,IAAI,CAAC,uBAAuB,EAAE;AACpC,QAAA,MAAM,cAAc;IACtB;AAEA;AACgD;AACzC,IAAA,MAAM,KAAK,GAAA;AAChB,QAAA,MAAM,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE;IACvB;;;;AAMQ,IAAA,mBAAmB,CAAC,IAAa,EAAA;AACvC,QAAA,OAAO,qBAAqB,CAAC,IAAI,EAAE,EAAE,IAAI,CAAC,sBAAsB,EAAE,IAAI,CAAC,SAAS,CAAC;IACnF;AAEQ,IAAA,OAAO,gBAAgB,GAAG,CAAC;AAE3B,IAAA,OAAO,aAAa,GAAA;QAC1B,aAAa,CAAC,gBAAgB,EAAE;AAChC,QAAA,IAAI,aAAa,CAAC,gBAAgB,KAAK,OAAO;AAAE,YAAA,aAAa,CAAC,gBAAgB,GAAG,CAAC;QAClF,OAAO,aAAa,CAAC,gBAAgB;IACvC;;;;;"}
@@ -0,0 +1,106 @@
1
+ 'use strict';
2
+
3
+ var api_types = require('../proto/github.com/milaboratory/pl/plapi/plapiproto/api_types.cjs');
4
+ var base_types = require('../proto/github.com/milaboratory/pl/plapi/plapiproto/base_types.cjs');
5
+ var types = require('./types.cjs');
6
+ var tsHelpers = require('@milaboratories/ts-helpers');
7
+ var errors = require('./errors.cjs');
8
+
9
+ const ResourceErrorField = 'resourceError';
10
+ function resourceIsDeleted(proto) {
11
+ return proto.deletedTime !== undefined && proto.deletedTime.seconds !== 0n;
12
+ }
13
+ /** Throws "native" pl not found error, if resource is marked as deleted. */
14
+ function protoToResource(proto) {
15
+ if (resourceIsDeleted(proto))
16
+ errors.throwPlNotFoundError('resource deleted');
17
+ return {
18
+ id: proto.id,
19
+ originalResourceId: proto.originalResourceId,
20
+ type: tsHelpers.notEmpty(proto.type),
21
+ data: proto.data,
22
+ inputsLocked: proto.inputsLocked,
23
+ outputsLocked: proto.outputsLocked,
24
+ resourceReady: proto.resourceReady,
25
+ kind: protoToResourceKind(proto.kind),
26
+ error: protoToError(proto),
27
+ final: proto.isFinal,
28
+ fields: proto.fields?.filter((f) => f.id.fieldName !== ResourceErrorField).map(protoToField),
29
+ };
30
+ }
31
+ function protoToResourceKind(proto) {
32
+ switch (proto) {
33
+ case api_types.Resource_Kind.STRUCTURAL:
34
+ return 'Structural';
35
+ case api_types.Resource_Kind.VALUE:
36
+ return 'Value';
37
+ }
38
+ throw new Error('invalid ResourceKind: ' + proto);
39
+ }
40
+ function protoToError(proto) {
41
+ const f = proto.fields.find((f) => f?.id?.fieldName === ResourceErrorField);
42
+ return (f?.error ?? types.NullResourceId);
43
+ }
44
+ function protoToField(proto) {
45
+ return {
46
+ name: tsHelpers.notEmpty(proto.id?.fieldName),
47
+ type: protoToFieldType(proto.type),
48
+ status: protoToFieldStatus(proto.valueStatus),
49
+ value: proto.value,
50
+ error: proto.error,
51
+ valueIsFinal: proto.valueIsFinal,
52
+ };
53
+ }
54
+ function protoToFieldType(proto) {
55
+ switch (proto) {
56
+ case base_types.FieldType.INPUT:
57
+ return 'Input';
58
+ case base_types.FieldType.OUTPUT:
59
+ return 'Output';
60
+ case base_types.FieldType.SERVICE:
61
+ return 'Service';
62
+ case base_types.FieldType.ONE_TIME_WRITABLE:
63
+ return 'OTW';
64
+ case base_types.FieldType.DYNAMIC:
65
+ return 'Dynamic';
66
+ case base_types.FieldType.MULTIPLE_TIMES_WRITABLE:
67
+ return 'MTW';
68
+ default:
69
+ throw new Error('invalid FieldType: ' + proto);
70
+ }
71
+ }
72
+ function protoToFieldStatus(proto) {
73
+ switch (proto) {
74
+ case api_types.Field_ValueStatus.EMPTY:
75
+ return 'Empty';
76
+ case api_types.Field_ValueStatus.ASSIGNED:
77
+ return 'Assigned';
78
+ case api_types.Field_ValueStatus.RESOLVED:
79
+ return 'Resolved';
80
+ default:
81
+ throw new Error('invalid FieldStatus: ' + proto);
82
+ }
83
+ }
84
+ function fieldTypeToProto(type) {
85
+ switch (type) {
86
+ case 'Input':
87
+ return base_types.FieldType.INPUT;
88
+ case 'Output':
89
+ return base_types.FieldType.OUTPUT;
90
+ case 'Dynamic':
91
+ return base_types.FieldType.DYNAMIC;
92
+ case 'Service':
93
+ return base_types.FieldType.SERVICE;
94
+ case 'MTW':
95
+ return base_types.FieldType.MULTIPLE_TIMES_WRITABLE;
96
+ case 'OTW':
97
+ return base_types.FieldType.ONE_TIME_WRITABLE;
98
+ default:
99
+ return tsHelpers.assertNever(type);
100
+ }
101
+ }
102
+
103
+ exports.fieldTypeToProto = fieldTypeToProto;
104
+ exports.protoToField = protoToField;
105
+ exports.protoToResource = protoToResource;
106
+ //# sourceMappingURL=type_conversion.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type_conversion.cjs","sources":["../../src/core/type_conversion.ts"],"sourcesContent":["import type {\n Field,\n Resource } from '../proto/github.com/milaboratory/pl/plapi/plapiproto/api_types';\nimport {\n Field_ValueStatus,\n Resource_Kind,\n} from '../proto/github.com/milaboratory/pl/plapi/plapiproto/api_types';\nimport { FieldType as GrpcFieldType } from '../proto/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,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,CA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AAA,OAAO,SAAS;QAClB,KAAKA,oBAAa,CAAC,uBAAuB;AACxC,YAAA,OAAO,KAAK;AACd,QAAA;AACE,YAAA,MAAM,IAAI,KAAK,CAAC,qBAAqB,GAAG,KAAK,CAAC;;AAEpD;AAEA,SAAS,kBAAkB,CAAC,KAAwB,EAAA;IAClD,QAAQ,KAAK;QACX,KAAKC,2BAAiB,CAAC,KAAK;AAC1B,YAAA,OAAO,OAAO;QAChB,KAAKA,2BAAiB,CAAC,QAAQ;AAC7B,YAAA,OAAO,UAAU;QACnB,KAAKA,2BAAiB,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,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;;;;;;"}
@@ -5,4 +5,3 @@ import { FieldData, FieldType, ResourceData } from './types';
5
5
  export declare function protoToResource(proto: Resource): ResourceData;
6
6
  export declare function protoToField(proto: Field): FieldData;
7
7
  export declare function fieldTypeToProto(type: FieldType): GrpcFieldType;
8
- //# sourceMappingURL=type_conversion.d.ts.map
@@ -0,0 +1,102 @@
1
+ import { Resource_Kind, Field_ValueStatus } from '../proto/github.com/milaboratory/pl/plapi/plapiproto/api_types.js';
2
+ import { FieldType } from '../proto/github.com/milaboratory/pl/plapi/plapiproto/base_types.js';
3
+ import { NullResourceId } from './types.js';
4
+ import { notEmpty, assertNever } from '@milaboratories/ts-helpers';
5
+ import { throwPlNotFoundError } from './errors.js';
6
+
7
+ const ResourceErrorField = 'resourceError';
8
+ function resourceIsDeleted(proto) {
9
+ return proto.deletedTime !== undefined && proto.deletedTime.seconds !== 0n;
10
+ }
11
+ /** Throws "native" pl not found error, if resource is marked as deleted. */
12
+ function protoToResource(proto) {
13
+ if (resourceIsDeleted(proto))
14
+ throwPlNotFoundError('resource deleted');
15
+ return {
16
+ id: proto.id,
17
+ originalResourceId: proto.originalResourceId,
18
+ type: notEmpty(proto.type),
19
+ data: proto.data,
20
+ inputsLocked: proto.inputsLocked,
21
+ outputsLocked: proto.outputsLocked,
22
+ resourceReady: proto.resourceReady,
23
+ kind: protoToResourceKind(proto.kind),
24
+ error: protoToError(proto),
25
+ final: proto.isFinal,
26
+ fields: proto.fields?.filter((f) => f.id.fieldName !== ResourceErrorField).map(protoToField),
27
+ };
28
+ }
29
+ function protoToResourceKind(proto) {
30
+ switch (proto) {
31
+ case Resource_Kind.STRUCTURAL:
32
+ return 'Structural';
33
+ case Resource_Kind.VALUE:
34
+ return 'Value';
35
+ }
36
+ throw new Error('invalid ResourceKind: ' + proto);
37
+ }
38
+ function protoToError(proto) {
39
+ const f = proto.fields.find((f) => f?.id?.fieldName === ResourceErrorField);
40
+ return (f?.error ?? NullResourceId);
41
+ }
42
+ function protoToField(proto) {
43
+ return {
44
+ name: notEmpty(proto.id?.fieldName),
45
+ type: protoToFieldType(proto.type),
46
+ status: protoToFieldStatus(proto.valueStatus),
47
+ value: proto.value,
48
+ error: proto.error,
49
+ valueIsFinal: proto.valueIsFinal,
50
+ };
51
+ }
52
+ function protoToFieldType(proto) {
53
+ switch (proto) {
54
+ case FieldType.INPUT:
55
+ return 'Input';
56
+ case FieldType.OUTPUT:
57
+ return 'Output';
58
+ case FieldType.SERVICE:
59
+ return 'Service';
60
+ case FieldType.ONE_TIME_WRITABLE:
61
+ return 'OTW';
62
+ case FieldType.DYNAMIC:
63
+ return 'Dynamic';
64
+ case FieldType.MULTIPLE_TIMES_WRITABLE:
65
+ return 'MTW';
66
+ default:
67
+ throw new Error('invalid FieldType: ' + proto);
68
+ }
69
+ }
70
+ function protoToFieldStatus(proto) {
71
+ switch (proto) {
72
+ case Field_ValueStatus.EMPTY:
73
+ return 'Empty';
74
+ case Field_ValueStatus.ASSIGNED:
75
+ return 'Assigned';
76
+ case Field_ValueStatus.RESOLVED:
77
+ return 'Resolved';
78
+ default:
79
+ throw new Error('invalid FieldStatus: ' + proto);
80
+ }
81
+ }
82
+ function fieldTypeToProto(type) {
83
+ switch (type) {
84
+ case 'Input':
85
+ return FieldType.INPUT;
86
+ case 'Output':
87
+ return FieldType.OUTPUT;
88
+ case 'Dynamic':
89
+ return FieldType.DYNAMIC;
90
+ case 'Service':
91
+ return FieldType.SERVICE;
92
+ case 'MTW':
93
+ return FieldType.MULTIPLE_TIMES_WRITABLE;
94
+ case 'OTW':
95
+ return FieldType.ONE_TIME_WRITABLE;
96
+ default:
97
+ return assertNever(type);
98
+ }
99
+ }
100
+
101
+ export { fieldTypeToProto, protoToField, protoToResource };
102
+ //# sourceMappingURL=type_conversion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type_conversion.js","sources":["../../src/core/type_conversion.ts"],"sourcesContent":["import type {\n Field,\n Resource } from '../proto/github.com/milaboratory/pl/plapi/plapiproto/api_types';\nimport {\n Field_ValueStatus,\n Resource_Kind,\n} from '../proto/github.com/milaboratory/pl/plapi/plapiproto/api_types';\nimport { FieldType as GrpcFieldType } from '../proto/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,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,QAA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;QACjB,KAAKA,SAAa,CAAC,OAAO;AACxB,YAAA,OAAO,SAAS;QAClB,KAAKA,SAAa,CAAC,iBAAiB;AAClC,YAAA,OAAO,KAAK;QACd,KAAKA,SAAa,CAAC,OAAO;AACxB,YAAA,OAAO,SAAS;QAClB,KAAKA,SAAa,CAAC,uBAAuB;AACxC,YAAA,OAAO,KAAK;AACd,QAAA;AACE,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;;;;"}
@@ -0,0 +1,159 @@
1
+ 'use strict';
2
+
3
+ var tsHelpers = require('@milaboratories/ts-helpers');
4
+
5
+ const NullResourceId = 0n;
6
+ function isNullResourceId(resourceId) {
7
+ return resourceId === NullResourceId;
8
+ }
9
+ function isNotNullResourceId(resourceId) {
10
+ return resourceId !== NullResourceId;
11
+ }
12
+ function ensureResourceIdNotNull(resourceId) {
13
+ if (!isNotNullResourceId(resourceId))
14
+ throw new Error('null resource id');
15
+ return resourceId;
16
+ }
17
+ function isAnyResourceId(resourceId) {
18
+ return resourceId !== 0n;
19
+ }
20
+ function resourceType(name, version) {
21
+ return { name, version };
22
+ }
23
+ function resourceTypeToString(rt) {
24
+ return `${rt.name}:${rt.version}`;
25
+ }
26
+ function resourceTypesEqual(type1, type2) {
27
+ return type1.name === type2.name && type1.version === type2.version;
28
+ }
29
+ 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
+ };
43
+ }
44
+ const jsonToData = (data) => Buffer.from(JSON.stringify(data));
45
+ const resDataToJson = (res) => tsHelpers.cachedDeserialize(tsHelpers.notEmpty(res.data));
46
+ 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
55
+ const ResourceIdRootMask = 1n << 63n;
56
+ const ResourceIdLocalMask = 1n << 62n;
57
+ const NoFlagsIdMask = 0x3fffffffffffffffn;
58
+ const LocalResourceIdTxIdOffset = 24n;
59
+ const MaxLocalId = 0xffffff;
60
+ const MaxTxId = 0xffffffff;
61
+ /** Mask valid after applying shift */
62
+ const TxIdMask = BigInt(MaxTxId);
63
+ const LocalIdMask = BigInt(MaxLocalId);
64
+ // /** Basically removes embedded tx id */
65
+ // const LocalIdCleanMask = 0xFF00000000FFFFFFn;
66
+ function isRootResourceId(id) {
67
+ return (id & ResourceIdRootMask) !== 0n;
68
+ }
69
+ function isLocalResourceId(id) {
70
+ return (id & ResourceIdLocalMask) !== 0n;
71
+ }
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));
82
+ }
83
+ function createGlobalResourceId(isRoot, unmaskedId) {
84
+ return ((isRoot ? ResourceIdRootMask : 0n) | unmaskedId);
85
+ }
86
+ function extractTxId(localResourceId) {
87
+ return Number((localResourceId >> LocalResourceIdTxIdOffset) & TxIdMask);
88
+ }
89
+ 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');
94
+ }
95
+ 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));
109
+ }
110
+ const resourceIdRegexp = /^(?:(?<xx>XX)|(?<rn>[XRN])(?<lg>[XLG])):0x(?<rid>[0-9a-fA-F]+)(?:\[0x(?<txid>[0-9a-fA-F]+)])?$/;
111
+ 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));
122
+ }
123
+ /** Converts bigint to global resource id */
124
+ 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;
130
+ }
131
+ function stringifyWithResourceId(object) {
132
+ return JSON.stringify(object, (key, value) => typeof value === 'bigint' ? resourceIdToString(value) : value);
133
+ }
134
+
135
+ exports.MaxLocalId = MaxLocalId;
136
+ exports.MaxTxId = MaxTxId;
137
+ exports.NullResourceId = NullResourceId;
138
+ exports.bigintToResourceId = bigintToResourceId;
139
+ exports.checkLocalityOfResourceId = checkLocalityOfResourceId;
140
+ exports.createGlobalResourceId = createGlobalResourceId;
141
+ exports.createLocalResourceId = createLocalResourceId;
142
+ exports.ensureResourceIdNotNull = ensureResourceIdNotNull;
143
+ exports.extractBasicResourceData = extractBasicResourceData;
144
+ exports.extractTxId = extractTxId;
145
+ exports.getField = getField;
146
+ exports.isAnyResourceId = isAnyResourceId;
147
+ exports.isLocalResourceId = isLocalResourceId;
148
+ exports.isNotNullResourceId = isNotNullResourceId;
149
+ exports.isNullResourceId = isNullResourceId;
150
+ exports.isRootResourceId = isRootResourceId;
151
+ exports.jsonToData = jsonToData;
152
+ exports.resDataToJson = resDataToJson;
153
+ exports.resourceIdFromString = resourceIdFromString;
154
+ exports.resourceIdToString = resourceIdToString;
155
+ exports.resourceType = resourceType;
156
+ exports.resourceTypeToString = resourceTypeToString;
157
+ exports.resourceTypesEqual = resourceTypesEqual;
158
+ exports.stringifyWithResourceId = stringifyWithResourceId;
159
+ //# sourceMappingURL=types.cjs.map
@@ -0,0 +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;AA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;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;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -75,4 +75,3 @@ export declare function resourceIdFromString(str: string): OptionalAnyResourceId
75
75
  export declare function bigintToResourceId(resourceId: bigint): ResourceId;
76
76
  export declare function stringifyWithResourceId(object: unknown): string;
77
77
  export {};
78
- //# sourceMappingURL=types.d.ts.map