@coasys/ad4m 0.13.0-test-3 → 0.13.0-test-5

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 (337) hide show
  1. package/README.md +2 -25
  2. package/jest-setup.ts +1 -1
  3. package/lib/index.cjs +6717 -15519
  4. package/lib/index.js +4811 -13662
  5. package/lib/src/Ad4mClient.d.ts +7 -3
  6. package/lib/src/Ad4mClient.js +39 -13
  7. package/lib/src/agent/Agent.js +26 -272
  8. package/lib/src/agent/AgentClient.d.ts +10 -21
  9. package/lib/src/agent/AgentClient.js +75 -427
  10. package/lib/src/agent/AgentStatus.js +2 -37
  11. package/lib/src/ai/AIClient.d.ts +12 -4
  12. package/lib/src/ai/AIClient.js +81 -285
  13. package/lib/src/ai/AITypes.d.ts +55 -0
  14. package/lib/src/ai/AITypes.js +18 -0
  15. package/lib/src/ai/Tasks.js +10 -133
  16. package/lib/src/apiClient.d.ts +52 -0
  17. package/lib/src/apiClient.js +231 -0
  18. package/lib/src/expression/Expression.d.ts +1 -1
  19. package/lib/src/expression/Expression.js +13 -122
  20. package/lib/src/expression/ExpressionClient.d.ts +3 -3
  21. package/lib/src/expression/ExpressionClient.js +13 -76
  22. package/lib/src/expression/ExpressionRef.js +2 -25
  23. package/lib/src/generated/api/AIModelLoadingStatus.d.ts +7 -0
  24. package/lib/src/generated/api/AIModelLoadingStatus.js +2 -0
  25. package/lib/src/generated/api/AddLinkExpressionRequest.d.ts +6 -0
  26. package/lib/src/generated/api/AddLinkExpressionRequest.js +1 -0
  27. package/lib/src/generated/api/AddLinkRequest.d.ts +6 -0
  28. package/lib/src/generated/api/AddLinkRequest.js +1 -0
  29. package/lib/src/generated/api/AddLinksBulkRequest.d.ts +6 -0
  30. package/lib/src/generated/api/AddLinksBulkRequest.js +1 -0
  31. package/lib/src/generated/api/AddSdnaRequest.d.ts +6 -0
  32. package/lib/src/generated/api/AddSdnaRequest.js +2 -0
  33. package/lib/src/generated/api/ApplyTemplateRequest.d.ts +4 -0
  34. package/lib/src/generated/api/ApplyTemplateRequest.js +2 -0
  35. package/lib/src/generated/api/AuthInfoInput.d.ts +10 -0
  36. package/lib/src/generated/api/AuthInfoInput.js +1 -0
  37. package/lib/src/generated/api/CapabilityInput.d.ts +5 -0
  38. package/lib/src/generated/api/CapabilityInput.js +1 -0
  39. package/lib/src/generated/api/CommitBatchRequest.d.ts +3 -0
  40. package/lib/src/generated/api/CommitBatchRequest.js +2 -0
  41. package/lib/src/generated/api/ComputeLogEntry.d.ts +9 -0
  42. package/lib/src/generated/api/ComputeLogEntry.js +2 -0
  43. package/lib/src/generated/api/CreateExpressionRequest.d.ts +4 -0
  44. package/lib/src/generated/api/CreateExpressionRequest.js +2 -0
  45. package/lib/src/generated/api/CreatePerspectiveRequest.d.ts +3 -0
  46. package/lib/src/generated/api/CreatePerspectiveRequest.js +2 -0
  47. package/lib/src/generated/api/CreateSubjectRequest.d.ts +6 -0
  48. package/lib/src/generated/api/CreateSubjectRequest.js +2 -0
  49. package/lib/src/generated/api/EmbedRequest.d.ts +4 -0
  50. package/lib/src/generated/api/EmbedRequest.js +2 -0
  51. package/lib/src/generated/api/EntanglementProofInput.d.ts +6 -0
  52. package/lib/src/generated/api/EntanglementProofInput.js +2 -0
  53. package/lib/src/generated/api/ExecuteCommandsRequest.d.ts +4 -0
  54. package/lib/src/generated/api/ExecuteCommandsRequest.js +2 -0
  55. package/lib/src/generated/api/ExportRequest.d.ts +5 -0
  56. package/lib/src/generated/api/ExportRequest.js +2 -0
  57. package/lib/src/generated/api/ExpressionManyRequest.d.ts +3 -0
  58. package/lib/src/generated/api/ExpressionManyRequest.js +2 -0
  59. package/lib/src/generated/api/ExpressionProof.d.ts +4 -0
  60. package/lib/src/generated/api/ExpressionProof.js +2 -0
  61. package/lib/src/generated/api/ExpressionProofInput.d.ts +6 -0
  62. package/lib/src/generated/api/ExpressionProofInput.js +2 -0
  63. package/lib/src/generated/api/FriendSendMessageRequest.d.ts +3 -0
  64. package/lib/src/generated/api/FriendSendMessageRequest.js +2 -0
  65. package/lib/src/generated/api/FriendsListRequest.d.ts +3 -0
  66. package/lib/src/generated/api/FriendsListRequest.js +2 -0
  67. package/lib/src/generated/api/GenerateAgentRequest.d.ts +3 -0
  68. package/lib/src/generated/api/GenerateAgentRequest.js +2 -0
  69. package/lib/src/generated/api/GenerateJwtRequest.d.ts +4 -0
  70. package/lib/src/generated/api/GenerateJwtRequest.js +2 -0
  71. package/lib/src/generated/api/GetSubjectDataRequest.d.ts +4 -0
  72. package/lib/src/generated/api/GetSubjectDataRequest.js +2 -0
  73. package/lib/src/generated/api/ImportAgentRequest.d.ts +6 -0
  74. package/lib/src/generated/api/ImportAgentRequest.js +2 -0
  75. package/lib/src/generated/api/ImportRequest.d.ts +4 -0
  76. package/lib/src/generated/api/ImportRequest.js +2 -0
  77. package/lib/src/generated/api/JoinNeighbourhoodRequest.d.ts +3 -0
  78. package/lib/src/generated/api/JoinNeighbourhoodRequest.js +2 -0
  79. package/lib/src/generated/api/LanguageMetaInput.d.ts +6 -0
  80. package/lib/src/generated/api/LanguageMetaInput.js +2 -0
  81. package/lib/src/generated/api/Link.d.ts +5 -0
  82. package/lib/src/generated/api/Link.js +2 -0
  83. package/lib/src/generated/api/LinkExpression.d.ts +10 -0
  84. package/lib/src/generated/api/LinkExpression.js +1 -0
  85. package/lib/src/generated/api/LinkExpressionInput.d.ts +10 -0
  86. package/lib/src/generated/api/LinkExpressionInput.js +1 -0
  87. package/lib/src/generated/api/LinkInput.d.ts +5 -0
  88. package/lib/src/generated/api/LinkInput.js +2 -0
  89. package/lib/src/generated/api/LinkLanguageTemplatesRequest.d.ts +3 -0
  90. package/lib/src/generated/api/LinkLanguageTemplatesRequest.js +2 -0
  91. package/lib/src/generated/api/LinkMutations.d.ts +6 -0
  92. package/lib/src/generated/api/LinkMutations.js +1 -0
  93. package/lib/src/generated/api/LinkStatus.d.ts +1 -0
  94. package/lib/src/generated/api/LinkStatus.js +2 -0
  95. package/lib/src/generated/api/LockAgentRequest.d.ts +3 -0
  96. package/lib/src/generated/api/LockAgentRequest.js +2 -0
  97. package/lib/src/generated/api/ModelType.d.ts +1 -0
  98. package/lib/src/generated/api/ModelType.js +2 -0
  99. package/lib/src/generated/api/NotificationInput.d.ts +10 -0
  100. package/lib/src/generated/api/NotificationInput.js +2 -0
  101. package/lib/src/generated/api/OpenLinkRequest.d.ts +3 -0
  102. package/lib/src/generated/api/OpenLinkRequest.js +2 -0
  103. package/lib/src/generated/api/PermitCapabilityRequest.d.ts +3 -0
  104. package/lib/src/generated/api/PermitCapabilityRequest.js +2 -0
  105. package/lib/src/generated/api/PerspectiveInput.d.ts +4 -0
  106. package/lib/src/generated/api/PerspectiveInput.js +1 -0
  107. package/lib/src/generated/api/PromptRequest.d.ts +4 -0
  108. package/lib/src/generated/api/PromptRequest.js +2 -0
  109. package/lib/src/generated/api/PublishLanguageRequest.d.ts +5 -0
  110. package/lib/src/generated/api/PublishLanguageRequest.js +1 -0
  111. package/lib/src/generated/api/PublishNeighbourhoodRequest.d.ts +6 -0
  112. package/lib/src/generated/api/PublishNeighbourhoodRequest.js +1 -0
  113. package/lib/src/generated/api/QueryRequest.d.ts +7 -0
  114. package/lib/src/generated/api/QueryRequest.js +2 -0
  115. package/lib/src/generated/api/RemoveLinkRequest.d.ts +5 -0
  116. package/lib/src/generated/api/RemoveLinkRequest.js +1 -0
  117. package/lib/src/generated/api/RemoveLinksBulkRequest.d.ts +5 -0
  118. package/lib/src/generated/api/RemoveLinksBulkRequest.js +1 -0
  119. package/lib/src/generated/api/ResourceInput.d.ts +4 -0
  120. package/lib/src/generated/api/ResourceInput.js +2 -0
  121. package/lib/src/generated/api/SetDefaultModelRequest.d.ts +4 -0
  122. package/lib/src/generated/api/SetDefaultModelRequest.js +1 -0
  123. package/lib/src/generated/api/SetFreeHostingEnabledRequest.d.ts +3 -0
  124. package/lib/src/generated/api/SetFreeHostingEnabledRequest.js +2 -0
  125. package/lib/src/generated/api/SetMultiUserRequest.d.ts +3 -0
  126. package/lib/src/generated/api/SetMultiUserRequest.js +2 -0
  127. package/lib/src/generated/api/SetStatusRequest.d.ts +3 -0
  128. package/lib/src/generated/api/SetStatusRequest.js +2 -0
  129. package/lib/src/generated/api/SignMessageRequest.d.ts +3 -0
  130. package/lib/src/generated/api/SignMessageRequest.js +2 -0
  131. package/lib/src/generated/api/TrustedAgentsRequest.d.ts +3 -0
  132. package/lib/src/generated/api/TrustedAgentsRequest.js +2 -0
  133. package/lib/src/generated/api/UnlockAgentRequest.d.ts +4 -0
  134. package/lib/src/generated/api/UnlockAgentRequest.js +2 -0
  135. package/lib/src/generated/api/UpdateLinkRequest.d.ts +7 -0
  136. package/lib/src/generated/api/UpdateLinkRequest.js +1 -0
  137. package/lib/src/generated/api/UpdatePerspectiveRequest.d.ts +3 -0
  138. package/lib/src/generated/api/UpdatePerspectiveRequest.js +2 -0
  139. package/lib/src/generated/api/UserStatistics.d.ts +9 -0
  140. package/lib/src/generated/api/UserStatistics.js +2 -0
  141. package/lib/src/generated/api/VerificationRequestResult.d.ts +6 -0
  142. package/lib/src/generated/api/VerificationRequestResult.js +2 -0
  143. package/lib/src/generated/api/VerifySignatureRequest.d.ts +5 -0
  144. package/lib/src/generated/api/VerifySignatureRequest.js +2 -0
  145. package/lib/src/generated/api/WriteSettingsRequest.d.ts +3 -0
  146. package/lib/src/generated/api/WriteSettingsRequest.js +2 -0
  147. package/lib/src/generated/api/index.d.ts +42 -0
  148. package/lib/src/generated/api/index.js +7 -0
  149. package/lib/src/index.d.ts +6 -1
  150. package/lib/src/index.js +6 -1
  151. package/lib/src/jestSetup.d.ts +0 -1
  152. package/lib/src/jestSetup.js +1 -1
  153. package/lib/src/language/Icon.js +2 -21
  154. package/lib/src/language/Language.d.ts +1 -1
  155. package/lib/src/language/Language.js +10 -76
  156. package/lib/src/language/LanguageClient.d.ts +2 -2
  157. package/lib/src/language/LanguageClient.js +15 -105
  158. package/lib/src/language/LanguageHandle.js +2 -41
  159. package/lib/src/language/LanguageMeta.js +4 -75
  160. package/lib/src/language/LanguageRef.js +2 -25
  161. package/lib/src/links/Links.js +14 -111
  162. package/lib/src/model/Ad4mModel.d.ts +76 -44
  163. package/lib/src/model/Ad4mModel.js +635 -479
  164. package/lib/src/model/Ad4mModel.test.js +371 -815
  165. package/lib/src/model/ModelQueryBuilder.d.ts +15 -27
  166. package/lib/src/model/ModelQueryBuilder.js +163 -224
  167. package/lib/src/model/decorators.d.ts +22 -0
  168. package/lib/src/model/decorators.js +7 -0
  169. package/lib/src/model/hydration.d.ts +3 -93
  170. package/lib/src/model/hydration.js +3 -970
  171. package/lib/src/model/index.d.ts +0 -4
  172. package/lib/src/model/index.js +0 -4
  173. package/lib/src/model/model-manifest.d.ts +41 -0
  174. package/lib/src/model/model-manifest.js +11 -0
  175. package/lib/src/model/query-sparql.d.ts +4 -67
  176. package/lib/src/model/query-sparql.js +26 -322
  177. package/lib/src/model/query-sparql.test.js +35 -218
  178. package/lib/src/model/query-utils.d.ts +1 -0
  179. package/lib/src/model/query-utils.js +46 -1
  180. package/lib/src/model/shacl-gen.js +4 -0
  181. package/lib/src/model/types.d.ts +51 -43
  182. package/lib/src/model/types.js +4 -1
  183. package/lib/src/neighbourhood/Neighbourhood.js +4 -32
  184. package/lib/src/neighbourhood/NeighbourhoodClient.d.ts +3 -3
  185. package/lib/src/neighbourhood/NeighbourhoodClient.js +40 -203
  186. package/lib/src/perspectives/LinkQuery.js +2 -42
  187. package/lib/src/perspectives/Perspective.d.ts +1 -1
  188. package/lib/src/perspectives/Perspective.js +10 -52
  189. package/lib/src/perspectives/PerspectiveClient.d.ts +13 -17
  190. package/lib/src/perspectives/PerspectiveClient.js +179 -429
  191. package/lib/src/perspectives/PerspectiveClient.test.js +55 -0
  192. package/lib/src/perspectives/PerspectiveDiff.js +4 -31
  193. package/lib/src/perspectives/PerspectiveHandle.js +3 -43
  194. package/lib/src/perspectives/PerspectiveProxy.d.ts +106 -71
  195. package/lib/src/perspectives/PerspectiveProxy.js +289 -310
  196. package/lib/src/runtime/RuntimeClient.d.ts +6 -6
  197. package/lib/src/runtime/RuntimeClient.js +93 -467
  198. package/lib/src/runtime/RuntimeTypes.d.ts +101 -0
  199. package/lib/src/runtime/RuntimeTypes.js +45 -0
  200. package/lib/src/shacl/SHACLShape.d.ts +7 -0
  201. package/lib/src/shacl/SHACLShape.js +19 -0
  202. package/lib/src/shacl/SHACLShape.test.js +82 -0
  203. package/lib/src/typeDefs.js +3 -628
  204. package/package.json +6 -18
  205. package/rollup.config.js +0 -7
  206. package/src/Ad4mClient.test.ts +1179 -1340
  207. package/src/Ad4mClient.ts +40 -15
  208. package/src/agent/Agent.ts +0 -99
  209. package/src/agent/AgentClient.ts +112 -526
  210. package/src/agent/AgentStatus.ts +0 -12
  211. package/src/ai/AIClient.ts +96 -296
  212. package/src/ai/AITypes.ts +66 -0
  213. package/src/ai/Tasks.ts +0 -52
  214. package/src/apiClient.ts +283 -0
  215. package/src/expression/Expression.ts +3 -43
  216. package/src/expression/ExpressionClient.ts +14 -77
  217. package/src/expression/ExpressionRef.ts +0 -6
  218. package/src/generated/api/AIModelLoadingStatus.ts +3 -0
  219. package/src/generated/api/AddLinkExpressionRequest.ts +4 -0
  220. package/src/generated/api/AddLinkRequest.ts +4 -0
  221. package/src/generated/api/AddLinksBulkRequest.ts +4 -0
  222. package/src/generated/api/AddSdnaRequest.ts +3 -0
  223. package/src/generated/api/ApplyTemplateRequest.ts +3 -0
  224. package/src/generated/api/AuthInfoInput.ts +4 -0
  225. package/src/generated/api/CapabilityInput.ts +4 -0
  226. package/src/generated/api/CommitBatchRequest.ts +3 -0
  227. package/src/generated/api/ComputeLogEntry.ts +3 -0
  228. package/src/generated/api/CreateExpressionRequest.ts +3 -0
  229. package/src/generated/api/CreatePerspectiveRequest.ts +3 -0
  230. package/src/generated/api/CreateSubjectRequest.ts +3 -0
  231. package/src/generated/api/EmbedRequest.ts +3 -0
  232. package/src/generated/api/EntanglementProofInput.ts +3 -0
  233. package/src/generated/api/ExecuteCommandsRequest.ts +3 -0
  234. package/src/generated/api/ExportRequest.ts +3 -0
  235. package/src/generated/api/ExpressionManyRequest.ts +3 -0
  236. package/src/generated/api/ExpressionProof.ts +3 -0
  237. package/src/generated/api/ExpressionProofInput.ts +3 -0
  238. package/src/generated/api/FriendSendMessageRequest.ts +3 -0
  239. package/src/generated/api/FriendsListRequest.ts +3 -0
  240. package/src/generated/api/GenerateAgentRequest.ts +3 -0
  241. package/src/generated/api/GenerateJwtRequest.ts +3 -0
  242. package/src/generated/api/GetSubjectDataRequest.ts +3 -0
  243. package/src/generated/api/ImportAgentRequest.ts +3 -0
  244. package/src/generated/api/ImportRequest.ts +3 -0
  245. package/src/generated/api/JoinNeighbourhoodRequest.ts +3 -0
  246. package/src/generated/api/LanguageMetaInput.ts +3 -0
  247. package/src/generated/api/Link.ts +3 -0
  248. package/src/generated/api/LinkExpression.ts +6 -0
  249. package/src/generated/api/LinkExpressionInput.ts +6 -0
  250. package/src/generated/api/LinkInput.ts +3 -0
  251. package/src/generated/api/LinkLanguageTemplatesRequest.ts +3 -0
  252. package/src/generated/api/LinkMutations.ts +5 -0
  253. package/src/generated/api/LinkStatus.ts +3 -0
  254. package/src/generated/api/LockAgentRequest.ts +3 -0
  255. package/src/generated/api/ModelType.ts +3 -0
  256. package/src/generated/api/NotificationInput.ts +3 -0
  257. package/src/generated/api/OpenLinkRequest.ts +3 -0
  258. package/src/generated/api/PermitCapabilityRequest.ts +3 -0
  259. package/src/generated/api/PerspectiveInput.ts +4 -0
  260. package/src/generated/api/PromptRequest.ts +3 -0
  261. package/src/generated/api/PublishLanguageRequest.ts +4 -0
  262. package/src/generated/api/PublishNeighbourhoodRequest.ts +4 -0
  263. package/src/generated/api/QueryRequest.ts +6 -0
  264. package/src/generated/api/RemoveLinkRequest.ts +4 -0
  265. package/src/generated/api/RemoveLinksBulkRequest.ts +4 -0
  266. package/src/generated/api/ResourceInput.ts +3 -0
  267. package/src/generated/api/SetDefaultModelRequest.ts +4 -0
  268. package/src/generated/api/SetFreeHostingEnabledRequest.ts +3 -0
  269. package/src/generated/api/SetMultiUserRequest.ts +3 -0
  270. package/src/generated/api/SetStatusRequest.ts +3 -0
  271. package/src/generated/api/SignMessageRequest.ts +3 -0
  272. package/src/generated/api/TrustedAgentsRequest.ts +3 -0
  273. package/src/generated/api/UnlockAgentRequest.ts +3 -0
  274. package/src/generated/api/UpdateLinkRequest.ts +5 -0
  275. package/src/generated/api/UpdatePerspectiveRequest.ts +3 -0
  276. package/src/generated/api/UserStatistics.ts +3 -0
  277. package/src/generated/api/VerificationRequestResult.ts +3 -0
  278. package/src/generated/api/VerifySignatureRequest.ts +3 -0
  279. package/src/generated/api/WriteSettingsRequest.ts +3 -0
  280. package/src/generated/api/index.ts +49 -0
  281. package/src/index.ts +6 -1
  282. package/src/jestSetup.ts +1 -1
  283. package/src/language/Icon.ts +0 -4
  284. package/src/language/Language.ts +2 -23
  285. package/src/language/LanguageClient.ts +21 -132
  286. package/src/language/LanguageHandle.ts +0 -14
  287. package/src/language/LanguageMeta.ts +0 -29
  288. package/src/language/LanguageRef.ts +0 -7
  289. package/src/links/Links.ts +0 -37
  290. package/src/model/Ad4mModel.test.ts +766 -1173
  291. package/src/model/Ad4mModel.ts +664 -529
  292. package/src/model/ModelQueryBuilder.ts +203 -251
  293. package/src/model/decorators.ts +29 -0
  294. package/src/model/hydration.ts +3 -1037
  295. package/src/model/index.ts +0 -4
  296. package/src/model/query-sparql.test.ts +34 -242
  297. package/src/model/query-sparql.ts +27 -337
  298. package/src/model/query-utils.ts +47 -2
  299. package/src/model/shacl-gen.ts +5 -0
  300. package/src/model/types.ts +55 -44
  301. package/src/neighbourhood/Neighbourhood.ts +0 -9
  302. package/src/neighbourhood/NeighbourhoodClient.ts +42 -207
  303. package/src/neighbourhood/NeighbourhoodProxy.test.ts +34 -36
  304. package/src/perspectives/LinkQuery.ts +0 -15
  305. package/src/perspectives/Perspective.ts +1 -12
  306. package/src/perspectives/PerspectiveClient.test.ts +206 -148
  307. package/src/perspectives/PerspectiveClient.ts +247 -442
  308. package/src/perspectives/PerspectiveDiff.ts +0 -8
  309. package/src/perspectives/PerspectiveHandle.ts +1 -12
  310. package/src/perspectives/PerspectiveProxy.test.ts +41 -0
  311. package/src/perspectives/PerspectiveProxy.ts +331 -348
  312. package/src/runtime/RuntimeClient.ts +112 -474
  313. package/src/runtime/RuntimeTypes.ts +144 -0
  314. package/src/shacl/SHACLShape.test.ts +94 -0
  315. package/src/shacl/SHACLShape.ts +27 -0
  316. package/src/typeDefs.ts +3 -5
  317. package/tsconfig.json +3 -7
  318. package/shims/reflect-metadata.ts +0 -0
  319. package/shims/type-graphql.ts +0 -75
  320. package/src/PubSub.ts +0 -17
  321. package/src/agent/AgentResolver.ts +0 -263
  322. package/src/ai/AIResolver.ts +0 -372
  323. package/src/buildSchema.ts +0 -43
  324. package/src/expression/ExpressionResolver.ts +0 -64
  325. package/src/language/LanguageResolver.ts +0 -98
  326. package/src/model/Subject.ts +0 -159
  327. package/src/model/hydration-batch.ts +0 -205
  328. package/src/model/hydration-batching.test.ts +0 -563
  329. package/src/model/prolog-facts.ts +0 -145
  330. package/src/model/query-prolog.ts +0 -148
  331. package/src/model/query-sparql-batch.ts +0 -301
  332. package/src/model/subscription-delta.test.ts +0 -207
  333. package/src/model/subscription-pool.ts +0 -211
  334. package/src/neighbourhood/NeighbourhoodResolver.ts +0 -100
  335. package/src/perspectives/PerspectiveResolver.ts +0 -364
  336. package/src/runtime/RuntimeResolver.ts +0 -749
  337. package/src/unwrapApolloResult.ts +0 -16
@@ -4,9 +4,6 @@
4
4
  * Allows building queries with a chainable interface and either
5
5
  * running them once or subscribing to real-time updates.
6
6
  */
7
- import { groupSPARQLResults, hasJsOnlyWhereFilters, parseSparqlCount } from "./query-sparql";
8
- import { getRelationsMetadata } from "./decorators";
9
- import { pooledSubscribe } from "./subscription-pool";
10
7
  /** Query builder for Ad4mModel queries.
11
8
  * Allows building queries with a fluent interface and either running them once
12
9
  * or subscribing to updates.
@@ -31,7 +28,6 @@ export class ModelQueryBuilder {
31
28
  constructor(perspective, ctor, query) {
32
29
  this.queryParams = {};
33
30
  this.modelClassName = null;
34
- this.engineFlag = 'sparql';
35
31
  this.perspective = perspective;
36
32
  this.ctor = ctor;
37
33
  if (query)
@@ -42,7 +38,7 @@ export class ModelQueryBuilder {
42
38
  *
43
39
  * This method:
44
40
  * 1. Stops the keepalive signals to the subscription
45
- * 2. Unsubscribes from GraphQL subscription updates
41
+ * 2. Unsubscribes from subscription updates
46
42
  * 3. Notifies the backend to clean up subscription resources
47
43
  * 4. Clears the subscription reference
48
44
  *
@@ -205,25 +201,25 @@ export class ModelQueryBuilder {
205
201
  return this;
206
202
  }
207
203
  /**
208
- * Opts in to evaluating SPARQL property getters during collection hydration.
204
+ * Controls whether SPARQL property getters are evaluated during hydration.
209
205
  *
210
- * By default, collection queries skip getter evaluation for performance.
211
- * Call `.deepQuery()` when you need getter-backed properties in the result set.
206
+ * By default, collection queries evaluate property getters (deepQuery=true).
207
+ * Call `.deepQuery(false)` to skip getter evaluation for performance.
212
208
  *
209
+ * @param enabled - Whether to evaluate property getters (default: true)
213
210
  * @returns The query builder for chaining
214
211
  *
215
212
  * @example
216
213
  * ```typescript
217
214
  * const messages = await Message.query(perspective)
218
215
  * .parent(channel)
219
- * .deepQuery()
216
+ * .deepQuery(false) // skip property getters for performance
220
217
  * .limit(30)
221
218
  * .get();
222
- * // messages[i].replyingTo is populated
223
219
  * ```
224
220
  */
225
- deepQuery() {
226
- this.queryParams.deepQuery = true;
221
+ deepQuery(enabled = true) {
222
+ this.queryParams.deepQuery = enabled;
227
223
  return this;
228
224
  }
229
225
  /**
@@ -262,9 +258,9 @@ export class ModelQueryBuilder {
262
258
  }
263
259
  /**
264
260
  * Sets the query engine to use.
261
+ * @deprecated Prolog engine has been removed. All queries use SPARQL/Rust.
265
262
  */
266
- engine(eng) {
267
- this.engineFlag = eng;
263
+ engine(_eng) {
268
264
  return this;
269
265
  }
270
266
  /**
@@ -280,16 +276,7 @@ export class ModelQueryBuilder {
280
276
  * ```
281
277
  */
282
278
  async get() {
283
- let results;
284
- if (this.engineFlag === 'sparql') {
285
- results = await this.executeSparqlQuery();
286
- }
287
- else {
288
- const query = await this.ctor.queryToProlog(this.perspective, this.queryParams, this.modelClassName);
289
- const result = await this.perspective.infer(query);
290
- ({ results } = await this.ctor.instancesFromPrologResult(this.perspective, this.queryParams, result));
291
- }
292
- return results;
279
+ return await this.executeSparqlQuery();
293
280
  }
294
281
  /**
295
282
  * Executes the query once using SPARQL and returns the results.
@@ -298,22 +285,12 @@ export class ModelQueryBuilder {
298
285
  return this.executeSparqlQuery();
299
286
  }
300
287
  /**
301
- * Shared SPARQL query execution logic used by both get() and getSparql().
288
+ * Shared query execution logic — routes through the executor-side modelQuery endpoint.
302
289
  */
303
290
  async executeSparqlQuery() {
304
- const sparqlQuery = await this.ctor.queryToSPARQL(this.perspective, this.queryParams);
305
- const rawResult = await this.perspective.querySparql(sparqlQuery);
306
- const { results } = await this.processSparqlResult(rawResult);
291
+ const { results } = await this.ctor.executeModelQuery(this.perspective, this.queryParams, this.modelClassName);
307
292
  return results;
308
293
  }
309
- /**
310
- * Groups raw SPARQL results and hydrates them into model instances.
311
- * Centralises the repeated groupSPARQLResults → instancesFromQueryResult pipeline.
312
- */
313
- async processSparqlResult(rawResult, queryOverride, computeTotalCount = false) {
314
- const grouped = groupSPARQLResults(Array.isArray(rawResult) ? rawResult : []);
315
- return await this.ctor.instancesFromQueryResult(this.perspective, queryOverride || this.queryParams, grouped, computeTotalCount);
316
- }
317
294
  /**
318
295
  * Returns the first matching instance, or `null` if none match.
319
296
  *
@@ -360,70 +337,80 @@ export class ModelQueryBuilder {
360
337
  * builder.dispose();
361
338
  * ```
362
339
  *
363
- * @remarks
364
- * By default, this uses SPARQL live queries for real-time updates.
365
- * Prolog subscriptions remain available via `.useSPARQL(false)`.
366
340
  */
367
341
  async subscribe(callback) {
368
342
  // Clean up any existing subscription
369
343
  this.dispose();
370
344
  const ctor = this.ctor;
371
- if (this.engineFlag === 'sparql') {
372
- const sparqlQuery = await ctor.queryToSPARQL(this.perspective, this.queryParams);
373
- // Track last emitted result fingerprint to suppress duplicate callbacks
374
- let lastResultFingerprint = null;
375
- const buildFingerprint = (results) => {
376
- if (results.length === 0)
377
- return '0:';
378
- // Must include relation data (e.g. tags) — not just id/timestamp.
379
- // Otherwise @HasMany changes on existing instances are suppressed as duplicates.
380
- return JSON.stringify(results, (_, v) => typeof v === 'function' ? undefined : v);
381
- };
382
- const hydrate = async (rawResult) => {
383
- const { results } = await this.processSparqlResult(rawResult);
384
- return results;
385
- };
386
- const pooled = await pooledSubscribe(this.perspective, sparqlQuery, hydrate, (hydratedResults) => {
387
- const fp = buildFingerprint(hydratedResults);
345
+ // Build the model query params (className, queryJson, shapeJson)
346
+ const { className, queryJson, shapeJson } = ctor.prepareModelQueryParams(this.queryParams, this.modelClassName);
347
+ // Register model subscription via Rust — this builds trigger SPARQL internally,
348
+ // registers the subscription, and runs the initial query in one call.
349
+ const { subscriptionId, result: initialModelResult } = await this.perspective.modelSubscribe(className, queryJson, shapeJson);
350
+ // Convert JSON instances to model class instances
351
+ const parseResults = (raw) => {
352
+ return ctor.parseModelResult(this.perspective, raw, this.queryParams.include, this.queryParams.properties);
353
+ };
354
+ // Parse initial results
355
+ const initialResults = parseResults(initialModelResult);
356
+ // Track last emitted result fingerprint to suppress duplicate callbacks
357
+ let lastResultFingerprint = null;
358
+ const buildFingerprint = (results) => {
359
+ if (results.length === 0)
360
+ return '0:';
361
+ return JSON.stringify(results, (_, v) => typeof v === 'function' ? undefined : v);
362
+ };
363
+ lastResultFingerprint = buildFingerprint(initialResults);
364
+ // Listen for subscription updates via the same GraphQL subscription channel.
365
+ // When Rust re-runs the model query and finds changed results, it pushes them.
366
+ const unsubscribe = this.perspective.client.subscribeToQueryUpdates(subscriptionId, (rawResult) => {
367
+ // Skip delayed #init# messages — initial data was already returned
368
+ // synchronously from modelSubscribe(). Late init messages contain stale
369
+ // data that would overwrite real subscription updates.
370
+ if (rawResult && rawResult.isInit)
371
+ return;
372
+ try {
373
+ const results = parseResults(rawResult);
374
+ const fp = buildFingerprint(results);
388
375
  if (fp === lastResultFingerprint)
389
376
  return;
390
377
  lastResultFingerprint = fp;
391
- callback(hydratedResults);
392
- });
393
- // Store dispose function as subscription
394
- this.currentSubscription = { dispose: pooled.dispose };
395
- const initialResults = pooled.initialResult;
396
- lastResultFingerprint = buildFingerprint(initialResults);
397
- return initialResults;
398
- }
399
- else {
400
- const query = await ctor.queryToProlog(this.perspective, this.queryParams, this.modelClassName);
401
- this.currentSubscription = await this.perspective.subscribeInfer(query);
402
- const processResults = async (result) => {
403
- const { results } = await ctor.instancesFromPrologResult(this.perspective, this.queryParams, result);
404
378
  callback(results);
405
- };
406
- this.currentSubscription.onResult(processResults);
407
- const { results } = await ctor.instancesFromPrologResult(this.perspective, this.queryParams, this.currentSubscription.result);
408
- // Initial results returned via Promise only — callback is for subsequent updates
409
- return results;
379
+ }
380
+ catch (e) {
381
+ console.error('Model subscription update parse error:', e);
382
+ }
383
+ });
384
+ // Set up keepalive with failure tracking
385
+ let keepaliveFailures = 0;
386
+ const keepaliveTimer = setInterval(() => {
387
+ this.perspective.client.keepAliveQuery(this.perspective.uuid, subscriptionId).then(() => {
388
+ keepaliveFailures = 0;
389
+ }).catch((e) => {
390
+ keepaliveFailures++;
391
+ console.warn(`Model subscription keepalive failed (attempt ${keepaliveFailures}) for ${subscriptionId}:`, e);
392
+ });
393
+ }, 30000);
394
+ // Store dispose function
395
+ this.currentSubscription = {
396
+ dispose: () => {
397
+ clearInterval(keepaliveTimer);
398
+ unsubscribe();
399
+ this.perspective.client.disposeQuerySubscription(this.perspective.uuid, subscriptionId).catch(() => { });
400
+ },
401
+ };
402
+ // Take snapshots for dirty tracking
403
+ for (const inst of initialResults) {
404
+ inst.takeSnapshot?.(this.queryParams.include);
410
405
  }
406
+ return initialResults;
411
407
  }
412
408
  /**
413
409
  * Subscribes to the query and receives updates using SPARQL.
410
+ * @deprecated Use subscribe() instead — now routes through Rust model subscription.
414
411
  */
415
412
  async subscribeSparql(callback) {
416
- this.dispose();
417
- const sparqlQuery = await this.ctor.queryToSPARQL(this.perspective, this.queryParams);
418
- this.currentSubscription = await this.perspective.subscribeQuery(sparqlQuery);
419
- const processResults = async (result) => {
420
- const { results } = await this.processSparqlResult(result);
421
- callback(results);
422
- };
423
- this.currentSubscription.onResult(processResults);
424
- const { results } = await this.processSparqlResult(this.currentSubscription.result);
425
- // Initial results returned via Promise only — callback is for subsequent updates
426
- return results;
413
+ return this.subscribe(callback);
427
414
  }
428
415
  /**
429
416
  * Gets the total count of matching entities.
@@ -438,40 +425,15 @@ export class ModelQueryBuilder {
438
425
  * ```
439
426
  */
440
427
  async count() {
441
- if (this.engineFlag === 'sparql') {
442
- // When query has JS-only where filters, fall back to full hydration
443
- const metadata = this.ctor.getModelMetadata();
444
- const allRelMeta = getRelationsMetadata(this.ctor);
445
- if (hasJsOnlyWhereFilters(metadata, allRelMeta, this.queryParams.where)) {
446
- const sparqlQuery = await this.ctor.queryToSPARQL(this.perspective, this.queryParams);
447
- const rawResult = await this.perspective.querySparql(sparqlQuery);
448
- const { totalCount } = await this.processSparqlResult(rawResult, undefined, true);
449
- return totalCount;
450
- }
451
- // Use efficient COUNT query — no hydration
452
- const countSparql = await this.ctor.countQueryToSPARQL(this.perspective, this.queryParams);
453
- const countResult = await this.perspective.querySparql(countSparql);
454
- return parseSparqlCount(countResult) ?? 0;
455
- }
456
- else {
457
- const query = await this.ctor.countQueryToProlog(this.perspective, this.queryParams, this.modelClassName);
458
- const result = await this.perspective.infer(query);
459
- return result?.[0]?.TotalCount || 0;
460
- }
428
+ const { totalCount } = await this.ctor.executeModelQuery(this.perspective, { ...this.queryParams, limit: 0 }, this.modelClassName);
429
+ return totalCount;
461
430
  }
462
431
  /**
463
432
  * Gets the total count of matching entities using SPARQL.
464
- * Delegates to count() with SPARQL engine forced.
433
+ * Delegates to count().
465
434
  */
466
435
  async countSparql() {
467
- const prev = this.engineFlag;
468
- this.engineFlag = 'sparql';
469
- try {
470
- return await this.count();
471
- }
472
- finally {
473
- this.engineFlag = prev;
474
- }
436
+ return await this.count();
475
437
  }
476
438
  /**
477
439
  * Subscribes to count updates for matching entities.
@@ -500,53 +462,52 @@ export class ModelQueryBuilder {
500
462
  * builder.dispose();
501
463
  * ```
502
464
  *
503
- * @remarks
504
- * By default, this uses SPARQL live queries for real-time updates.
505
- * Prolog subscriptions remain available via `.useSPARQL(false)`.
506
465
  */
507
466
  async countSubscribe(callback) {
508
467
  // Clean up any existing subscription
509
468
  this.dispose();
510
- if (this.engineFlag === 'sparql') {
511
- const sparqlQuery = await this.ctor.queryToSPARQL(this.perspective, this.queryParams);
512
- this.currentSubscription = await this.perspective.subscribeQuery(sparqlQuery);
513
- const processResults = async (result) => {
514
- const { totalCount } = await this.processSparqlResult(result, undefined, true);
515
- callback(totalCount);
516
- };
517
- this.currentSubscription.onResult(processResults);
518
- const { totalCount } = await this.processSparqlResult(this.currentSubscription.result, undefined, true);
519
- // Initial count returned via Promise — callback for updates only
520
- return totalCount;
521
- }
522
- else {
523
- const query = await this.ctor.countQueryToProlog(this.perspective, this.queryParams, this.modelClassName);
524
- this.currentSubscription = await this.perspective.subscribeInfer(query);
525
- const processResults = async (result) => {
526
- const newCount = result?.[0]?.TotalCount || 0;
527
- callback(newCount);
528
- };
529
- this.currentSubscription.onResult(processResults);
530
- const initialCount = this.currentSubscription.result?.[0]?.TotalCount || 0;
531
- // Initial count returned via Promise — callback for subsequent updates only
532
- return initialCount;
533
- }
469
+ const countParams = { ...this.queryParams, limit: 0 };
470
+ const { className, queryJson, shapeJson } = this.ctor.prepareModelQueryParams(countParams, this.modelClassName);
471
+ const { subscriptionId, result: initialModelResult } = await this.perspective.modelSubscribe(className, queryJson, shapeJson);
472
+ const parseCount = (raw) => {
473
+ const data = typeof raw === 'string' ? JSON.parse(raw) : raw;
474
+ return data.totalCount ?? 0;
475
+ };
476
+ const initialCount = parseCount(initialModelResult);
477
+ const unsubscribe = this.perspective.client.subscribeToQueryUpdates(subscriptionId, (rawResult) => {
478
+ if (rawResult && rawResult.isInit)
479
+ return;
480
+ try {
481
+ callback(parseCount(rawResult));
482
+ }
483
+ catch (e) {
484
+ console.error('Count subscription update parse error:', e);
485
+ }
486
+ });
487
+ let keepaliveFailures = 0;
488
+ const keepaliveTimer = setInterval(() => {
489
+ this.perspective.client.keepAliveQuery(this.perspective.uuid, subscriptionId).then(() => {
490
+ keepaliveFailures = 0;
491
+ }).catch((e) => {
492
+ keepaliveFailures++;
493
+ console.warn(`Count subscription keepalive failed (attempt ${keepaliveFailures}) for ${subscriptionId}:`, e);
494
+ });
495
+ }, 30000);
496
+ this.currentSubscription = {
497
+ dispose: () => {
498
+ clearInterval(keepaliveTimer);
499
+ unsubscribe();
500
+ this.perspective.client.disposeQuerySubscription(this.perspective.uuid, subscriptionId).catch(() => { });
501
+ },
502
+ };
503
+ return initialCount;
534
504
  }
535
505
  /**
536
506
  * Subscribes to count updates using SPARQL.
507
+ * @deprecated Use countSubscribe() instead — now routes through Rust model subscription.
537
508
  */
538
509
  async countSubscribeSparql(callback) {
539
- this.dispose();
540
- const sparqlQuery = await this.ctor.queryToSPARQL(this.perspective, this.queryParams);
541
- this.currentSubscription = await this.perspective.subscribeQuery(sparqlQuery);
542
- const processResults = async (result) => {
543
- const { totalCount } = await this.processSparqlResult(result, undefined, true);
544
- callback(totalCount);
545
- };
546
- this.currentSubscription.onResult(processResults);
547
- const { totalCount } = await this.processSparqlResult(this.currentSubscription.result, undefined, true);
548
- // Initial count returned via Promise — callback for updates only
549
- return totalCount;
510
+ return this.countSubscribe(callback);
550
511
  }
551
512
  /**
552
513
  * Gets a page of results with pagination metadata.
@@ -565,32 +526,15 @@ export class ModelQueryBuilder {
565
526
  */
566
527
  async paginate(pageSize, pageNumber) {
567
528
  const paginationQuery = { ...(this.queryParams || {}), limit: pageSize, offset: pageSize * (pageNumber - 1), count: true };
568
- if (this.engineFlag === 'sparql') {
569
- const sparqlQuery = await this.ctor.queryToSPARQL(this.perspective, paginationQuery);
570
- const result = await this.perspective.querySparql(sparqlQuery);
571
- const { results, totalCount } = await this.processSparqlResult(result, paginationQuery, true);
572
- return { results, totalCount, pageSize, pageNumber };
573
- }
574
- else {
575
- const prologQuery = await this.ctor.queryToProlog(this.perspective, paginationQuery, this.modelClassName);
576
- const result = await this.perspective.infer(prologQuery);
577
- const { results, totalCount } = (await this.ctor.instancesFromPrologResult(this.perspective, paginationQuery, result));
578
- return { results, totalCount, pageSize, pageNumber };
579
- }
529
+ const { results, totalCount } = await this.ctor.executeModelQuery(this.perspective, paginationQuery, this.modelClassName);
530
+ return { results, totalCount, pageSize, pageNumber };
580
531
  }
581
532
  /**
582
533
  * Gets a page of results using SPARQL.
583
- * Delegates to paginate() with SPARQL engine forced.
534
+ * Delegates to paginate().
584
535
  */
585
536
  async paginateSparql(pageSize, pageNumber) {
586
- const prev = this.engineFlag;
587
- this.engineFlag = 'sparql';
588
- try {
589
- return await this.paginate(pageSize, pageNumber);
590
- }
591
- finally {
592
- this.engineFlag = prev;
593
- }
537
+ return await this.paginate(pageSize, pageNumber);
594
538
  }
595
539
  /**
596
540
  * Subscribes to paginated results updates.
@@ -621,65 +565,60 @@ export class ModelQueryBuilder {
621
565
  * builder.dispose();
622
566
  * ```
623
567
  *
624
- * @remarks
625
- * By default, this uses SPARQL live queries for real-time updates.
626
- * Prolog subscriptions remain available via `.useSPARQL(false)`.
627
568
  */
628
569
  async paginateSubscribe(pageSize, pageNumber, callback) {
629
570
  // Clean up any existing subscription
630
571
  this.dispose();
631
- const paginationQuery = { ...(this.queryParams || {}), limit: pageSize, offset: pageSize * (pageNumber - 1), count: true };
632
- if (this.engineFlag === 'sparql') {
633
- // Subscribe to the FULL result set (no LIMIT/OFFSET) so the subscription
634
- // detects changes anywhere in the dataset (e.g. new items beyond current page).
635
- // Pagination is applied in JS when processing each update.
636
- const subscriptionParams = { ...(this.queryParams || {}) };
637
- delete subscriptionParams.limit;
638
- delete subscriptionParams.offset;
639
- const sparqlQuery = await this.ctor.queryToSPARQL(this.perspective, subscriptionParams);
640
- this.currentSubscription = await this.perspective.subscribeQuery(sparqlQuery);
641
- // Query for processSparqlResult has NO limit/offset — gets all results, totalCount via count:true
642
- const fullQuery = { ...(this.queryParams || {}), count: true };
643
- const processResults = async (result) => {
644
- const { results: allResults, totalCount } = await this.processSparqlResult(result, fullQuery, true);
645
- const start = pageSize * (pageNumber - 1);
646
- const results = allResults.slice(start, start + pageSize);
647
- callback({ results, totalCount, pageSize, pageNumber });
648
- };
649
- this.currentSubscription.onResult(processResults);
650
- const { results: allResults, totalCount } = await this.processSparqlResult(this.currentSubscription.result, fullQuery, true);
651
- const start = pageSize * (pageNumber - 1);
652
- const results = allResults.slice(start, start + pageSize);
653
- const initialPage = { results, totalCount, pageSize, pageNumber };
654
- // Initial page returned via Promise — callback for subsequent updates only
655
- return initialPage;
656
- }
657
- else {
658
- const prologQuery = await this.ctor.queryToProlog(this.perspective, paginationQuery, this.modelClassName);
659
- this.currentSubscription = await this.perspective.subscribeInfer(prologQuery);
660
- const processResults = async (r) => {
661
- const { results, totalCount } = (await this.ctor.instancesFromPrologResult(this.perspective, this.queryParams, r));
662
- callback({ results, totalCount, pageSize, pageNumber });
663
- };
664
- this.currentSubscription.onResult(processResults);
665
- const { results, totalCount } = (await this.ctor.instancesFromPrologResult(this.perspective, paginationQuery, this.currentSubscription.result));
666
- const initialPrologPage = { results, totalCount, pageSize, pageNumber };
667
- // Initial page returned via Promise — callback for subsequent updates only
668
- return initialPrologPage;
669
- }
572
+ const ctor = this.ctor;
573
+ // Subscribe to the full result set (no limit/offset) so the subscription
574
+ // detects changes anywhere in the dataset. Rust builds trigger SPARQL
575
+ // from the shape predicates.
576
+ const subscriptionParams = { ...(this.queryParams || {}) };
577
+ delete subscriptionParams.limit;
578
+ delete subscriptionParams.offset;
579
+ const { className, queryJson, shapeJson } = ctor.prepareModelQueryParams(subscriptionParams, this.modelClassName);
580
+ const { subscriptionId } = await this.perspective.modelSubscribe(className, queryJson, shapeJson);
581
+ // Build the paginated query for Rust endpoint (count: true fetches both results and totalCount in one call)
582
+ const paginatedQuery = {
583
+ ...(this.queryParams || {}),
584
+ limit: pageSize,
585
+ offset: pageSize * (pageNumber - 1),
586
+ count: true,
587
+ };
588
+ const processResults = async () => {
589
+ const { results, totalCount } = await ctor.executeModelQuery(this.perspective, paginatedQuery, this.modelClassName);
590
+ callback({ results, totalCount, pageSize, pageNumber });
591
+ };
592
+ const unsubscribe = this.perspective.client.subscribeToQueryUpdates(subscriptionId, (rawResult) => {
593
+ if (rawResult && rawResult.isInit)
594
+ return;
595
+ processResults().catch(e => console.error('Paginate subscription error:', e));
596
+ });
597
+ let keepaliveFailures = 0;
598
+ const keepaliveTimer = setInterval(() => {
599
+ this.perspective.client.keepAliveQuery(this.perspective.uuid, subscriptionId).then(() => {
600
+ keepaliveFailures = 0;
601
+ }).catch((e) => {
602
+ keepaliveFailures++;
603
+ console.warn(`Paginate subscription keepalive failed (attempt ${keepaliveFailures}) for ${subscriptionId}:`, e);
604
+ });
605
+ }, 30000);
606
+ this.currentSubscription = {
607
+ dispose: () => {
608
+ clearInterval(keepaliveTimer);
609
+ unsubscribe();
610
+ this.perspective.client.disposeQuerySubscription(this.perspective.uuid, subscriptionId).catch(() => { });
611
+ },
612
+ };
613
+ // Initial fetch (single call with count: true)
614
+ const { results, totalCount } = await ctor.executeModelQuery(this.perspective, paginatedQuery, this.modelClassName);
615
+ return { results, totalCount, pageSize, pageNumber };
670
616
  }
671
617
  /**
672
618
  * Subscribes to paginated results updates using SPARQL.
673
- * Delegates to paginateSubscribe() with SPARQL engine forced.
619
+ * Delegates to paginateSubscribe().
674
620
  */
675
621
  async paginateSubscribeSparql(pageSize, pageNumber, callback) {
676
- const prev = this.engineFlag;
677
- this.engineFlag = 'sparql';
678
- try {
679
- return await this.paginateSubscribe(pageSize, pageNumber, callback);
680
- }
681
- finally {
682
- this.engineFlag = prev;
683
- }
622
+ return await this.paginateSubscribe(pageSize, pageNumber, callback);
684
623
  }
685
624
  }
@@ -135,6 +135,28 @@ export interface PropertyOptions {
135
135
  * The function takes the raw value as input and returns the transformed value.
136
136
  */
137
137
  transform?: (value: any) => any;
138
+ /**
139
+ * Allowed values for this property (enum constraint).
140
+ * Maps to SHACL `sh:in`. Each entry has a `value` (the stored RDF term)
141
+ * and an optional `label` (human-readable display name).
142
+ *
143
+ * @example
144
+ * ```typescript
145
+ * @Property({
146
+ * through: "task://status",
147
+ * options: [
148
+ * { value: "task://todo", label: "To Do" },
149
+ * { value: "task://doing", label: "Doing" },
150
+ * { value: "task://done", label: "Done" },
151
+ * ]
152
+ * })
153
+ * status: string = "task://todo";
154
+ * ```
155
+ */
156
+ options?: Array<{
157
+ value: string;
158
+ label?: string;
159
+ }>;
138
160
  }
139
161
  /**
140
162
  * Convenience decorator for defining optional (not required) properties.
@@ -521,8 +521,15 @@ function resolveRelationArgs(first, second) {
521
521
  return opts;
522
522
  }
523
523
  export function HasMany(first, second) {
524
+ const explicitThrough = typeof first === 'function' ? second?.through : first.through;
524
525
  const opts = resolveRelationArgs(first, second);
525
526
  return function (target, key) {
527
+ if (!explicitThrough && !opts.getter) {
528
+ const className = (target.constructor?.name) ?? 'unknown';
529
+ console.warn(`@HasMany on ${className}.${String(key)} has no 'through' predicate — defaulting to 'ad4m://has_child'. ` +
530
+ `Add { through: 'ad4m://has_child' } to silence this warning, or use a semantic predicate ` +
531
+ `like { through: 'myns://has_${String(key)}' } for efficient targeted queries.`);
532
+ }
526
533
  // --- relation registry ---
527
534
  const ctor = target.constructor;
528
535
  if (!relationRegistry.has(ctor))