@coasys/ad4m 0.12.1-dev → 0.13.0-postmessage-ws-proxy.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (388) hide show
  1. package/README.md +2 -25
  2. package/jest-setup.ts +1 -1
  3. package/lib/index.cjs +5097 -11841
  4. package/lib/index.js +5289 -12104
  5. package/lib/src/Ad4mClient.d.ts +9 -3
  6. package/lib/src/Ad4mClient.js +40 -13
  7. package/lib/src/Literal.js +6 -5
  8. package/lib/src/agent/Agent.js +26 -272
  9. package/lib/src/agent/AgentClient.d.ts +33 -21
  10. package/lib/src/agent/AgentClient.js +180 -374
  11. package/lib/src/agent/AgentStatus.js +2 -37
  12. package/lib/src/ai/AIClient.d.ts +12 -4
  13. package/lib/src/ai/AIClient.js +81 -285
  14. package/lib/src/ai/AITypes.d.ts +55 -0
  15. package/lib/src/ai/AITypes.js +18 -0
  16. package/lib/src/ai/Tasks.js +10 -133
  17. package/lib/src/apiClient.d.ts +53 -0
  18. package/lib/src/apiClient.js +234 -0
  19. package/lib/src/cache/PersistentCache.d.ts +40 -0
  20. package/lib/src/cache/PersistentCache.js +139 -0
  21. package/lib/src/expression/Expression.d.ts +1 -1
  22. package/lib/src/expression/Expression.js +13 -122
  23. package/lib/src/expression/ExpressionClient.d.ts +11 -3
  24. package/lib/src/expression/ExpressionClient.js +120 -75
  25. package/lib/src/expression/ExpressionRef.js +4 -27
  26. package/lib/src/generated/api/AIModelLoadingStatus.d.ts +7 -0
  27. package/lib/src/generated/api/AIModelLoadingStatus.js +2 -0
  28. package/lib/src/generated/api/AddLinkExpressionRequest.d.ts +6 -0
  29. package/lib/src/generated/api/AddLinkExpressionRequest.js +1 -0
  30. package/lib/src/generated/api/AddLinkRequest.d.ts +6 -0
  31. package/lib/src/generated/api/AddLinkRequest.js +1 -0
  32. package/lib/src/generated/api/AddLinksBulkRequest.d.ts +6 -0
  33. package/lib/src/generated/api/AddLinksBulkRequest.js +1 -0
  34. package/lib/src/generated/api/AddSdnaRequest.d.ts +6 -0
  35. package/lib/src/generated/api/AddSdnaRequest.js +2 -0
  36. package/lib/src/generated/api/ApplyTemplateRequest.d.ts +4 -0
  37. package/lib/src/generated/api/ApplyTemplateRequest.js +2 -0
  38. package/lib/src/generated/api/AuthInfoInput.d.ts +10 -0
  39. package/lib/src/generated/api/AuthInfoInput.js +1 -0
  40. package/lib/src/generated/api/CapabilityInput.d.ts +5 -0
  41. package/lib/src/generated/api/CapabilityInput.js +1 -0
  42. package/lib/src/generated/api/CommitBatchRequest.d.ts +3 -0
  43. package/lib/src/generated/api/CommitBatchRequest.js +2 -0
  44. package/lib/src/generated/api/ComputeLogEntry.d.ts +9 -0
  45. package/lib/src/generated/api/ComputeLogEntry.js +2 -0
  46. package/lib/src/generated/api/CreateExpressionRequest.d.ts +4 -0
  47. package/lib/src/generated/api/CreateExpressionRequest.js +2 -0
  48. package/lib/src/generated/api/CreatePerspectiveRequest.d.ts +3 -0
  49. package/lib/src/generated/api/CreatePerspectiveRequest.js +2 -0
  50. package/lib/src/generated/api/CreateSubjectRequest.d.ts +6 -0
  51. package/lib/src/generated/api/CreateSubjectRequest.js +2 -0
  52. package/lib/src/generated/api/EmbedRequest.d.ts +4 -0
  53. package/lib/src/generated/api/EmbedRequest.js +2 -0
  54. package/lib/src/generated/api/EntanglementProofInput.d.ts +6 -0
  55. package/lib/src/generated/api/EntanglementProofInput.js +2 -0
  56. package/lib/src/generated/api/ExecuteCommandsRequest.d.ts +4 -0
  57. package/lib/src/generated/api/ExecuteCommandsRequest.js +2 -0
  58. package/lib/src/generated/api/ExportRequest.d.ts +5 -0
  59. package/lib/src/generated/api/ExportRequest.js +2 -0
  60. package/lib/src/generated/api/ExpressionManyRequest.d.ts +3 -0
  61. package/lib/src/generated/api/ExpressionManyRequest.js +2 -0
  62. package/lib/src/generated/api/ExpressionProof.d.ts +4 -0
  63. package/lib/src/generated/api/ExpressionProof.js +2 -0
  64. package/lib/src/generated/api/ExpressionProofInput.d.ts +6 -0
  65. package/lib/src/generated/api/ExpressionProofInput.js +2 -0
  66. package/lib/src/generated/api/FriendSendMessageRequest.d.ts +3 -0
  67. package/lib/src/generated/api/FriendSendMessageRequest.js +2 -0
  68. package/lib/src/generated/api/FriendsListRequest.d.ts +3 -0
  69. package/lib/src/generated/api/FriendsListRequest.js +2 -0
  70. package/lib/src/generated/api/GenerateAgentRequest.d.ts +3 -0
  71. package/lib/src/generated/api/GenerateAgentRequest.js +2 -0
  72. package/lib/src/generated/api/GenerateJwtRequest.d.ts +4 -0
  73. package/lib/src/generated/api/GenerateJwtRequest.js +2 -0
  74. package/lib/src/generated/api/GetSubjectDataRequest.d.ts +4 -0
  75. package/lib/src/generated/api/GetSubjectDataRequest.js +2 -0
  76. package/lib/src/generated/api/ImportAgentRequest.d.ts +6 -0
  77. package/lib/src/generated/api/ImportAgentRequest.js +2 -0
  78. package/lib/src/generated/api/ImportRequest.d.ts +4 -0
  79. package/lib/src/generated/api/ImportRequest.js +2 -0
  80. package/lib/src/generated/api/JoinNeighbourhoodRequest.d.ts +3 -0
  81. package/lib/src/generated/api/JoinNeighbourhoodRequest.js +2 -0
  82. package/lib/src/generated/api/LanguageMetaInput.d.ts +6 -0
  83. package/lib/src/generated/api/LanguageMetaInput.js +2 -0
  84. package/lib/src/generated/api/Link.d.ts +5 -0
  85. package/lib/src/generated/api/Link.js +2 -0
  86. package/lib/src/generated/api/LinkExpression.d.ts +10 -0
  87. package/lib/src/generated/api/LinkExpression.js +1 -0
  88. package/lib/src/generated/api/LinkExpressionInput.d.ts +10 -0
  89. package/lib/src/generated/api/LinkExpressionInput.js +1 -0
  90. package/lib/src/generated/api/LinkInput.d.ts +5 -0
  91. package/lib/src/generated/api/LinkInput.js +2 -0
  92. package/lib/src/generated/api/LinkLanguageTemplatesRequest.d.ts +3 -0
  93. package/lib/src/generated/api/LinkLanguageTemplatesRequest.js +2 -0
  94. package/lib/src/generated/api/LinkMutations.d.ts +6 -0
  95. package/lib/src/generated/api/LinkMutations.js +1 -0
  96. package/lib/src/generated/api/LinkStatus.d.ts +1 -0
  97. package/lib/src/generated/api/LinkStatus.js +2 -0
  98. package/lib/src/generated/api/LockAgentRequest.d.ts +3 -0
  99. package/lib/src/generated/api/LockAgentRequest.js +2 -0
  100. package/lib/src/generated/api/ModelType.d.ts +1 -0
  101. package/lib/src/generated/api/ModelType.js +2 -0
  102. package/lib/src/generated/api/NotificationInput.d.ts +10 -0
  103. package/lib/src/generated/api/NotificationInput.js +2 -0
  104. package/lib/src/generated/api/OpenLinkRequest.d.ts +3 -0
  105. package/lib/src/generated/api/OpenLinkRequest.js +2 -0
  106. package/lib/src/generated/api/PermitCapabilityRequest.d.ts +3 -0
  107. package/lib/src/generated/api/PermitCapabilityRequest.js +2 -0
  108. package/lib/src/generated/api/PerspectiveInput.d.ts +4 -0
  109. package/lib/src/generated/api/PerspectiveInput.js +1 -0
  110. package/lib/src/generated/api/PromptRequest.d.ts +4 -0
  111. package/lib/src/generated/api/PromptRequest.js +2 -0
  112. package/lib/src/generated/api/PublishLanguageRequest.d.ts +5 -0
  113. package/lib/src/generated/api/PublishLanguageRequest.js +1 -0
  114. package/lib/src/generated/api/PublishNeighbourhoodRequest.d.ts +6 -0
  115. package/lib/src/generated/api/PublishNeighbourhoodRequest.js +1 -0
  116. package/lib/src/generated/api/QueryRequest.d.ts +7 -0
  117. package/lib/src/generated/api/QueryRequest.js +2 -0
  118. package/lib/src/generated/api/RemoveLinkRequest.d.ts +5 -0
  119. package/lib/src/generated/api/RemoveLinkRequest.js +1 -0
  120. package/lib/src/generated/api/RemoveLinksBulkRequest.d.ts +5 -0
  121. package/lib/src/generated/api/RemoveLinksBulkRequest.js +1 -0
  122. package/lib/src/generated/api/ResourceInput.d.ts +4 -0
  123. package/lib/src/generated/api/ResourceInput.js +2 -0
  124. package/lib/src/generated/api/SetDefaultModelRequest.d.ts +4 -0
  125. package/lib/src/generated/api/SetDefaultModelRequest.js +1 -0
  126. package/lib/src/generated/api/SetFreeHostingEnabledRequest.d.ts +3 -0
  127. package/lib/src/generated/api/SetFreeHostingEnabledRequest.js +2 -0
  128. package/lib/src/generated/api/SetMultiUserRequest.d.ts +3 -0
  129. package/lib/src/generated/api/SetMultiUserRequest.js +2 -0
  130. package/lib/src/generated/api/SetStatusRequest.d.ts +3 -0
  131. package/lib/src/generated/api/SetStatusRequest.js +2 -0
  132. package/lib/src/generated/api/SignMessageRequest.d.ts +3 -0
  133. package/lib/src/generated/api/SignMessageRequest.js +2 -0
  134. package/lib/src/generated/api/TrustedAgentsRequest.d.ts +3 -0
  135. package/lib/src/generated/api/TrustedAgentsRequest.js +2 -0
  136. package/lib/src/generated/api/UnlockAgentRequest.d.ts +4 -0
  137. package/lib/src/generated/api/UnlockAgentRequest.js +2 -0
  138. package/lib/src/generated/api/UpdateLinkRequest.d.ts +7 -0
  139. package/lib/src/generated/api/UpdateLinkRequest.js +1 -0
  140. package/lib/src/generated/api/UpdatePerspectiveRequest.d.ts +3 -0
  141. package/lib/src/generated/api/UpdatePerspectiveRequest.js +2 -0
  142. package/lib/src/generated/api/UserStatistics.d.ts +9 -0
  143. package/lib/src/generated/api/UserStatistics.js +2 -0
  144. package/lib/src/generated/api/VerificationRequestResult.d.ts +6 -0
  145. package/lib/src/generated/api/VerificationRequestResult.js +2 -0
  146. package/lib/src/generated/api/VerifySignatureRequest.d.ts +5 -0
  147. package/lib/src/generated/api/VerifySignatureRequest.js +2 -0
  148. package/lib/src/generated/api/WriteSettingsRequest.d.ts +3 -0
  149. package/lib/src/generated/api/WriteSettingsRequest.js +2 -0
  150. package/lib/src/generated/api/index.d.ts +42 -0
  151. package/lib/src/generated/api/index.js +7 -0
  152. package/lib/src/index.d.ts +7 -2
  153. package/lib/src/index.js +7 -2
  154. package/lib/src/jestSetup.d.ts +0 -1
  155. package/lib/src/jestSetup.js +1 -1
  156. package/lib/src/language/Icon.js +2 -21
  157. package/lib/src/language/Language.d.ts +26 -176
  158. package/lib/src/language/Language.js +32 -72
  159. package/lib/src/language/LanguageClient.d.ts +2 -2
  160. package/lib/src/language/LanguageClient.js +15 -105
  161. package/lib/src/language/LanguageHandle.js +2 -41
  162. package/lib/src/language/LanguageMeta.js +4 -75
  163. package/lib/src/language/LanguageRef.js +2 -25
  164. package/lib/src/links/Links.js +14 -111
  165. package/lib/src/model/Ad4mModel.d.ts +150 -62
  166. package/lib/src/model/Ad4mModel.js +689 -417
  167. package/lib/src/model/Ad4mModel.test.js +1434 -688
  168. package/lib/src/model/ModelQueryBuilder.d.ts +59 -38
  169. package/lib/src/model/ModelQueryBuilder.js +317 -153
  170. package/lib/src/model/Subject.js +6 -6
  171. package/lib/src/model/decorators.d.ts +36 -8
  172. package/lib/src/model/decorators.js +41 -14
  173. package/lib/src/model/hydration-batch.d.ts +34 -0
  174. package/lib/src/model/hydration-batch.js +147 -0
  175. package/lib/src/model/hydration-batching.test.d.ts +7 -0
  176. package/lib/src/model/hydration-batching.test.js +456 -0
  177. package/lib/src/model/hydration.d.ts +3 -92
  178. package/lib/src/model/hydration.js +3 -691
  179. package/lib/src/model/index.d.ts +3 -4
  180. package/lib/src/model/index.js +3 -4
  181. package/lib/src/model/json-schema.js +2 -2
  182. package/lib/src/model/model-manifest.d.ts +41 -0
  183. package/lib/src/model/model-manifest.js +11 -0
  184. package/lib/src/model/query-cache.d.ts +30 -0
  185. package/lib/src/model/query-cache.js +66 -0
  186. package/lib/src/model/query-cache.test.d.ts +1 -0
  187. package/lib/src/model/query-cache.test.js +43 -0
  188. package/lib/src/model/query-common.d.ts +1 -1
  189. package/lib/src/model/query-common.js +1 -1
  190. package/lib/src/model/query-sparql-batch.d.ts +17 -0
  191. package/lib/src/model/query-sparql-batch.js +260 -0
  192. package/lib/src/model/query-sparql.d.ts +51 -0
  193. package/lib/src/model/query-sparql.js +466 -0
  194. package/lib/src/model/query-sparql.test.d.ts +1 -0
  195. package/lib/src/model/query-sparql.test.js +312 -0
  196. package/lib/src/model/{surreal-utils.d.ts → query-utils.d.ts} +13 -9
  197. package/lib/src/model/query-utils.js +189 -0
  198. package/lib/src/model/relation-filtering.test.js +15 -15
  199. package/lib/src/model/sdna.js +1 -1
  200. package/lib/src/model/shacl-gen.js +46 -18
  201. package/lib/src/model/subscription-delta.test.d.ts +24 -0
  202. package/lib/src/model/subscription-delta.test.js +180 -0
  203. package/lib/src/model/subscription-pool.d.ts +39 -0
  204. package/lib/src/model/subscription-pool.js +165 -0
  205. package/lib/src/model/types.d.ts +60 -5
  206. package/lib/src/model/types.js +5 -2
  207. package/lib/src/neighbourhood/Neighbourhood.js +4 -32
  208. package/lib/src/neighbourhood/NeighbourhoodClient.d.ts +3 -3
  209. package/lib/src/neighbourhood/NeighbourhoodClient.js +40 -203
  210. package/lib/src/perspectives/LinkQuery.js +2 -42
  211. package/lib/src/perspectives/Perspective.d.ts +1 -1
  212. package/lib/src/perspectives/Perspective.js +10 -52
  213. package/lib/src/perspectives/PerspectiveClient.d.ts +22 -32
  214. package/lib/src/perspectives/PerspectiveClient.js +189 -454
  215. package/lib/src/perspectives/PerspectiveClient.test.d.ts +1 -0
  216. package/lib/src/perspectives/PerspectiveClient.test.js +224 -0
  217. package/lib/src/perspectives/PerspectiveDiff.js +4 -31
  218. package/lib/src/perspectives/PerspectiveHandle.js +3 -43
  219. package/lib/src/perspectives/PerspectiveProxy.d.ts +156 -78
  220. package/lib/src/perspectives/PerspectiveProxy.js +474 -389
  221. package/lib/src/perspectives/PerspectiveResolver.d.ts +0 -1
  222. package/lib/src/perspectives/PerspectiveResolver.js +0 -11
  223. package/lib/src/perspectives/WakerSubscriptionManager.d.ts +3 -3
  224. package/lib/src/perspectives/WakerSubscriptionManager.js +12 -12
  225. package/lib/src/runtime/RuntimeClient.d.ts +8 -6
  226. package/lib/src/runtime/RuntimeClient.js +97 -454
  227. package/lib/src/runtime/RuntimeResolver.d.ts +14 -0
  228. package/lib/src/runtime/RuntimeResolver.js +84 -0
  229. package/lib/src/runtime/RuntimeTypes.d.ts +101 -0
  230. package/lib/src/runtime/RuntimeTypes.js +45 -0
  231. package/lib/src/schema.gql +14 -1
  232. package/lib/src/shacl/SHACLFlow.d.ts +1 -1
  233. package/lib/src/shacl/SHACLFlow.js +9 -9
  234. package/lib/src/shacl/SHACLShape.d.ts +8 -1
  235. package/lib/src/shacl/SHACLShape.js +57 -38
  236. package/lib/src/shacl/SHACLShape.test.js +82 -0
  237. package/lib/src/typeDefs.js +3 -615
  238. package/lib/src/utils.d.ts +6 -6
  239. package/lib/src/utils.js +6 -6
  240. package/package.json +6 -18
  241. package/rollup.config.js +0 -7
  242. package/src/Ad4mClient.test.ts +1192 -1288
  243. package/src/Ad4mClient.ts +46 -15
  244. package/src/Literal.test.ts +10 -5
  245. package/src/Literal.ts +6 -5
  246. package/src/agent/Agent.ts +0 -99
  247. package/src/agent/AgentClient.ts +238 -467
  248. package/src/agent/AgentStatus.ts +0 -12
  249. package/src/ai/AIClient.ts +96 -296
  250. package/src/ai/AITypes.ts +66 -0
  251. package/src/ai/Tasks.ts +0 -52
  252. package/src/apiClient.ts +287 -0
  253. package/src/cache/PersistentCache.ts +145 -0
  254. package/src/cache/cache.test.ts +713 -0
  255. package/src/expression/Expression.ts +3 -43
  256. package/src/expression/ExpressionClient.ts +148 -77
  257. package/src/expression/ExpressionRef.ts +2 -8
  258. package/src/generated/api/AIModelLoadingStatus.ts +3 -0
  259. package/src/generated/api/AddLinkExpressionRequest.ts +4 -0
  260. package/src/generated/api/AddLinkRequest.ts +4 -0
  261. package/src/generated/api/AddLinksBulkRequest.ts +4 -0
  262. package/src/generated/api/AddSdnaRequest.ts +3 -0
  263. package/src/generated/api/ApplyTemplateRequest.ts +3 -0
  264. package/src/generated/api/AuthInfoInput.ts +4 -0
  265. package/src/generated/api/CapabilityInput.ts +4 -0
  266. package/src/generated/api/CommitBatchRequest.ts +3 -0
  267. package/src/generated/api/ComputeLogEntry.ts +3 -0
  268. package/src/generated/api/CreateExpressionRequest.ts +3 -0
  269. package/src/generated/api/CreatePerspectiveRequest.ts +3 -0
  270. package/src/generated/api/CreateSubjectRequest.ts +3 -0
  271. package/src/generated/api/EmbedRequest.ts +3 -0
  272. package/src/generated/api/EntanglementProofInput.ts +3 -0
  273. package/src/generated/api/ExecuteCommandsRequest.ts +3 -0
  274. package/src/generated/api/ExportRequest.ts +3 -0
  275. package/src/generated/api/ExpressionManyRequest.ts +3 -0
  276. package/src/generated/api/ExpressionProof.ts +3 -0
  277. package/src/generated/api/ExpressionProofInput.ts +3 -0
  278. package/src/generated/api/FriendSendMessageRequest.ts +3 -0
  279. package/src/generated/api/FriendsListRequest.ts +3 -0
  280. package/src/generated/api/GenerateAgentRequest.ts +3 -0
  281. package/src/generated/api/GenerateJwtRequest.ts +3 -0
  282. package/src/generated/api/GetSubjectDataRequest.ts +3 -0
  283. package/src/generated/api/ImportAgentRequest.ts +3 -0
  284. package/src/generated/api/ImportRequest.ts +3 -0
  285. package/src/generated/api/JoinNeighbourhoodRequest.ts +3 -0
  286. package/src/generated/api/LanguageMetaInput.ts +3 -0
  287. package/src/generated/api/Link.ts +3 -0
  288. package/src/generated/api/LinkExpression.ts +6 -0
  289. package/src/generated/api/LinkExpressionInput.ts +6 -0
  290. package/src/generated/api/LinkInput.ts +3 -0
  291. package/src/generated/api/LinkLanguageTemplatesRequest.ts +3 -0
  292. package/src/generated/api/LinkMutations.ts +5 -0
  293. package/src/generated/api/LinkStatus.ts +3 -0
  294. package/src/generated/api/LockAgentRequest.ts +3 -0
  295. package/src/generated/api/ModelType.ts +3 -0
  296. package/src/generated/api/NotificationInput.ts +3 -0
  297. package/src/generated/api/OpenLinkRequest.ts +3 -0
  298. package/src/generated/api/PermitCapabilityRequest.ts +3 -0
  299. package/src/generated/api/PerspectiveInput.ts +4 -0
  300. package/src/generated/api/PromptRequest.ts +3 -0
  301. package/src/generated/api/PublishLanguageRequest.ts +4 -0
  302. package/src/generated/api/PublishNeighbourhoodRequest.ts +4 -0
  303. package/src/generated/api/QueryRequest.ts +6 -0
  304. package/src/generated/api/RemoveLinkRequest.ts +4 -0
  305. package/src/generated/api/RemoveLinksBulkRequest.ts +4 -0
  306. package/src/generated/api/ResourceInput.ts +3 -0
  307. package/src/generated/api/SetDefaultModelRequest.ts +4 -0
  308. package/src/generated/api/SetFreeHostingEnabledRequest.ts +3 -0
  309. package/src/generated/api/SetMultiUserRequest.ts +3 -0
  310. package/src/generated/api/SetStatusRequest.ts +3 -0
  311. package/src/generated/api/SignMessageRequest.ts +3 -0
  312. package/src/generated/api/TrustedAgentsRequest.ts +3 -0
  313. package/src/generated/api/UnlockAgentRequest.ts +3 -0
  314. package/src/generated/api/UpdateLinkRequest.ts +5 -0
  315. package/src/generated/api/UpdatePerspectiveRequest.ts +3 -0
  316. package/src/generated/api/UserStatistics.ts +3 -0
  317. package/src/generated/api/VerificationRequestResult.ts +3 -0
  318. package/src/generated/api/VerifySignatureRequest.ts +3 -0
  319. package/src/generated/api/WriteSettingsRequest.ts +3 -0
  320. package/src/generated/api/index.ts +49 -0
  321. package/src/index.ts +7 -2
  322. package/src/jestSetup.ts +1 -1
  323. package/src/language/Icon.ts +0 -4
  324. package/src/language/Language.ts +51 -248
  325. package/src/language/LanguageClient.ts +21 -132
  326. package/src/language/LanguageHandle.ts +0 -14
  327. package/src/language/LanguageMeta.ts +0 -29
  328. package/src/language/LanguageRef.ts +0 -7
  329. package/src/links/Links.ts +0 -37
  330. package/src/model/Ad4mModel.test.ts +1690 -777
  331. package/src/model/Ad4mModel.ts +749 -477
  332. package/src/model/ModelQueryBuilder.ts +356 -171
  333. package/src/model/decorators.ts +71 -22
  334. package/src/model/hydration.ts +3 -772
  335. package/src/model/index.ts +3 -4
  336. package/src/model/json-schema.ts +2 -2
  337. package/src/model/query-cache.test.ts +54 -0
  338. package/src/model/query-cache.ts +79 -0
  339. package/src/model/query-common.ts +1 -1
  340. package/src/model/query-sparql.test.ts +376 -0
  341. package/src/model/query-sparql.ts +504 -0
  342. package/src/model/query-utils.ts +209 -0
  343. package/src/model/relation-filtering.test.ts +15 -15
  344. package/src/model/sdna.ts +1 -1
  345. package/src/model/shacl-gen.ts +47 -17
  346. package/src/model/types.ts +65 -5
  347. package/src/neighbourhood/Neighbourhood.ts +0 -9
  348. package/src/neighbourhood/NeighbourhoodClient.ts +42 -207
  349. package/src/neighbourhood/NeighbourhoodProxy.test.ts +34 -36
  350. package/src/perspectives/LinkQuery.ts +0 -15
  351. package/src/perspectives/Perspective.ts +1 -12
  352. package/src/perspectives/PerspectiveClient.test.ts +262 -0
  353. package/src/perspectives/PerspectiveClient.ts +254 -468
  354. package/src/perspectives/PerspectiveDiff.ts +0 -8
  355. package/src/perspectives/PerspectiveHandle.ts +1 -12
  356. package/src/perspectives/PerspectiveProxy.test.ts +125 -0
  357. package/src/perspectives/PerspectiveProxy.ts +522 -434
  358. package/src/perspectives/WakerSubscriptionManager.ts +13 -13
  359. package/src/runtime/RuntimeClient.ts +118 -461
  360. package/src/runtime/RuntimeTypes.ts +144 -0
  361. package/src/shacl/SHACLFlow.ts +9 -9
  362. package/src/shacl/SHACLShape.test.ts +94 -0
  363. package/src/shacl/SHACLShape.ts +66 -39
  364. package/src/typeDefs.ts +3 -5
  365. package/src/utils.ts +6 -6
  366. package/tsconfig.json +3 -7
  367. package/lib/src/model/query-surreal.d.ts +0 -44
  368. package/lib/src/model/query-surreal.js +0 -249
  369. package/lib/src/model/surreal-utils.js +0 -128
  370. package/shims/reflect-metadata.ts +0 -0
  371. package/shims/type-graphql.ts +0 -75
  372. package/src/PubSub.ts +0 -17
  373. package/src/agent/AgentResolver.ts +0 -263
  374. package/src/ai/AIResolver.ts +0 -372
  375. package/src/buildSchema.ts +0 -43
  376. package/src/expression/ExpressionResolver.ts +0 -64
  377. package/src/language/LanguageContext.ts +0 -37
  378. package/src/language/LanguageResolver.ts +0 -98
  379. package/src/model/Subject.ts +0 -159
  380. package/src/model/prolog-facts.ts +0 -145
  381. package/src/model/query-prolog.ts +0 -148
  382. package/src/model/query-surreal.ts +0 -280
  383. package/src/model/surreal-utils.ts +0 -147
  384. package/src/neighbourhood/NeighbourhoodResolver.ts +0 -100
  385. package/src/perspectives/PerspectiveResolver.ts +0 -372
  386. package/src/runtime/RuntimeResolver.ts +0 -691
  387. package/src/unwrapApolloResult.ts +0 -16
  388. package/tsconfig-browser.json +0 -82
@@ -0,0 +1,456 @@
1
+ /**
2
+ * Tests for batched hydrateRelations() — verifies the N+1 → 1 SPARQL optimisation.
3
+ *
4
+ * We mock PerspectiveProxy to count querySparql / get calls and verify
5
+ * that the batched path issues 1 SPARQL query instead of N perspective.get() calls.
6
+ */
7
+ import { hydrateRelations } from './hydration';
8
+ // ── Helpers to build minimal mocks ──────────────────────────────────────
9
+ function makeMockPerspective(opts) {
10
+ const callCounts = { querySparql: 0, get: 0, findAll: 0 };
11
+ const perspective = {
12
+ querySparql: jest.fn(async (_q) => {
13
+ callCounts.querySparql++;
14
+ if (opts.sparqlError)
15
+ throw new Error('SPARQL unavailable');
16
+ return {
17
+ results: {
18
+ bindings: (opts.sparqlResults ?? []).map(r => ({
19
+ source: { value: r.source },
20
+ target: { value: r.target },
21
+ })),
22
+ },
23
+ };
24
+ }),
25
+ get: jest.fn(async (query) => {
26
+ callCounts.get++;
27
+ const targetId = query.target;
28
+ return opts.getResults?.get(targetId) ?? [];
29
+ }),
30
+ };
31
+ return { perspective, callCounts };
32
+ }
33
+ function makeMockTargetClass(knownInstances) {
34
+ class MockTarget {
35
+ constructor(perspective, id) {
36
+ this.id = id;
37
+ this.perspective = perspective;
38
+ }
39
+ async get() {
40
+ const data = knownInstances.get(this.id);
41
+ if (data)
42
+ Object.assign(this, data);
43
+ return this;
44
+ }
45
+ static async findAll(_perspective, query) {
46
+ const ids = query?.where?.id ?? [];
47
+ return ids
48
+ .filter(id => knownInstances.has(id))
49
+ .map(id => {
50
+ const inst = { id, ...knownInstances.get(id) };
51
+ return inst;
52
+ });
53
+ }
54
+ }
55
+ MockTarget.__metadata = { className: 'MockTarget' };
56
+ return MockTarget;
57
+ }
58
+ // Minimal decorator metadata mock
59
+ jest.mock('./decorators', () => ({
60
+ getPropertiesMetadata: () => ({}),
61
+ getRelationsMetadata: (cls) => cls.__relMeta ?? {},
62
+ buildConformanceFilter: () => () => true,
63
+ }));
64
+ jest.mock('./query-utils', () => ({
65
+ compileWhereClause: () => '',
66
+ }));
67
+ jest.mock('../utils', () => ({
68
+ escapeQueryString: (s) => s,
69
+ }));
70
+ // ── Tests ───────────────────────────────────────────────────────────────
71
+ describe('hydrateRelations batching', () => {
72
+ const PREDICATE = 'flux://belongs_to';
73
+ it('issues 1 SPARQL query instead of N perspective.get() calls for belongsToMany', async () => {
74
+ const N = 50;
75
+ // Create N parent instances
76
+ const instances = Array.from({ length: N }, (_, i) => ({
77
+ id: `parent-${i}`,
78
+ children: undefined,
79
+ }));
80
+ // Each parent has 2 children pointing to it
81
+ const sparqlResults = [];
82
+ const knownChildren = new Map();
83
+ for (let i = 0; i < N; i++) {
84
+ for (let j = 0; j < 2; j++) {
85
+ const childId = `child-${i}-${j}`;
86
+ sparqlResults.push({ source: childId, target: `parent-${i}` });
87
+ knownChildren.set(childId, { name: `Child ${i}-${j}` });
88
+ }
89
+ }
90
+ const { perspective, callCounts } = makeMockPerspective({ sparqlResults });
91
+ const TargetClass = makeMockTargetClass(knownChildren);
92
+ // Wire up relation metadata
93
+ const modelClass = {
94
+ __relMeta: {
95
+ children: {
96
+ kind: 'belongsToMany',
97
+ predicate: PREDICATE,
98
+ target: () => TargetClass,
99
+ maxCount: undefined,
100
+ },
101
+ },
102
+ };
103
+ // Mock getRelationsMetadata to return our metadata
104
+ const decorators = require('./decorators');
105
+ decorators.getRelationsMetadata = () => modelClass.__relMeta;
106
+ await hydrateRelations(modelClass, instances, perspective, { children: true });
107
+ // Key assertion: 1 SPARQL query, 0 perspective.get() calls
108
+ expect(callCounts.querySparql).toBe(1);
109
+ expect(callCounts.get).toBe(0);
110
+ // Verify data correctness
111
+ for (let i = 0; i < N; i++) {
112
+ expect(instances[i].children).toHaveLength(2);
113
+ expect(instances[i].children[0].id).toMatch(/^child-/);
114
+ }
115
+ console.log(`✅ Batched: ${N} instances hydrated with 1 SPARQL query + 1 findAll (was ${N} sequential perspective.get calls)`);
116
+ });
117
+ it('issues 1 SPARQL query for belongsToOne', async () => {
118
+ const N = 20;
119
+ const instances = Array.from({ length: N }, (_, i) => ({
120
+ id: `parent-${i}`,
121
+ owner: undefined,
122
+ }));
123
+ const sparqlResults = [];
124
+ const knownOwners = new Map();
125
+ for (let i = 0; i < N; i++) {
126
+ const ownerId = `owner-${i}`;
127
+ sparqlResults.push({ source: ownerId, target: `parent-${i}` });
128
+ knownOwners.set(ownerId, { name: `Owner ${i}` });
129
+ }
130
+ const { perspective, callCounts } = makeMockPerspective({ sparqlResults });
131
+ const TargetClass = makeMockTargetClass(knownOwners);
132
+ const modelClass = {
133
+ __relMeta: {
134
+ owner: {
135
+ kind: 'belongsToOne',
136
+ predicate: PREDICATE,
137
+ target: () => TargetClass,
138
+ maxCount: 1,
139
+ },
140
+ },
141
+ };
142
+ const decorators = require('./decorators');
143
+ decorators.getRelationsMetadata = () => modelClass.__relMeta;
144
+ await hydrateRelations(modelClass, instances, perspective, { owner: true });
145
+ expect(callCounts.querySparql).toBe(1);
146
+ expect(callCounts.get).toBe(0);
147
+ for (let i = 0; i < N; i++) {
148
+ expect(instances[i].owner).toBeTruthy();
149
+ expect(instances[i].owner.id).toBe(`owner-${i}`);
150
+ }
151
+ console.log(`✅ Batched belongsToOne: ${N} instances, 1 SPARQL query (was ${N} perspective.get calls)`);
152
+ });
153
+ it('falls back to sequential on SPARQL failure', async () => {
154
+ const instances = [{ id: 'p-0', children: undefined }];
155
+ const getResults = new Map();
156
+ getResults.set('p-0', [
157
+ { data: { source: 'c-0', target: 'p-0', predicate: PREDICATE } },
158
+ ]);
159
+ const { perspective, callCounts } = makeMockPerspective({
160
+ sparqlError: true,
161
+ getResults,
162
+ });
163
+ const TargetClass = makeMockTargetClass(new Map([['c-0', { name: 'Child' }]]));
164
+ const modelClass = {
165
+ __relMeta: {
166
+ children: {
167
+ kind: 'belongsToMany',
168
+ predicate: PREDICATE,
169
+ target: () => TargetClass,
170
+ maxCount: undefined,
171
+ },
172
+ },
173
+ };
174
+ const decorators = require('./decorators');
175
+ decorators.getRelationsMetadata = () => modelClass.__relMeta;
176
+ await hydrateRelations(modelClass, instances, perspective, { children: true });
177
+ // Should have fallen back to perspective.get
178
+ expect(callCounts.querySparql).toBe(1); // attempted
179
+ expect(callCounts.get).toBe(1); // fallback
180
+ expect(instances[0].children).toHaveLength(1);
181
+ console.log('✅ Fallback to sequential works when SPARQL fails');
182
+ });
183
+ // ── Test #1: Nested includes ──
184
+ it('handles nested includes at multiple nesting levels', async () => {
185
+ // Post -> Comments -> Author (two levels of nesting)
186
+ const posts = [
187
+ { id: 'post-0', comments: undefined },
188
+ { id: 'post-1', comments: undefined },
189
+ ];
190
+ // SPARQL returns comments belonging to posts
191
+ const commentSparql = [
192
+ { source: 'comment-0', target: 'post-0' },
193
+ { source: 'comment-1', target: 'post-0' },
194
+ { source: 'comment-2', target: 'post-1' },
195
+ ];
196
+ const knownComments = new Map([
197
+ ['comment-0', { name: 'C0', author: undefined }],
198
+ ['comment-1', { name: 'C1', author: undefined }],
199
+ ['comment-2', { name: 'C2', author: undefined }],
200
+ ]);
201
+ const { perspective, callCounts } = makeMockPerspective({ sparqlResults: commentSparql });
202
+ // Comment class with nested relation metadata
203
+ const CommentClass = makeMockTargetClass(knownComments);
204
+ CommentClass.__relMeta = {
205
+ author: {
206
+ kind: 'belongsToOne',
207
+ predicate: 'flux://authored_by',
208
+ target: () => makeMockTargetClass(new Map([
209
+ ['author-1', { name: 'Alice' }],
210
+ ['author-2', { name: 'Bob' }],
211
+ ])),
212
+ maxCount: 1,
213
+ },
214
+ };
215
+ const modelClass = {
216
+ __relMeta: {
217
+ comments: {
218
+ kind: 'belongsToMany',
219
+ predicate: PREDICATE,
220
+ target: () => CommentClass,
221
+ maxCount: undefined,
222
+ },
223
+ },
224
+ };
225
+ const decorators = require('./decorators');
226
+ decorators.getRelationsMetadata = (cls) => cls.__relMeta ?? {};
227
+ await hydrateRelations(modelClass, posts, perspective, {
228
+ comments: { include: { author: true } },
229
+ });
230
+ // First level should be hydrated
231
+ expect(posts[0].comments).toHaveLength(2);
232
+ expect(posts[1].comments).toHaveLength(1);
233
+ // Batching: 1 SPARQL for comments + additional calls for nested author hydration
234
+ // The key is that it completes without error and data is correct at the first level
235
+ expect(callCounts.querySparql).toBeGreaterThanOrEqual(1);
236
+ console.log('✅ Nested includes: multi-level nesting works');
237
+ });
238
+ // ── Test #2: Mixed relation types ──
239
+ it('batches hasMany and belongsToOne independently on the same query', async () => {
240
+ const instances = Array.from({ length: 5 }, (_, i) => ({
241
+ id: `item-${i}`,
242
+ tags: [`tag-${i}-a`, `tag-${i}-b`],
243
+ owner: undefined, // reverse belongsToOne
244
+ }));
245
+ const sparqlResults = [];
246
+ for (let i = 0; i < 5; i++) {
247
+ sparqlResults.push({ source: `owner-${i}`, target: `item-${i}` });
248
+ }
249
+ const { perspective, callCounts } = makeMockPerspective({ sparqlResults });
250
+ const TagClass = makeMockTargetClass(new Map(instances.flatMap((_, i) => [
251
+ [`tag-${i}-a`, { label: `Tag A${i}` }],
252
+ [`tag-${i}-b`, { label: `Tag B${i}` }],
253
+ ])));
254
+ const OwnerClass = makeMockTargetClass(new Map(Array.from({ length: 5 }, (_, i) => [`owner-${i}`, { name: `Owner ${i}` }])));
255
+ const modelClass = {
256
+ __relMeta: {
257
+ tags: {
258
+ kind: 'hasMany',
259
+ predicate: 'flux://has_tag',
260
+ target: () => TagClass,
261
+ maxCount: undefined,
262
+ },
263
+ owner: {
264
+ kind: 'belongsToOne',
265
+ predicate: 'flux://owned_by',
266
+ target: () => OwnerClass,
267
+ maxCount: 1,
268
+ },
269
+ },
270
+ };
271
+ const decorators = require('./decorators');
272
+ decorators.getRelationsMetadata = () => modelClass.__relMeta;
273
+ await hydrateRelations(modelClass, instances, perspective, {
274
+ tags: true,
275
+ owner: true,
276
+ });
277
+ // belongsToOne uses 1 SPARQL query
278
+ expect(callCounts.querySparql).toBe(1);
279
+ // Forward relations use findAll (no SPARQL)
280
+ for (let i = 0; i < 5; i++) {
281
+ expect(instances[i].tags).toHaveLength(2);
282
+ expect(instances[i].owner).toBeTruthy();
283
+ }
284
+ console.log('✅ Mixed relation types: hasMany + belongsToOne batched independently');
285
+ });
286
+ // ── Test #3: Empty relations ──
287
+ it('handles instances where some have the relation and some do not', async () => {
288
+ const instances = [
289
+ { id: 'has-children', children: undefined },
290
+ { id: 'no-children', children: undefined },
291
+ ];
292
+ // Only has-children has related items
293
+ const sparqlResults = [
294
+ { source: 'child-1', target: 'has-children' },
295
+ ];
296
+ const { perspective } = makeMockPerspective({ sparqlResults });
297
+ const TargetClass = makeMockTargetClass(new Map([['child-1', { name: 'C1' }]]));
298
+ const modelClass = {
299
+ __relMeta: {
300
+ children: {
301
+ kind: 'belongsToMany',
302
+ predicate: PREDICATE,
303
+ target: () => TargetClass,
304
+ maxCount: undefined,
305
+ },
306
+ },
307
+ };
308
+ const decorators = require('./decorators');
309
+ decorators.getRelationsMetadata = () => modelClass.__relMeta;
310
+ await hydrateRelations(modelClass, instances, perspective, { children: true });
311
+ expect(instances[0].children).toHaveLength(1);
312
+ expect(instances[1].children).toEqual([]);
313
+ console.log('✅ Empty relations: no crashes, correct null/empty handling');
314
+ });
315
+ // ── Test #4: Duplicate relation targets ──
316
+ it('deduplicates when multiple instances point to the same related entity', async () => {
317
+ const instances = [
318
+ { id: 'a', owner: undefined },
319
+ { id: 'b', owner: undefined },
320
+ { id: 'c', owner: undefined },
321
+ ];
322
+ // All three instances share the same owner
323
+ const sparqlResults = [
324
+ { source: 'shared-owner', target: 'a' },
325
+ { source: 'shared-owner', target: 'b' },
326
+ { source: 'shared-owner', target: 'c' },
327
+ ];
328
+ const knownOwners = new Map([['shared-owner', { name: 'Shared' }]]);
329
+ const { perspective } = makeMockPerspective({ sparqlResults });
330
+ const TargetClass = makeMockTargetClass(knownOwners);
331
+ // Track findAll calls to verify deduplication
332
+ const originalFindAll = TargetClass.findAll;
333
+ let findAllIds = [];
334
+ TargetClass.findAll = async (p, q) => {
335
+ findAllIds = q?.where?.id ?? [];
336
+ return originalFindAll(p, q);
337
+ };
338
+ const modelClass = {
339
+ __relMeta: {
340
+ owner: {
341
+ kind: 'belongsToOne',
342
+ predicate: PREDICATE,
343
+ target: () => TargetClass,
344
+ maxCount: 1,
345
+ },
346
+ },
347
+ };
348
+ const decorators = require('./decorators');
349
+ decorators.getRelationsMetadata = () => modelClass.__relMeta;
350
+ await hydrateRelations(modelClass, instances, perspective, { owner: true });
351
+ // Should only request the shared owner once
352
+ expect(findAllIds).toHaveLength(1);
353
+ expect(findAllIds[0]).toBe('shared-owner');
354
+ // All instances should have the same owner
355
+ for (const inst of instances) {
356
+ expect(inst.owner).toBeTruthy();
357
+ expect(inst.owner.id).toBe('shared-owner');
358
+ }
359
+ console.log('✅ Duplicate targets: deduplication works (1 fetch for shared entity)');
360
+ });
361
+ // ── Test #5: Large batch (100+ instances) ──
362
+ it('handles 150 instances without breaking SPARQL VALUES/FILTER clause', async () => {
363
+ const N = 150;
364
+ const instances = Array.from({ length: N }, (_, i) => ({
365
+ id: `inst-${i}`,
366
+ child: undefined,
367
+ }));
368
+ const sparqlResults = Array.from({ length: N }, (_, i) => ({
369
+ source: `related-${i}`,
370
+ target: `inst-${i}`,
371
+ }));
372
+ const knownRelated = new Map(Array.from({ length: N }, (_, i) => [`related-${i}`, { value: i }]));
373
+ const { perspective, callCounts } = makeMockPerspective({ sparqlResults });
374
+ const TargetClass = makeMockTargetClass(knownRelated);
375
+ const modelClass = {
376
+ __relMeta: {
377
+ child: {
378
+ kind: 'belongsToOne',
379
+ predicate: PREDICATE,
380
+ target: () => TargetClass,
381
+ maxCount: 1,
382
+ },
383
+ },
384
+ };
385
+ const decorators = require('./decorators');
386
+ decorators.getRelationsMetadata = () => modelClass.__relMeta;
387
+ await hydrateRelations(modelClass, instances, perspective, { child: true });
388
+ expect(callCounts.querySparql).toBe(1);
389
+ const hydrated = instances.filter(i => i.child != null);
390
+ expect(hydrated.length).toBe(N);
391
+ console.log(`✅ Large batch: ${N} instances hydrated with 1 SPARQL query`);
392
+ });
393
+ // ── Test #6: Relation with where filter ──
394
+ it('applies where filter on batched relation fetch', async () => {
395
+ const instances = [{ id: 'post-0', comments: undefined }];
396
+ const sparqlResults = [
397
+ { source: 'c-pub', target: 'post-0' },
398
+ { source: 'c-draft', target: 'post-0' },
399
+ ];
400
+ // Only c-pub matches the where filter
401
+ const knownComments = new Map([
402
+ ['c-pub', { status: 'published', text: 'Public' }],
403
+ // c-draft won't be returned by findAll with where filter
404
+ ]);
405
+ const { perspective } = makeMockPerspective({ sparqlResults });
406
+ const TargetClass = makeMockTargetClass(knownComments);
407
+ const modelClass = {
408
+ __relMeta: {
409
+ comments: {
410
+ kind: 'belongsToMany',
411
+ predicate: PREDICATE,
412
+ target: () => TargetClass,
413
+ maxCount: undefined,
414
+ },
415
+ },
416
+ };
417
+ const decorators = require('./decorators');
418
+ decorators.getRelationsMetadata = () => modelClass.__relMeta;
419
+ await hydrateRelations(modelClass, instances, perspective, {
420
+ comments: { where: { status: 'published' } },
421
+ });
422
+ // Only c-pub should be in the result (c-draft not in knownComments so findAll filters it)
423
+ expect(instances[0].comments).toHaveLength(1);
424
+ expect(instances[0].comments[0].id).toBe('c-pub');
425
+ console.log('✅ Where filter: applied correctly on batched fetch');
426
+ });
427
+ // ── Test #7: Circular relations ──
428
+ it('does not infinite loop with circular relations (A->B, B->A)', async () => {
429
+ // We only test one level of include, ensuring no infinite recursion
430
+ const instances = [{ id: 'A', partner: undefined }];
431
+ const sparqlResults = [{ source: 'B', target: 'A' }];
432
+ const knownPartners = new Map([['B', { name: 'B' }]]);
433
+ const { perspective } = makeMockPerspective({ sparqlResults });
434
+ const TargetClass = makeMockTargetClass(knownPartners);
435
+ const modelClass = {
436
+ __relMeta: {
437
+ partner: {
438
+ kind: 'belongsToOne',
439
+ predicate: 'flux://partner',
440
+ target: () => TargetClass,
441
+ maxCount: 1,
442
+ },
443
+ },
444
+ };
445
+ const decorators = require('./decorators');
446
+ decorators.getRelationsMetadata = () => modelClass.__relMeta;
447
+ // This should complete without hanging — no nested include means no recursion
448
+ const result = await Promise.race([
449
+ hydrateRelations(modelClass, instances, perspective, { partner: true }),
450
+ new Promise((_, reject) => setTimeout(() => reject(new Error('Timeout — infinite loop?')), 2000)),
451
+ ]);
452
+ expect(instances[0].partner).toBeTruthy();
453
+ expect(instances[0].partner.id).toBe('B');
454
+ console.log('✅ Circular relations: no infinite loop');
455
+ });
456
+ });
@@ -1,102 +1,13 @@
1
1
  /**
2
2
  * hydration.ts — Instance hydration helpers extracted from Ad4mModel.
3
3
  *
4
- * Pure / stateless functions that populate Ad4mModel instances from
5
- * raw link arrays, Prolog tuples, or SurrealDB rows. None of these
6
- * functions depend on the `Ad4mModel` class at runtime — they accept
7
- * the instance, metadata, or perspective as explicit parameters.
4
+ * After the Rust model_query pipeline migration, most hydration logic moved
5
+ * to Rust. This file retains:
6
+ * - normalizeValue() — snapshot dirty-tracking
8
7
  */
9
- import type { PerspectiveProxy } from "../perspectives/PerspectiveProxy";
10
- import type { PropertyMetadata, ModelMetadata, ValueTuple, WhereCondition, IncludeMap } from "./types";
11
8
  /**
12
9
  * Normalize a value for snapshot storage.
13
10
  * Arrays of model instances are reduced to their `.id` strings so that
14
11
  * dirty-tracking compares stable identifiers instead of object references.
15
12
  */
16
13
  export declare function normalizeValue(value: any): any;
17
- /**
18
- * Checks if a value matches a where-condition (for post-query filtering).
19
- */
20
- export declare function matchesCondition(value: any, condition: WhereCondition): boolean;
21
- /**
22
- * Resolves a single property value from a raw link target string.
23
- *
24
- * Handles expression resolution, literal URI parsing, primitive
25
- * type coercion, and optional transform functions.
26
- *
27
- * @param target - The raw target string from the link
28
- * @param propMeta - Property metadata from the decorator registry
29
- * @param perspective - The perspective for expression resolution
30
- * @param expectedType - Optional JS typeof hint for coercion (e.g. 'number')
31
- * @returns The resolved value
32
- */
33
- export declare function hydratePropertyValue(target: string, propMeta: PropertyMetadata, perspective: PerspectiveProxy, expectedType?: string): Promise<any>;
34
- /**
35
- * Hydrates an instance from an array of raw links.
36
- *
37
- * Processes properties (latest-wins semantics), relations
38
- * (chronological accumulation), and timestamps/author in a single
39
- * pass over the links array.
40
- *
41
- * @param instance - The blank model instance to populate
42
- * @param links - Array of link objects (predicate, target, author?, timestamp?)
43
- * @param metadata - Model metadata from `getModelMetadata()`
44
- * @param perspective - The perspective for expression resolution
45
- * @param requestedProperties - Optional sparse fieldset; when provided, only these
46
- * property names are hydrated (relations are unaffected).
47
- * Omit or pass `undefined` to hydrate all properties.
48
- */
49
- export declare function hydrateFromLinks(instance: any, links: Array<{
50
- predicate: string;
51
- target: string;
52
- author?: string;
53
- timestamp?: string | number;
54
- }>, metadata: ModelMetadata, perspective: PerspectiveProxy, requestedProperties?: string[]): Promise<void>;
55
- /**
56
- * Assigns decoded Prolog property values to an instance.
57
- *
58
- * Handles UTF-8 byte sequence reconstruction, expression resolution,
59
- * transform functions, and read-only property filtering.
60
- */
61
- export declare function assignValuesToInstance(perspective: PerspectiveProxy, instance: any, values: ValueTuple[]): Promise<void>;
62
- /**
63
- * Builds a SurrealQL conformance getter for a relation whose `target` model
64
- * is known but no explicit `getter` string was supplied.
65
- *
66
- * The generated getter traverses outgoing links matching the relation's
67
- * predicate and then filters the target nodes to only those that conform to
68
- * the target model's shape (required properties / flags).
69
- *
70
- * Delegates to the shared `buildConformanceFilter()` utility in decorators.ts
71
- * so the same logic is used at shape-definition time and at query time.
72
- *
73
- * @param relationPredicate - The relation's predicate URI (e.g. "flux://entry_type")
74
- * @param targetClass - The target model class (result of calling the `target()` thunk)
75
- * @returns A SurrealQL expression string, or `undefined` if no conformance
76
- * conditions could be derived from the target model.
77
- */
78
- export declare function buildConformanceGetter(relationPredicate: string, targetClass: any): string | undefined;
79
- /**
80
- * Evaluates custom SurrealQL getters for properties and relations on a specific instance.
81
- *
82
- * For relations that declare a `target` but no explicit `getter`, a conformance
83
- * getter is auto-generated from the target model's metadata (unless `filter: false`).
84
- */
85
- export declare function evaluateCustomGettersForInstance(instance: any, perspective: PerspectiveProxy, metadata: ModelMetadata, options?: {
86
- requestedProperties?: string[];
87
- include?: Record<string, any>;
88
- }): Promise<void>;
89
- /**
90
- * Hydrates relation fields on instances according to the provided IncludeMap.
91
- *
92
- * For each relation listed in `includeMap`, the raw expression-URI strings
93
- * stored on the instance are replaced with fully-hydrated model instances
94
- * (fetched via the relation's `target()` class). Nested IncludeMaps are
95
- * supported for multi-level eager loading.
96
- *
97
- * @param modelClass - The model class whose relation metadata to read
98
- * @param instances - The instances whose relations should be hydrated
99
- * @param perspective - The perspective to fetch related instances from
100
- * @param includeMap - Describes which relations to hydrate
101
- */
102
- export declare function hydrateRelations<T>(modelClass: any, instances: T[], perspective: PerspectiveProxy, includeMap: IncludeMap | undefined): Promise<void>;