@coasys/ad4m 0.13.0-test-flows-1 → 0.13.1-staging.2

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 (958) hide show
  1. package/README.md +1 -0
  2. package/lib/index.cjs +9613 -7069
  3. package/lib/index.js +7367 -4840
  4. package/lib/src/Ad4mClient.d.ts +12 -4
  5. package/lib/src/Ad4mClient.js +15 -11
  6. package/lib/src/Literal.js +3 -3
  7. package/lib/src/agent/Agent.d.ts +4 -1
  8. package/lib/src/agent/Agent.js +6 -0
  9. package/lib/src/agent/AgentClient.d.ts +9 -23
  10. package/lib/src/agent/AgentClient.js +68 -148
  11. package/lib/src/ai/AIClient.d.ts +10 -6
  12. package/lib/src/ai/AIClient.js +29 -27
  13. package/lib/src/apiClient.d.ts +54 -42
  14. package/lib/src/apiClient.js +279 -252
  15. package/lib/src/expression/Expression.d.ts +13 -4
  16. package/lib/src/expression/Expression.js +0 -1
  17. package/lib/src/expression/ExpressionClient.js +1 -1
  18. package/lib/src/generated/api/AIPromptExamples.d.ts +4 -0
  19. package/lib/src/generated/api/AIPromptExamples.js +2 -0
  20. package/lib/src/generated/api/AIPromptExamplesInput.d.ts +4 -0
  21. package/lib/src/generated/api/AIPromptExamplesInput.js +2 -0
  22. package/lib/src/generated/api/AITask.d.ts +11 -0
  23. package/lib/src/generated/api/AITaskInput.d.ts +8 -0
  24. package/lib/src/generated/api/AddAgentInfosRequest.d.ts +3 -0
  25. package/lib/src/generated/api/AddAgentInfosRequest.js +2 -0
  26. package/lib/src/generated/api/AddLinkExpressionRequest.d.ts +2 -2
  27. package/lib/src/generated/api/AddLinkRequest.d.ts +2 -2
  28. package/lib/src/generated/api/AddLinksBulkRequest.d.ts +2 -2
  29. package/lib/src/generated/api/AddSdnaRequest.d.ts +2 -2
  30. package/lib/src/generated/api/Agent.d.ts +6 -0
  31. package/lib/src/generated/api/AgentAddEntanglementProofsParams.d.ts +9 -0
  32. package/lib/src/generated/api/AgentByDidParams.d.ts +3 -0
  33. package/lib/src/generated/api/AgentByDidParams.js +2 -0
  34. package/lib/src/generated/api/AgentRemoveAppParams.d.ts +3 -0
  35. package/lib/src/generated/api/AgentRemoveAppParams.js +2 -0
  36. package/lib/src/generated/api/AgentRevokeTokenParams.d.ts +3 -0
  37. package/lib/src/generated/api/AgentRevokeTokenParams.js +2 -0
  38. package/lib/src/generated/api/AgentSignature.d.ts +4 -0
  39. package/lib/src/generated/api/AgentSignature.js +2 -0
  40. package/lib/src/generated/api/AgentStatus.d.ts +8 -0
  41. package/lib/src/generated/api/AgentStatusChangedEvent.d.ts +7 -0
  42. package/lib/src/generated/api/AgentUpdatedEvent.d.ts +7 -0
  43. package/lib/src/generated/api/AgentsByDidsRequest.d.ts +3 -0
  44. package/lib/src/generated/api/AgentsByDidsRequest.js +2 -0
  45. package/lib/src/generated/api/AiAddModelParams.d.ts +4 -0
  46. package/lib/src/generated/api/AiAddTaskParams.d.ts +4 -0
  47. package/lib/src/generated/api/AiDiscoverModelsParams.d.ts +8 -0
  48. package/lib/src/generated/api/AiDiscoverModelsParams.js +2 -0
  49. package/lib/src/generated/api/AiGetDefaultModelParams.d.ts +4 -0
  50. package/lib/src/generated/api/AiIdParams.d.ts +3 -0
  51. package/lib/src/generated/api/AiIdParams.js +2 -0
  52. package/lib/src/generated/api/AiModelLoadingStatusParams.d.ts +7 -0
  53. package/lib/src/generated/api/AiModelLoadingStatusParams.js +2 -0
  54. package/lib/src/generated/api/AiSetDefaultModelParams.d.ts +5 -0
  55. package/lib/src/generated/api/AiSetDefaultModelParams.js +1 -0
  56. package/lib/src/generated/api/AiTranscriptionCloseParams.d.ts +3 -0
  57. package/lib/src/generated/api/AiTranscriptionCloseParams.js +2 -0
  58. package/lib/src/generated/api/AiTranscriptionOpenParams.d.ts +5 -0
  59. package/lib/src/generated/api/AiTranscriptionOpenParams.js +1 -0
  60. package/lib/src/generated/api/AiUpdateModelParams.d.ts +5 -0
  61. package/lib/src/generated/api/AiUpdateModelParams.js +1 -0
  62. package/lib/src/generated/api/AiUpdateTaskParams.d.ts +4 -0
  63. package/lib/src/generated/api/AiUpdateTaskParams.js +1 -0
  64. package/lib/src/generated/api/Apps.d.ts +7 -0
  65. package/lib/src/generated/api/Apps.js +1 -0
  66. package/lib/src/generated/api/AuthInfo.d.ts +10 -0
  67. package/lib/src/generated/api/AuthInfo.js +1 -0
  68. package/lib/src/generated/api/AuthInfoInput.d.ts +4 -4
  69. package/lib/src/generated/api/AutoProcessorEvent.d.ts +89 -0
  70. package/lib/src/generated/api/AutoProcessorEvent.js +1 -0
  71. package/lib/src/generated/api/AutoProcessorNeighbourhoodState.d.ts +32 -0
  72. package/lib/src/generated/api/AutoProcessorNeighbourhoodState.js +1 -0
  73. package/lib/src/generated/api/AutoProcessorStep.d.ts +7 -0
  74. package/lib/src/generated/api/AutoProcessorStep.js +2 -0
  75. package/lib/src/generated/api/BroadcastRequest.d.ts +5 -0
  76. package/lib/src/generated/api/BroadcastRequest.js +2 -0
  77. package/lib/src/generated/api/CallSessionInfo.d.ts +23 -0
  78. package/lib/src/generated/api/CallSessionInfo.js +2 -0
  79. package/lib/src/generated/api/Capability.d.ts +5 -0
  80. package/lib/src/generated/api/Capability.js +1 -0
  81. package/lib/src/generated/api/CreateSubjectRequest.d.ts +2 -2
  82. package/lib/src/generated/api/CreateUserRequest.d.ts +4 -0
  83. package/lib/src/generated/api/CreateUserRequest.js +2 -0
  84. package/lib/src/generated/api/DateTime.d.ts +1 -0
  85. package/lib/src/generated/api/DateTime.js +2 -0
  86. package/lib/src/generated/api/DecoratedExpressionProof.d.ts +6 -0
  87. package/lib/src/generated/api/DecoratedExpressionProof.js +2 -0
  88. package/lib/src/generated/api/DecoratedLinkExpression.d.ts +10 -0
  89. package/lib/src/generated/api/DecoratedLinkExpression.js +1 -0
  90. package/lib/src/generated/api/DecoratedNeighbourhoodExpression.d.ts +8 -0
  91. package/lib/src/generated/api/DecoratedNeighbourhoodExpression.js +1 -0
  92. package/lib/src/generated/api/DecoratedPerspective.d.ts +4 -0
  93. package/lib/src/generated/api/DecoratedPerspective.js +1 -0
  94. package/lib/src/generated/api/DiscardBatchRequest.d.ts +3 -0
  95. package/lib/src/generated/api/DiscardBatchRequest.js +2 -0
  96. package/lib/src/generated/api/DisposeQueryRequest.d.ts +3 -0
  97. package/lib/src/generated/api/DisposeQueryRequest.js +2 -0
  98. package/lib/src/generated/api/EntanglementProof.d.ts +8 -0
  99. package/lib/src/generated/api/EntanglementProof.js +2 -0
  100. package/lib/src/generated/api/EntanglementProofInput.d.ts +1 -1
  101. package/lib/src/generated/api/EntanglementProofPreflightRequest.d.ts +4 -0
  102. package/lib/src/generated/api/EntanglementProofPreflightRequest.js +2 -0
  103. package/lib/src/generated/api/EntanglementProofsWrapper.d.ts +7 -0
  104. package/lib/src/generated/api/EntanglementProofsWrapper.js +1 -0
  105. package/lib/src/generated/api/Events.d.ts +56 -0
  106. package/lib/src/generated/api/Events.js +18 -0
  107. package/lib/src/generated/api/ExceptionInfo.d.ts +7 -0
  108. package/lib/src/generated/api/ExceptionInfo.js +1 -0
  109. package/lib/src/generated/api/ExceptionOccurredEvent.d.ts +7 -0
  110. package/lib/src/generated/api/ExceptionOccurredEvent.js +1 -0
  111. package/lib/src/generated/api/ExceptionType.d.ts +1 -0
  112. package/lib/src/generated/api/ExceptionType.js +2 -0
  113. package/lib/src/generated/api/ExecuteCommandsRequest.d.ts +4 -2
  114. package/lib/src/generated/api/ExportRequest.d.ts +1 -1
  115. package/lib/src/generated/api/ExpressionInteractRequest.d.ts +5 -0
  116. package/lib/src/generated/api/ExpressionInteractRequest.js +1 -0
  117. package/lib/src/generated/api/ExpressionProofInput.d.ts +4 -4
  118. package/lib/src/generated/api/ExpressionRendered.d.ts +11 -0
  119. package/lib/src/generated/api/ExpressionRendered.js +1 -0
  120. package/lib/src/generated/api/ExpressionUrlRequest.d.ts +3 -0
  121. package/lib/src/generated/api/ExpressionUrlRequest.js +2 -0
  122. package/lib/src/generated/api/FireOutcome.d.ts +14 -0
  123. package/lib/src/generated/api/FireOutcome.js +2 -0
  124. package/lib/src/generated/api/FlowStateChangedEvent.d.ts +38 -0
  125. package/lib/src/generated/api/FlowStateChangedEvent.js +2 -0
  126. package/lib/src/generated/api/FlowStateEntry.d.ts +18 -0
  127. package/lib/src/generated/api/FlowStateEntry.js +2 -0
  128. package/lib/src/generated/api/FriendSendMessageRequest.d.ts +1 -1
  129. package/lib/src/generated/api/HostRate.d.ts +7 -0
  130. package/lib/src/generated/api/HostRate.js +2 -0
  131. package/lib/src/generated/api/HostingInfoResult.d.ts +13 -0
  132. package/lib/src/generated/api/HostingInfoResult.js +1 -0
  133. package/lib/src/generated/api/HostingInfoUser.d.ts +9 -0
  134. package/lib/src/generated/api/HostingInfoUser.js +2 -0
  135. package/lib/src/generated/api/HostingRequestPaymentResult.d.ts +4 -0
  136. package/lib/src/generated/api/HostingRequestPaymentResult.js +2 -0
  137. package/lib/src/generated/api/HostingUserInfo.d.ts +6 -0
  138. package/lib/src/generated/api/HostingUserInfo.js +2 -0
  139. package/lib/src/generated/api/HostingVersionInfo.d.ts +7 -0
  140. package/lib/src/generated/api/HostingVersionInfo.js +2 -0
  141. package/lib/src/generated/api/HostingWalletResult.d.ts +8 -0
  142. package/lib/src/generated/api/HostingWalletResult.js +1 -0
  143. package/lib/src/generated/api/IceServer.d.ts +18 -0
  144. package/lib/src/generated/api/IceServer.js +2 -0
  145. package/lib/src/generated/api/Icon.d.ts +3 -0
  146. package/lib/src/generated/api/Icon.js +2 -0
  147. package/lib/src/generated/api/ImportResult.d.ts +15 -0
  148. package/lib/src/generated/api/ImportResult.js +1 -0
  149. package/lib/src/generated/api/ImportStats.d.ts +7 -0
  150. package/lib/src/generated/api/ImportStats.js +2 -0
  151. package/lib/src/generated/api/InteractionCall.d.ts +4 -0
  152. package/lib/src/generated/api/InteractionCall.js +2 -0
  153. package/lib/src/generated/api/InteractionCallWrapper.d.ts +6 -0
  154. package/lib/src/generated/api/InteractionCallWrapper.js +2 -0
  155. package/lib/src/generated/api/InteractionMeta.d.ts +6 -0
  156. package/lib/src/generated/api/InteractionMeta.js +1 -0
  157. package/lib/src/generated/api/InteractionParameter.d.ts +4 -0
  158. package/lib/src/generated/api/InteractionParameter.js +2 -0
  159. package/lib/src/generated/api/LanguageAddressParams.d.ts +3 -0
  160. package/lib/src/generated/api/LanguageAddressParams.js +2 -0
  161. package/lib/src/generated/api/LanguageHandle.d.ts +9 -0
  162. package/lib/src/generated/api/LanguageHandle.js +1 -0
  163. package/lib/src/generated/api/LanguageListParams.d.ts +3 -0
  164. package/lib/src/generated/api/LanguageListParams.js +2 -0
  165. package/lib/src/generated/api/LanguageMeta.d.ts +11 -0
  166. package/lib/src/generated/api/LanguageMeta.js +2 -0
  167. package/lib/src/generated/api/LanguageMetaInput.d.ts +2 -2
  168. package/lib/src/generated/api/LanguageRef.d.ts +4 -0
  169. package/lib/src/generated/api/LanguageRef.js +2 -0
  170. package/lib/src/generated/api/LanguageSettingsWrapper.d.ts +6 -0
  171. package/lib/src/generated/api/LanguageSettingsWrapper.js +2 -0
  172. package/lib/src/generated/api/LanguageWriteSettingsParams.d.ts +4 -0
  173. package/lib/src/generated/api/LanguageWriteSettingsParams.js +2 -0
  174. package/lib/src/generated/api/LinkExpressionInput.d.ts +1 -1
  175. package/lib/src/generated/api/LinkInput.d.ts +1 -1
  176. package/lib/src/generated/api/LinkMutationRequest.d.ts +12 -0
  177. package/lib/src/generated/api/LinkMutationRequest.js +1 -0
  178. package/lib/src/generated/api/LinkMutationsRequest.d.ts +5 -0
  179. package/lib/src/generated/api/LinkMutationsRequest.js +1 -0
  180. package/lib/src/generated/api/LinkStatus.d.ts +1 -1
  181. package/lib/src/generated/api/LinkUpdateInput.d.ts +5 -0
  182. package/lib/src/generated/api/LinkUpdateInput.js +1 -0
  183. package/lib/src/generated/api/LocalModel.d.ts +7 -0
  184. package/lib/src/generated/api/LocalModel.js +1 -0
  185. package/lib/src/generated/api/LocalModelInput.d.ts +7 -0
  186. package/lib/src/generated/api/LocalModelInput.js +1 -0
  187. package/lib/src/generated/api/MessageReceivedEvent.d.ts +7 -0
  188. package/lib/src/generated/api/MessageReceivedEvent.js +1 -0
  189. package/lib/src/generated/api/Model.d.ts +10 -0
  190. package/lib/src/generated/api/Model.js +1 -0
  191. package/lib/src/generated/api/ModelApi.d.ts +17 -0
  192. package/lib/src/generated/api/ModelApi.js +1 -0
  193. package/lib/src/generated/api/ModelApiInput.d.ts +11 -0
  194. package/lib/src/generated/api/ModelApiInput.js +2 -0
  195. package/lib/src/generated/api/ModelApiType.d.ts +1 -0
  196. package/lib/src/generated/api/ModelApiType.js +2 -0
  197. package/lib/src/generated/api/ModelInput.d.ts +9 -0
  198. package/lib/src/generated/api/ModelInput.js +1 -0
  199. package/lib/src/generated/api/ModelType.d.ts +1 -1
  200. package/lib/src/generated/api/Neighbourhood.d.ts +5 -0
  201. package/lib/src/generated/api/Neighbourhood.js +1 -0
  202. package/lib/src/generated/api/NeighbourhoodBroadcastParams.d.ts +7 -0
  203. package/lib/src/generated/api/NeighbourhoodBroadcastParams.js +1 -0
  204. package/lib/src/generated/api/NeighbourhoodOnlineStatusParams.d.ts +6 -0
  205. package/lib/src/generated/api/NeighbourhoodOnlineStatusParams.js +1 -0
  206. package/lib/src/generated/api/NeighbourhoodPerspectivePayload.d.ts +7 -0
  207. package/lib/src/generated/api/NeighbourhoodPerspectivePayload.js +1 -0
  208. package/lib/src/generated/api/NeighbourhoodPhase.d.ts +6 -0
  209. package/lib/src/generated/api/NeighbourhoodPhase.js +2 -0
  210. package/lib/src/generated/api/NeighbourhoodSignalFilter.d.ts +8 -0
  211. package/lib/src/generated/api/NeighbourhoodSignalFilter.js +1 -0
  212. package/lib/src/generated/api/NeighbourhoodSignalParams.d.ts +7 -0
  213. package/lib/src/generated/api/NeighbourhoodSignalParams.js +1 -0
  214. package/lib/src/generated/api/NeighbourhoodSignedPerspective.d.ts +8 -0
  215. package/lib/src/generated/api/NeighbourhoodSignedPerspective.js +1 -0
  216. package/lib/src/generated/api/NeighbourhoodUuidParams.d.ts +3 -0
  217. package/lib/src/generated/api/NeighbourhoodUuidParams.js +2 -0
  218. package/lib/src/generated/api/Notification.d.ts +16 -0
  219. package/lib/src/generated/api/Notification.js +2 -0
  220. package/lib/src/generated/api/NotificationGrantRequest.d.ts +6 -0
  221. package/lib/src/generated/api/NotificationGrantRequest.js +2 -0
  222. package/lib/src/generated/api/NotificationInput.d.ts +1 -1
  223. package/lib/src/generated/api/NotificationTriggeredEvent.d.ts +9 -0
  224. package/lib/src/generated/api/NotificationTriggeredEvent.js +1 -0
  225. package/lib/src/generated/api/OnlineAgent.d.ts +9 -0
  226. package/lib/src/generated/api/OnlineAgent.js +1 -0
  227. package/lib/src/generated/api/OutputRef.d.ts +12 -0
  228. package/lib/src/generated/api/OutputRef.js +2 -0
  229. package/lib/src/generated/api/OverlayView.d.ts +24 -0
  230. package/lib/src/generated/api/OverlayView.js +1 -0
  231. package/lib/src/generated/api/Perspective.d.ts +4 -0
  232. package/lib/src/generated/api/Perspective.js +1 -0
  233. package/lib/src/generated/api/PerspectiveAddAutoProcessorParams.d.ts +26 -0
  234. package/lib/src/generated/api/PerspectiveAddAutoProcessorParams.js +2 -0
  235. package/lib/src/generated/api/PerspectiveAddLinkExpressionParams.d.ts +7 -0
  236. package/lib/src/generated/api/PerspectiveAddLinkExpressionParams.js +1 -0
  237. package/lib/src/generated/api/PerspectiveAddLinkParams.d.ts +7 -0
  238. package/lib/src/generated/api/PerspectiveAddLinkParams.js +1 -0
  239. package/lib/src/generated/api/PerspectiveAddLinksParams.d.ts +7 -0
  240. package/lib/src/generated/api/PerspectiveAddLinksParams.js +1 -0
  241. package/lib/src/generated/api/PerspectiveAddSdnaParams.d.ts +14 -0
  242. package/lib/src/generated/api/PerspectiveAddSdnaParams.js +1 -0
  243. package/lib/src/generated/api/PerspectiveAddSdnaResult.d.ts +4 -0
  244. package/lib/src/generated/api/PerspectiveAddSdnaResult.js +2 -0
  245. package/lib/src/generated/api/PerspectiveCommitBatchParams.d.ts +4 -0
  246. package/lib/src/generated/api/PerspectiveCommitBatchParams.js +2 -0
  247. package/lib/src/generated/api/PerspectiveCreateSubjectParams.d.ts +7 -0
  248. package/lib/src/generated/api/PerspectiveCreateSubjectParams.js +2 -0
  249. package/lib/src/generated/api/PerspectiveDiscardBatchParams.d.ts +4 -0
  250. package/lib/src/generated/api/PerspectiveDiscardBatchParams.js +2 -0
  251. package/lib/src/generated/api/PerspectiveEvaluateGettersParams.d.ts +9 -0
  252. package/lib/src/generated/api/PerspectiveEvaluateGettersParams.js +2 -0
  253. package/lib/src/generated/api/PerspectiveExecuteCommandsParams.d.ts +7 -0
  254. package/lib/src/generated/api/PerspectiveExecuteCommandsParams.js +2 -0
  255. package/lib/src/generated/api/PerspectiveExpression.d.ts +8 -0
  256. package/lib/src/generated/api/PerspectiveExpression.js +1 -0
  257. package/lib/src/generated/api/PerspectiveFlowFiredParams.d.ts +8 -0
  258. package/lib/src/generated/api/PerspectiveFlowFiredParams.js +2 -0
  259. package/lib/src/generated/api/PerspectiveFlowProposalParams.d.ts +4 -0
  260. package/lib/src/generated/api/PerspectiveFlowProposalParams.js +2 -0
  261. package/lib/src/generated/api/PerspectiveFlowReceiptVerdict.d.ts +12 -0
  262. package/lib/src/generated/api/PerspectiveFlowReceiptVerdict.js +1 -0
  263. package/lib/src/generated/api/PerspectiveFlowStatesParams.d.ts +11 -0
  264. package/lib/src/generated/api/PerspectiveFlowStatesParams.js +2 -0
  265. package/lib/src/generated/api/PerspectiveFlowValidOutputsParams.d.ts +8 -0
  266. package/lib/src/generated/api/PerspectiveFlowValidOutputsParams.js +2 -0
  267. package/lib/src/generated/api/PerspectiveGetAllShaclParams.d.ts +7 -0
  268. package/lib/src/generated/api/PerspectiveGetAllShaclParams.js +2 -0
  269. package/lib/src/generated/api/PerspectiveGetSubjectDataParams.d.ts +5 -0
  270. package/lib/src/generated/api/PerspectiveGetSubjectDataParams.js +2 -0
  271. package/lib/src/generated/api/PerspectiveHandle.d.ts +10 -0
  272. package/lib/src/generated/api/PerspectiveHandle.js +1 -0
  273. package/lib/src/generated/api/PerspectiveLinkDiff.d.ts +9 -0
  274. package/lib/src/generated/api/PerspectiveLinkDiff.js +1 -0
  275. package/lib/src/generated/api/PerspectiveLinkMutationsParams.d.ts +6 -0
  276. package/lib/src/generated/api/PerspectiveLinkMutationsParams.js +1 -0
  277. package/lib/src/generated/api/PerspectiveLinkUpdatedWithOwner.d.ts +7 -0
  278. package/lib/src/generated/api/PerspectiveLinkUpdatedWithOwner.js +1 -0
  279. package/lib/src/generated/api/PerspectiveLinkWithOwner.d.ts +6 -0
  280. package/lib/src/generated/api/PerspectiveLinkWithOwner.js +1 -0
  281. package/lib/src/generated/api/PerspectiveMintFlowReceiptParams.d.ts +4 -0
  282. package/lib/src/generated/api/PerspectiveMintFlowReceiptParams.js +2 -0
  283. package/lib/src/generated/api/PerspectiveMintFlowReceiptResult.d.ts +9 -0
  284. package/lib/src/generated/api/PerspectiveMintFlowReceiptResult.js +1 -0
  285. package/lib/src/generated/api/PerspectiveModelQueryParams.d.ts +13 -0
  286. package/lib/src/generated/api/PerspectiveModelQueryParams.js +2 -0
  287. package/lib/src/generated/api/PerspectiveNamedShacl.d.ts +6 -0
  288. package/lib/src/generated/api/PerspectiveNamedShacl.js +1 -0
  289. package/lib/src/generated/api/PerspectiveProposeFlowTransitionParams.d.ts +8 -0
  290. package/lib/src/generated/api/PerspectiveProposeFlowTransitionParams.js +1 -0
  291. package/lib/src/generated/api/PerspectiveQueryLinksParams.d.ts +15 -0
  292. package/lib/src/generated/api/PerspectiveQueryLinksParams.js +2 -0
  293. package/lib/src/generated/api/PerspectiveQueryParams.d.ts +4 -0
  294. package/lib/src/generated/api/PerspectiveQueryParams.js +2 -0
  295. package/lib/src/generated/api/PerspectiveReceiptOutcome.d.ts +1 -0
  296. package/lib/src/generated/api/PerspectiveReceiptOutcome.js +2 -0
  297. package/lib/src/generated/api/PerspectiveRejectFlowProposalResult.d.ts +3 -0
  298. package/lib/src/generated/api/PerspectiveRejectFlowProposalResult.js +2 -0
  299. package/lib/src/generated/api/PerspectiveRemoveAutoProcessorParams.d.ts +4 -0
  300. package/lib/src/generated/api/PerspectiveRemoveAutoProcessorParams.js +2 -0
  301. package/lib/src/generated/api/PerspectiveRemoveLinkParams.d.ts +6 -0
  302. package/lib/src/generated/api/PerspectiveRemoveLinkParams.js +1 -0
  303. package/lib/src/generated/api/PerspectiveRemoveLinksParams.d.ts +6 -0
  304. package/lib/src/generated/api/PerspectiveRemoveLinksParams.js +1 -0
  305. package/lib/src/generated/api/PerspectiveRemoveSubjectParams.d.ts +6 -0
  306. package/lib/src/generated/api/PerspectiveRemoveSubjectParams.js +2 -0
  307. package/lib/src/generated/api/PerspectiveRemovedWithOwner.d.ts +5 -0
  308. package/lib/src/generated/api/PerspectiveRemovedWithOwner.js +2 -0
  309. package/lib/src/generated/api/PerspectiveResolveInterpretationParams.d.ts +8 -0
  310. package/lib/src/generated/api/PerspectiveResolveInterpretationParams.js +2 -0
  311. package/lib/src/generated/api/PerspectiveResynced.d.ts +8 -0
  312. package/lib/src/generated/api/PerspectiveResynced.js +2 -0
  313. package/lib/src/generated/api/PerspectiveShacl.d.ts +5 -0
  314. package/lib/src/generated/api/PerspectiveShacl.js +1 -0
  315. package/lib/src/generated/api/PerspectiveShaclNameParams.d.ts +4 -0
  316. package/lib/src/generated/api/PerspectiveShaclNameParams.js +2 -0
  317. package/lib/src/generated/api/PerspectiveSparqlParams.d.ts +8 -0
  318. package/lib/src/generated/api/PerspectiveSparqlParams.js +2 -0
  319. package/lib/src/generated/api/PerspectiveState.d.ts +1 -0
  320. package/lib/src/generated/api/PerspectiveState.js +2 -0
  321. package/lib/src/generated/api/PerspectiveStateFilter.d.ts +7 -0
  322. package/lib/src/generated/api/PerspectiveStateFilter.js +1 -0
  323. package/lib/src/generated/api/PerspectiveSubjectClassesOfParams.d.ts +4 -0
  324. package/lib/src/generated/api/PerspectiveSubjectClassesOfParams.js +2 -0
  325. package/lib/src/generated/api/PerspectiveSubscribed.d.ts +10 -0
  326. package/lib/src/generated/api/PerspectiveSubscribed.js +2 -0
  327. package/lib/src/generated/api/PerspectiveSubscriptionParams.d.ts +4 -0
  328. package/lib/src/generated/api/PerspectiveSubscriptionParams.js +2 -0
  329. package/lib/src/generated/api/PerspectiveUnsignedInput.d.ts +4 -0
  330. package/lib/src/generated/api/PerspectiveUnsignedInput.js +1 -0
  331. package/lib/src/generated/api/PerspectiveUpdateLinkParams.d.ts +8 -0
  332. package/lib/src/generated/api/PerspectiveUpdateLinkParams.js +1 -0
  333. package/lib/src/generated/api/PerspectiveUpdateParams.d.ts +4 -0
  334. package/lib/src/generated/api/PerspectiveUpdateParams.js +2 -0
  335. package/lib/src/generated/api/PerspectiveUpdateSubjectParams.d.ts +10 -0
  336. package/lib/src/generated/api/PerspectiveUpdateSubjectParams.js +2 -0
  337. package/lib/src/generated/api/PerspectiveUuidParams.d.ts +3 -0
  338. package/lib/src/generated/api/PerspectiveUuidParams.js +2 -0
  339. package/lib/src/generated/api/PerspectiveVerifyFlowReceiptParams.d.ts +9 -0
  340. package/lib/src/generated/api/PerspectiveVerifyFlowReceiptParams.js +1 -0
  341. package/lib/src/generated/api/PerspectiveWithOwner.d.ts +6 -0
  342. package/lib/src/generated/api/PerspectiveWithOwner.js +1 -0
  343. package/lib/src/generated/api/ProposeOutcome.d.ts +45 -0
  344. package/lib/src/generated/api/ProposeOutcome.js +1 -0
  345. package/lib/src/generated/api/PublicPerspectiveInput.d.ts +4 -0
  346. package/lib/src/generated/api/PublicPerspectiveInput.js +1 -0
  347. package/lib/src/generated/api/PublishNeighbourhoodRequest.d.ts +2 -2
  348. package/lib/src/generated/api/QuerySubscriptionUpdate.d.ts +19 -0
  349. package/lib/src/generated/api/QuerySubscriptionUpdate.js +2 -0
  350. package/lib/src/generated/api/QuerySubscriptionUpdateEvent.d.ts +7 -0
  351. package/lib/src/generated/api/QuerySubscriptionUpdateEvent.js +1 -0
  352. package/lib/src/generated/api/QueryUpdatesLagged.d.ts +7 -0
  353. package/lib/src/generated/api/QueryUpdatesLagged.js +2 -0
  354. package/lib/src/generated/api/RemoveLinkRequest.d.ts +1 -1
  355. package/lib/src/generated/api/RemoveLinksBulkRequest.d.ts +1 -1
  356. package/lib/src/generated/api/RemoveSubjectRequest.d.ts +9 -0
  357. package/lib/src/generated/api/RemoveSubjectRequest.js +2 -0
  358. package/lib/src/generated/api/RequestCapabilityRequest.d.ts +4 -0
  359. package/lib/src/generated/api/RequestCapabilityRequest.js +1 -0
  360. package/lib/src/generated/api/RequestPaymentRequest.d.ts +3 -0
  361. package/lib/src/generated/api/RequestPaymentRequest.js +2 -0
  362. package/lib/src/generated/api/Resource.d.ts +4 -0
  363. package/lib/src/generated/api/Resource.js +2 -0
  364. package/lib/src/generated/api/ResyncSubscriptionRequest.d.ts +3 -0
  365. package/lib/src/generated/api/ResyncSubscriptionRequest.js +2 -0
  366. package/lib/src/generated/api/RpcMethods.d.ts +961 -0
  367. package/lib/src/generated/api/RpcMethods.js +98 -0
  368. package/lib/src/generated/api/RunInterpretationRequest.d.ts +27 -1
  369. package/lib/src/generated/api/RunInterpretationWithHarnessRequest.d.ts +52 -0
  370. package/lib/src/generated/api/RunInterpretationWithHarnessRequest.js +1 -0
  371. package/lib/src/generated/api/RuntimeComputeLogParams.d.ts +14 -0
  372. package/lib/src/generated/api/RuntimeComputeLogParams.js +2 -0
  373. package/lib/src/generated/api/RuntimeFriendStatusParams.d.ts +3 -0
  374. package/lib/src/generated/api/RuntimeFriendStatusParams.js +2 -0
  375. package/lib/src/generated/api/RuntimeGrantNotificationParams.d.ts +4 -0
  376. package/lib/src/generated/api/RuntimeGrantNotificationParams.js +2 -0
  377. package/lib/src/generated/api/RuntimeImportPerspectiveResult.d.ts +4 -0
  378. package/lib/src/generated/api/RuntimeImportPerspectiveResult.js +2 -0
  379. package/lib/src/generated/api/RuntimeImportResult.d.ts +6 -0
  380. package/lib/src/generated/api/RuntimeImportResult.js +1 -0
  381. package/lib/src/generated/api/RuntimeInfo.d.ts +5 -0
  382. package/lib/src/generated/api/RuntimeInfo.js +2 -0
  383. package/lib/src/generated/api/RuntimeNotificationIdParams.d.ts +3 -0
  384. package/lib/src/generated/api/RuntimeNotificationIdParams.js +2 -0
  385. package/lib/src/generated/api/RuntimeSendFriendMessageParams.d.ts +8 -0
  386. package/lib/src/generated/api/RuntimeSendFriendMessageParams.js +1 -0
  387. package/lib/src/generated/api/RuntimeSetFreeHostingEnabledParams.d.ts +3 -0
  388. package/lib/src/generated/api/RuntimeSetFreeHostingEnabledParams.js +2 -0
  389. package/lib/src/generated/api/RuntimeUnytSendHotParams.d.ts +4 -0
  390. package/lib/src/generated/api/RuntimeUnytSendHotParams.js +2 -0
  391. package/lib/src/generated/api/RuntimeUnytWalletHistoryParams.d.ts +4 -0
  392. package/lib/src/generated/api/RuntimeUnytWalletHistoryParams.js +2 -0
  393. package/lib/src/generated/api/RuntimeUpdateNotificationParams.d.ts +11 -0
  394. package/lib/src/generated/api/RuntimeUpdateNotificationParams.js +2 -0
  395. package/lib/src/generated/api/SentMessage.d.ts +5 -0
  396. package/lib/src/generated/api/SentMessage.js +1 -0
  397. package/lib/src/generated/api/SetHostRatesRequest.d.ts +4 -0
  398. package/lib/src/generated/api/SetHostRatesRequest.js +1 -0
  399. package/lib/src/generated/api/SetHotWalletAddressRequest.d.ts +3 -0
  400. package/lib/src/generated/api/SetHotWalletAddressRequest.js +2 -0
  401. package/lib/src/generated/api/SetOnlineStatusRequest.d.ts +4 -0
  402. package/lib/src/generated/api/SetOnlineStatusRequest.js +2 -0
  403. package/lib/src/generated/api/SetUnytMembraneProofRequest.d.ts +6 -0
  404. package/lib/src/generated/api/SetUnytMembraneProofRequest.js +2 -0
  405. package/lib/src/generated/api/SetUserFreeAccessRequest.d.ts +4 -0
  406. package/lib/src/generated/api/SetUserFreeAccessRequest.js +2 -0
  407. package/lib/src/generated/api/SfuAddIceCandidateParams.d.ts +8 -0
  408. package/lib/src/generated/api/SfuAddIceCandidateParams.js +2 -0
  409. package/lib/src/generated/api/SfuAnswerServerOfferParams.d.ts +8 -0
  410. package/lib/src/generated/api/SfuAnswerServerOfferParams.js +2 -0
  411. package/lib/src/generated/api/SfuCallJoinParams.d.ts +14 -0
  412. package/lib/src/generated/api/SfuCallJoinParams.js +2 -0
  413. package/lib/src/generated/api/SfuCallRenegotiationOffer.d.ts +30 -0
  414. package/lib/src/generated/api/SfuCallRenegotiationOffer.js +1 -0
  415. package/lib/src/generated/api/SfuCascadePipe.d.ts +4 -0
  416. package/lib/src/generated/api/SfuCascadePipe.js +2 -0
  417. package/lib/src/generated/api/SfuCascadeStatus.d.ts +8 -0
  418. package/lib/src/generated/api/SfuCascadeStatus.js +1 -0
  419. package/lib/src/generated/api/SfuConfig.d.ts +52 -0
  420. package/lib/src/generated/api/SfuConfig.js +1 -0
  421. package/lib/src/generated/api/SfuDataMessage.d.ts +24 -0
  422. package/lib/src/generated/api/SfuDataMessage.js +2 -0
  423. package/lib/src/generated/api/SfuEnsureMembershipParams.d.ts +4 -0
  424. package/lib/src/generated/api/SfuEnsureMembershipParams.js +2 -0
  425. package/lib/src/generated/api/SfuMigrateEvent.d.ts +21 -0
  426. package/lib/src/generated/api/SfuMigrateEvent.js +2 -0
  427. package/lib/src/generated/api/SfuNeighbourhoodParams.d.ts +3 -0
  428. package/lib/src/generated/api/SfuNeighbourhoodParams.js +2 -0
  429. package/lib/src/generated/api/SfuParticipantQualityPreference.d.ts +7 -0
  430. package/lib/src/generated/api/SfuParticipantQualityPreference.js +2 -0
  431. package/lib/src/generated/api/SfuPerspectiveParams.d.ts +6 -0
  432. package/lib/src/generated/api/SfuPerspectiveParams.js +2 -0
  433. package/lib/src/generated/api/SfuQualityPreferenceParams.d.ts +8 -0
  434. package/lib/src/generated/api/SfuQualityPreferenceParams.js +2 -0
  435. package/lib/src/generated/api/SfuRoomInfo.d.ts +11 -0
  436. package/lib/src/generated/api/SfuRoomInfo.js +1 -0
  437. package/lib/src/generated/api/SfuRoomParams.d.ts +4 -0
  438. package/lib/src/generated/api/SfuRoomParams.js +2 -0
  439. package/lib/src/generated/api/SfuRoomParticipantInfo.d.ts +11 -0
  440. package/lib/src/generated/api/SfuRoomParticipantInfo.js +2 -0
  441. package/lib/src/generated/api/SfuRoomRoster.d.ts +13 -0
  442. package/lib/src/generated/api/SfuRoomRoster.js +2 -0
  443. package/lib/src/generated/api/SfuSendDataParams.d.ts +10 -0
  444. package/lib/src/generated/api/SfuSendDataParams.js +2 -0
  445. package/lib/src/generated/api/SfuSetConfigParams.d.ts +5 -0
  446. package/lib/src/generated/api/SfuSetConfigParams.js +1 -0
  447. package/lib/src/generated/api/SfuStatus.d.ts +24 -0
  448. package/lib/src/generated/api/SfuStatus.js +2 -0
  449. package/lib/src/generated/api/ShaclLinkTriple.d.ts +10 -0
  450. package/lib/src/generated/api/ShaclLinkTriple.js +2 -0
  451. package/lib/src/generated/api/SignalRequest.d.ts +5 -0
  452. package/lib/src/generated/api/SignalRequest.js +2 -0
  453. package/lib/src/generated/api/SubscribeQueryRequest.d.ts +3 -0
  454. package/lib/src/generated/api/SubscribeQueryRequest.js +2 -0
  455. package/lib/src/generated/api/TokenizerSource.d.ts +5 -0
  456. package/lib/src/generated/api/TokenizerSource.js +2 -0
  457. package/lib/src/generated/api/TokenizerSourceInput.d.ts +5 -0
  458. package/lib/src/generated/api/TokenizerSourceInput.js +2 -0
  459. package/lib/src/generated/api/TrackMapEntry.d.ts +17 -0
  460. package/lib/src/generated/api/TrackMapEntry.js +2 -0
  461. package/lib/src/generated/api/TranscriptionTextFilter.d.ts +5 -0
  462. package/lib/src/generated/api/TranscriptionTextFilter.js +2 -0
  463. package/lib/src/generated/api/TriggeredNotification.d.ts +6 -0
  464. package/lib/src/generated/api/TriggeredNotification.js +1 -0
  465. package/lib/src/generated/api/TrustedAgentsWrapper.d.ts +6 -0
  466. package/lib/src/generated/api/TrustedAgentsWrapper.js +2 -0
  467. package/lib/src/generated/api/UnlockAgentRequest.d.ts +1 -1
  468. package/lib/src/generated/api/UnytVersionInfo.d.ts +19 -0
  469. package/lib/src/generated/api/UnytVersionInfo.js +2 -0
  470. package/lib/src/generated/api/UpdateLinkRequest.d.ts +1 -1
  471. package/lib/src/generated/api/UpdateProfileRequest.d.ts +5 -0
  472. package/lib/src/generated/api/UpdateProfileRequest.js +1 -0
  473. package/lib/src/generated/api/UpdateSubjectRequest.d.ts +12 -0
  474. package/lib/src/generated/api/UpdateSubjectRequest.js +2 -0
  475. package/lib/src/generated/api/UserCreationResult.d.ts +5 -0
  476. package/lib/src/generated/api/UserCreationResult.js +2 -0
  477. package/lib/src/generated/api/UserStatistics.d.ts +2 -1
  478. package/lib/src/generated/api/UserStatistics.js +0 -1
  479. package/lib/src/generated/api/UsersAppInfo.d.ts +6 -0
  480. package/lib/src/generated/api/UsersAppInfo.js +2 -0
  481. package/lib/src/generated/api/UsersEmailParams.d.ts +3 -0
  482. package/lib/src/generated/api/UsersEmailParams.js +2 -0
  483. package/lib/src/generated/api/UsersEmailTestAction.d.ts +1 -0
  484. package/lib/src/generated/api/UsersEmailTestAction.js +2 -0
  485. package/lib/src/generated/api/UsersEmailTestParams.d.ts +14 -0
  486. package/lib/src/generated/api/UsersEmailTestParams.js +1 -0
  487. package/lib/src/generated/api/UsersEmailTestResult.d.ts +5 -0
  488. package/lib/src/generated/api/UsersEmailTestResult.js +2 -0
  489. package/lib/src/generated/api/UsersLoginParams.d.ts +8 -0
  490. package/lib/src/generated/api/UsersLoginParams.js +2 -0
  491. package/lib/src/generated/api/UsersRequestVerificationParams.d.ts +5 -0
  492. package/lib/src/generated/api/UsersRequestVerificationParams.js +1 -0
  493. package/lib/src/generated/api/UsersSetCreditsParams.d.ts +4 -0
  494. package/lib/src/generated/api/UsersSetCreditsParams.js +2 -0
  495. package/lib/src/generated/api/UsersVerifyEmailParams.d.ts +12 -0
  496. package/lib/src/generated/api/UsersVerifyEmailParams.js +2 -0
  497. package/lib/src/generated/api/ValidOutput.d.ts +29 -0
  498. package/lib/src/generated/api/ValidOutput.js +1 -0
  499. package/lib/src/generated/api/VoiceActivityParamsInput.d.ts +7 -0
  500. package/lib/src/generated/api/VoiceActivityParamsInput.js +2 -0
  501. package/lib/src/generated/api/index.d.ts +11 -0
  502. package/lib/src/generated/api/index.js +5 -3
  503. package/lib/src/generated/api/serde_json/JsonValue.d.ts +3 -0
  504. package/lib/src/generated/api/serde_json/JsonValue.js +2 -0
  505. package/lib/src/index.d.ts +9 -3
  506. package/lib/src/index.js +5 -3
  507. package/lib/src/language/LanguageClient.d.ts +3 -3
  508. package/lib/src/language/LanguageClient.js +6 -6
  509. package/lib/src/language/LanguageMeta.d.ts +1 -1
  510. package/lib/src/links/Links.d.ts +16 -5
  511. package/lib/src/links/Links.js +34 -0
  512. package/lib/src/model/Ad4mModel.d.ts +84 -0
  513. package/lib/src/model/Ad4mModel.js +365 -72
  514. package/lib/src/model/ModelQueryBuilder.d.ts +15 -13
  515. package/lib/src/model/ModelQueryBuilder.js +78 -221
  516. package/lib/src/model/decorators.d.ts +52 -2
  517. package/lib/src/model/decorators.js +83 -8
  518. package/lib/src/model/query-sparql.js +2 -3
  519. package/lib/src/model/shacl-gen.d.ts +3 -1
  520. package/lib/src/model/shacl-gen.js +40 -10
  521. package/lib/src/model/types.d.ts +19 -0
  522. package/lib/src/neighbourhood/MeshManager.d.ts +384 -0
  523. package/lib/src/neighbourhood/MeshManager.js +1144 -0
  524. package/lib/src/neighbourhood/Neighbourhood.d.ts +1 -1
  525. package/lib/src/neighbourhood/NeighbourhoodClient.d.ts +96 -5
  526. package/lib/src/neighbourhood/NeighbourhoodClient.js +211 -15
  527. package/lib/src/neighbourhood/NeighbourhoodProxy.d.ts +55 -1
  528. package/lib/src/neighbourhood/NeighbourhoodProxy.js +170 -3
  529. package/lib/src/neighbourhood/Session.d.ts +105 -0
  530. package/lib/src/neighbourhood/Session.js +412 -0
  531. package/lib/src/neighbourhood/SfuManager.d.ts +174 -0
  532. package/lib/src/neighbourhood/SfuManager.js +619 -0
  533. package/lib/src/neighbourhood/SfuTypes.d.ts +35 -0
  534. package/lib/src/neighbourhood/SfuTypes.js +8 -0
  535. package/lib/src/notifyListeners.d.ts +2 -0
  536. package/lib/src/notifyListeners.js +12 -0
  537. package/lib/src/perspectives/AutoProcessor.d.ts +12 -80
  538. package/lib/src/perspectives/FlowInstance.d.ts +73 -26
  539. package/lib/src/perspectives/FlowInstance.js +96 -31
  540. package/lib/src/perspectives/FlowModels.d.ts +30 -9
  541. package/lib/src/perspectives/FlowModels.js +43 -14
  542. package/lib/src/perspectives/InterpretationModels.d.ts +2 -0
  543. package/lib/src/perspectives/InterpretationModels.js +6 -0
  544. package/lib/src/perspectives/LiveQuery.d.ts +49 -0
  545. package/lib/src/perspectives/LiveQuery.js +169 -0
  546. package/lib/src/perspectives/Perspective.d.ts +8 -1
  547. package/lib/src/perspectives/Perspective.js +11 -0
  548. package/lib/src/perspectives/PerspectiveClient.d.ts +38 -65
  549. package/lib/src/perspectives/PerspectiveClient.js +87 -257
  550. package/lib/src/perspectives/PerspectiveDiff.d.ts +1 -1
  551. package/lib/src/perspectives/PerspectiveHandle.d.ts +15 -8
  552. package/lib/src/perspectives/PerspectiveHandle.js +25 -9
  553. package/lib/src/perspectives/PerspectiveProxy.d.ts +102 -228
  554. package/lib/src/perspectives/PerspectiveProxy.js +247 -673
  555. package/lib/src/perspectives/TextContent.d.ts +31 -0
  556. package/lib/src/perspectives/TextContent.js +52 -0
  557. package/lib/src/perspectives/WakerSubscriptionManager.d.ts +23 -0
  558. package/lib/src/perspectives/WakerSubscriptionManager.js +58 -21
  559. package/lib/src/runtime/RuntimeClient.d.ts +15 -27
  560. package/lib/src/runtime/RuntimeClient.js +57 -113
  561. package/lib/src/runtime/RuntimeTypes.d.ts +2 -2
  562. package/lib/src/runtime/RuntimeTypes.js +2 -2
  563. package/lib/src/shacl/SHACLFlow.d.ts +34 -6
  564. package/lib/src/shacl/SHACLFlow.js +62 -15
  565. package/lib/src/shacl/SHACLShape.d.ts +12 -0
  566. package/lib/src/shacl/SHACLShape.js +206 -321
  567. package/package.json +15 -16
  568. package/pnpm-workspace.yaml +4 -1
  569. package/src/Ad4mClient.test.ts +481 -144
  570. package/src/Ad4mClient.ts +16 -12
  571. package/src/Literal.test.ts +32 -0
  572. package/src/Literal.ts +3 -3
  573. package/src/agent/Agent.ts +8 -0
  574. package/src/agent/AgentClient.ts +87 -195
  575. package/src/agent/mutatePublicPerspective.test.ts +110 -0
  576. package/src/ai/AIClient.ts +40 -43
  577. package/src/ai/transcription-stream.test.ts +54 -0
  578. package/src/apiClient.test.ts +613 -185
  579. package/src/apiClient.ts +282 -288
  580. package/src/cache/cache.test.ts +7 -8
  581. package/src/expression/Expression.ts +12 -3
  582. package/src/expression/ExpressionClient.ts +6 -7
  583. package/src/generated/api/AIPromptExamples.ts +3 -0
  584. package/src/generated/api/AIPromptExamplesInput.ts +3 -0
  585. package/src/generated/api/AITask.ts +4 -0
  586. package/src/generated/api/AITaskInput.ts +4 -0
  587. package/src/generated/api/AddAgentInfosRequest.ts +3 -0
  588. package/src/generated/api/AddLinkExpressionRequest.ts +1 -1
  589. package/src/generated/api/AddLinkRequest.ts +1 -1
  590. package/src/generated/api/AddLinksBulkRequest.ts +1 -1
  591. package/src/generated/api/AddSdnaRequest.ts +1 -1
  592. package/src/generated/api/Agent.ts +4 -0
  593. package/src/generated/api/AgentAddEntanglementProofsParams.ts +8 -0
  594. package/src/generated/api/AgentByDidParams.ts +3 -0
  595. package/src/generated/api/AgentRemoveAppParams.ts +3 -0
  596. package/src/generated/api/AgentRevokeTokenParams.ts +3 -0
  597. package/src/generated/api/AgentSignature.ts +3 -0
  598. package/src/generated/api/AgentStatus.ts +4 -0
  599. package/src/generated/api/AgentStatusChangedEvent.ts +7 -0
  600. package/src/generated/api/AgentUpdatedEvent.ts +7 -0
  601. package/src/generated/api/AgentsByDidsRequest.ts +3 -0
  602. package/src/generated/api/AiAddModelParams.ts +4 -0
  603. package/src/generated/api/AiAddTaskParams.ts +4 -0
  604. package/src/generated/api/AiDiscoverModelsParams.ts +7 -0
  605. package/src/generated/api/AiGetDefaultModelParams.ts +4 -0
  606. package/src/generated/api/AiIdParams.ts +3 -0
  607. package/src/generated/api/AiModelLoadingStatusParams.ts +6 -0
  608. package/src/generated/api/AiSetDefaultModelParams.ts +4 -0
  609. package/src/generated/api/AiTranscriptionCloseParams.ts +3 -0
  610. package/src/generated/api/AiTranscriptionOpenParams.ts +4 -0
  611. package/src/generated/api/AiUpdateModelParams.ts +4 -0
  612. package/src/generated/api/AiUpdateTaskParams.ts +4 -0
  613. package/src/generated/api/Apps.ts +4 -0
  614. package/src/generated/api/AuthInfo.ts +4 -0
  615. package/src/generated/api/AuthInfoInput.ts +1 -1
  616. package/src/generated/api/AutoProcessorEvent.ts +90 -0
  617. package/src/generated/api/AutoProcessorNeighbourhoodState.ts +33 -0
  618. package/src/generated/api/AutoProcessorStep.ts +9 -0
  619. package/src/generated/api/BroadcastRequest.ts +3 -0
  620. package/src/generated/api/CallSessionInfo.ts +20 -0
  621. package/src/generated/api/Capability.ts +4 -0
  622. package/src/generated/api/CreateSubjectRequest.ts +1 -1
  623. package/src/generated/api/CreateUserRequest.ts +3 -0
  624. package/src/generated/api/DateTime.ts +3 -0
  625. package/src/generated/api/DecoratedExpressionProof.ts +3 -0
  626. package/src/generated/api/DecoratedLinkExpression.ts +6 -0
  627. package/src/generated/api/DecoratedNeighbourhoodExpression.ts +5 -0
  628. package/src/generated/api/DecoratedPerspective.ts +4 -0
  629. package/src/generated/api/DiscardBatchRequest.ts +3 -0
  630. package/src/generated/api/DisposeQueryRequest.ts +3 -0
  631. package/src/generated/api/EntanglementProof.ts +3 -0
  632. package/src/generated/api/EntanglementProofInput.ts +1 -1
  633. package/src/generated/api/EntanglementProofPreflightRequest.ts +3 -0
  634. package/src/generated/api/EntanglementProofsWrapper.ts +7 -0
  635. package/src/generated/api/Events.ts +77 -0
  636. package/src/generated/api/ExceptionInfo.ts +4 -0
  637. package/src/generated/api/ExceptionOccurredEvent.ts +7 -0
  638. package/src/generated/api/ExceptionType.ts +3 -0
  639. package/src/generated/api/ExecuteCommandsRequest.ts +1 -1
  640. package/src/generated/api/ExportRequest.ts +1 -1
  641. package/src/generated/api/ExpressionInteractRequest.ts +4 -0
  642. package/src/generated/api/ExpressionProofInput.ts +1 -1
  643. package/src/generated/api/ExpressionRendered.ts +6 -0
  644. package/src/generated/api/ExpressionUrlRequest.ts +3 -0
  645. package/src/generated/api/FireOutcome.ts +11 -0
  646. package/src/generated/api/FlowStateChangedEvent.ts +36 -0
  647. package/src/generated/api/FlowStateEntry.ts +18 -0
  648. package/src/generated/api/FriendSendMessageRequest.ts +1 -1
  649. package/src/generated/api/HostRate.ts +6 -0
  650. package/src/generated/api/HostingInfoResult.ts +13 -0
  651. package/src/generated/api/HostingInfoUser.ts +7 -0
  652. package/src/generated/api/HostingRequestPaymentResult.ts +3 -0
  653. package/src/generated/api/HostingUserInfo.ts +3 -0
  654. package/src/generated/api/HostingVersionInfo.ts +7 -0
  655. package/src/generated/api/HostingWalletResult.ts +8 -0
  656. package/src/generated/api/IceServer.ts +19 -0
  657. package/src/generated/api/Icon.ts +3 -0
  658. package/src/generated/api/ImportResult.ts +4 -0
  659. package/src/generated/api/ImportStats.ts +3 -0
  660. package/src/generated/api/InteractionCall.ts +3 -0
  661. package/src/generated/api/InteractionCallWrapper.ts +6 -0
  662. package/src/generated/api/InteractionMeta.ts +4 -0
  663. package/src/generated/api/InteractionParameter.ts +3 -0
  664. package/src/generated/api/LanguageAddressParams.ts +3 -0
  665. package/src/generated/api/LanguageHandle.ts +4 -0
  666. package/src/generated/api/LanguageListParams.ts +3 -0
  667. package/src/generated/api/LanguageMeta.ts +3 -0
  668. package/src/generated/api/LanguageMetaInput.ts +1 -1
  669. package/src/generated/api/LanguageRef.ts +3 -0
  670. package/src/generated/api/LanguageSettingsWrapper.ts +6 -0
  671. package/src/generated/api/LanguageWriteSettingsParams.ts +3 -0
  672. package/src/generated/api/LinkExpressionInput.ts +1 -1
  673. package/src/generated/api/LinkInput.ts +1 -1
  674. package/src/generated/api/LinkMutationRequest.ts +8 -0
  675. package/src/generated/api/LinkMutationsRequest.ts +4 -0
  676. package/src/generated/api/LinkStatus.ts +1 -1
  677. package/src/generated/api/LinkUpdateInput.ts +4 -0
  678. package/src/generated/api/LocalModel.ts +4 -0
  679. package/src/generated/api/LocalModelInput.ts +4 -0
  680. package/src/generated/api/MessageReceivedEvent.ts +7 -0
  681. package/src/generated/api/Model.ts +6 -0
  682. package/src/generated/api/ModelApi.ts +14 -0
  683. package/src/generated/api/ModelApiInput.ts +8 -0
  684. package/src/generated/api/ModelApiType.ts +3 -0
  685. package/src/generated/api/ModelInput.ts +6 -0
  686. package/src/generated/api/ModelType.ts +1 -1
  687. package/src/generated/api/Neighbourhood.ts +4 -0
  688. package/src/generated/api/NeighbourhoodBroadcastParams.ts +4 -0
  689. package/src/generated/api/NeighbourhoodOnlineStatusParams.ts +4 -0
  690. package/src/generated/api/NeighbourhoodPerspectivePayload.ts +9 -0
  691. package/src/generated/api/NeighbourhoodPhase.ts +8 -0
  692. package/src/generated/api/NeighbourhoodSignalFilter.ts +5 -0
  693. package/src/generated/api/NeighbourhoodSignalParams.ts +4 -0
  694. package/src/generated/api/NeighbourhoodSignedPerspective.ts +8 -0
  695. package/src/generated/api/NeighbourhoodUuidParams.ts +3 -0
  696. package/src/generated/api/Notification.ts +7 -0
  697. package/src/generated/api/NotificationGrantRequest.ts +6 -0
  698. package/src/generated/api/NotificationInput.ts +1 -1
  699. package/src/generated/api/NotificationTriggeredEvent.ts +8 -0
  700. package/src/generated/api/OnlineAgent.ts +9 -0
  701. package/src/generated/api/OutputRef.ts +11 -0
  702. package/src/generated/api/OverlayView.ts +25 -0
  703. package/src/generated/api/Perspective.ts +4 -0
  704. package/src/generated/api/PerspectiveAddAutoProcessorParams.ts +11 -0
  705. package/src/generated/api/PerspectiveAddLinkExpressionParams.ts +4 -0
  706. package/src/generated/api/PerspectiveAddLinkParams.ts +4 -0
  707. package/src/generated/api/PerspectiveAddLinksParams.ts +4 -0
  708. package/src/generated/api/PerspectiveAddSdnaParams.ts +7 -0
  709. package/src/generated/api/PerspectiveAddSdnaResult.ts +6 -0
  710. package/src/generated/api/PerspectiveCommitBatchParams.ts +3 -0
  711. package/src/generated/api/PerspectiveCreateSubjectParams.ts +3 -0
  712. package/src/generated/api/PerspectiveDiscardBatchParams.ts +3 -0
  713. package/src/generated/api/PerspectiveEvaluateGettersParams.ts +6 -0
  714. package/src/generated/api/PerspectiveExecuteCommandsParams.ts +3 -0
  715. package/src/generated/api/PerspectiveExpression.ts +5 -0
  716. package/src/generated/api/PerspectiveFlowFiredParams.ts +7 -0
  717. package/src/generated/api/PerspectiveFlowProposalParams.ts +3 -0
  718. package/src/generated/api/PerspectiveFlowReceiptVerdict.ts +8 -0
  719. package/src/generated/api/PerspectiveFlowStatesParams.ts +11 -0
  720. package/src/generated/api/PerspectiveFlowValidOutputsParams.ts +7 -0
  721. package/src/generated/api/PerspectiveGetAllShaclParams.ts +6 -0
  722. package/src/generated/api/PerspectiveGetSubjectDataParams.ts +3 -0
  723. package/src/generated/api/PerspectiveHandle.ts +5 -0
  724. package/src/generated/api/PerspectiveLinkDiff.ts +7 -0
  725. package/src/generated/api/PerspectiveLinkMutationsParams.ts +4 -0
  726. package/src/generated/api/PerspectiveLinkUpdatedWithOwner.ts +4 -0
  727. package/src/generated/api/PerspectiveLinkWithOwner.ts +4 -0
  728. package/src/generated/api/PerspectiveMintFlowReceiptParams.ts +3 -0
  729. package/src/generated/api/PerspectiveMintFlowReceiptResult.ts +9 -0
  730. package/src/generated/api/PerspectiveModelQueryParams.ts +10 -0
  731. package/src/generated/api/PerspectiveNamedShacl.ts +4 -0
  732. package/src/generated/api/PerspectiveProposeFlowTransitionParams.ts +4 -0
  733. package/src/generated/api/PerspectiveQueryLinksParams.ts +11 -0
  734. package/src/generated/api/PerspectiveQueryParams.ts +3 -0
  735. package/src/generated/api/PerspectiveReceiptOutcome.ts +3 -0
  736. package/src/generated/api/PerspectiveRejectFlowProposalResult.ts +3 -0
  737. package/src/generated/api/PerspectiveRemoveAutoProcessorParams.ts +3 -0
  738. package/src/generated/api/PerspectiveRemoveLinkParams.ts +4 -0
  739. package/src/generated/api/PerspectiveRemoveLinksParams.ts +4 -0
  740. package/src/generated/api/PerspectiveRemoveSubjectParams.ts +3 -0
  741. package/src/generated/api/PerspectiveRemovedWithOwner.ts +3 -0
  742. package/src/generated/api/PerspectiveResolveInterpretationParams.ts +6 -0
  743. package/src/generated/api/PerspectiveResynced.ts +7 -0
  744. package/src/generated/api/PerspectiveShacl.ts +4 -0
  745. package/src/generated/api/PerspectiveShaclNameParams.ts +3 -0
  746. package/src/generated/api/PerspectiveSparqlParams.ts +7 -0
  747. package/src/generated/api/PerspectiveState.ts +3 -0
  748. package/src/generated/api/PerspectiveStateFilter.ts +5 -0
  749. package/src/generated/api/PerspectiveSubjectClassesOfParams.ts +3 -0
  750. package/src/generated/api/PerspectiveSubscribed.ts +8 -0
  751. package/src/generated/api/PerspectiveSubscriptionParams.ts +3 -0
  752. package/src/generated/api/PerspectiveUnsignedInput.ts +4 -0
  753. package/src/generated/api/PerspectiveUpdateLinkParams.ts +5 -0
  754. package/src/generated/api/PerspectiveUpdateParams.ts +3 -0
  755. package/src/generated/api/PerspectiveUpdateSubjectParams.ts +7 -0
  756. package/src/generated/api/PerspectiveUuidParams.ts +3 -0
  757. package/src/generated/api/PerspectiveVerifyFlowReceiptParams.ts +9 -0
  758. package/src/generated/api/PerspectiveWithOwner.ts +4 -0
  759. package/src/generated/api/ProposeOutcome.ts +46 -0
  760. package/src/generated/api/PublicPerspectiveInput.ts +4 -0
  761. package/src/generated/api/PublishNeighbourhoodRequest.ts +2 -2
  762. package/src/generated/api/QuerySubscriptionUpdate.ts +10 -0
  763. package/src/generated/api/QuerySubscriptionUpdateEvent.ts +9 -0
  764. package/src/generated/api/QueryUpdatesLagged.ts +7 -0
  765. package/src/generated/api/RemoveLinkRequest.ts +1 -1
  766. package/src/generated/api/RemoveLinksBulkRequest.ts +1 -1
  767. package/src/generated/api/RemoveSubjectRequest.ts +7 -0
  768. package/src/generated/api/RequestCapabilityRequest.ts +4 -0
  769. package/src/generated/api/RequestPaymentRequest.ts +3 -0
  770. package/src/generated/api/Resource.ts +3 -0
  771. package/src/generated/api/ResyncSubscriptionRequest.ts +3 -0
  772. package/src/generated/api/RpcMethods.ts +479 -0
  773. package/src/generated/api/RunInterpretationRequest.ts +28 -2
  774. package/src/generated/api/RunInterpretationWithHarnessRequest.ts +51 -0
  775. package/src/generated/api/RuntimeComputeLogParams.ts +15 -0
  776. package/src/generated/api/RuntimeFriendStatusParams.ts +3 -0
  777. package/src/generated/api/RuntimeGrantNotificationParams.ts +3 -0
  778. package/src/generated/api/RuntimeImportPerspectiveResult.ts +3 -0
  779. package/src/generated/api/RuntimeImportResult.ts +8 -0
  780. package/src/generated/api/RuntimeInfo.ts +3 -0
  781. package/src/generated/api/RuntimeNotificationIdParams.ts +3 -0
  782. package/src/generated/api/RuntimeSendFriendMessageParams.ts +8 -0
  783. package/src/generated/api/RuntimeSetFreeHostingEnabledParams.ts +3 -0
  784. package/src/generated/api/RuntimeUnytSendHotParams.ts +3 -0
  785. package/src/generated/api/RuntimeUnytWalletHistoryParams.ts +3 -0
  786. package/src/generated/api/RuntimeUpdateNotificationParams.ts +3 -0
  787. package/src/generated/api/SentMessage.ts +4 -0
  788. package/src/generated/api/SetHostRatesRequest.ts +4 -0
  789. package/src/generated/api/SetHotWalletAddressRequest.ts +3 -0
  790. package/src/generated/api/SetOnlineStatusRequest.ts +3 -0
  791. package/src/generated/api/SetUnytMembraneProofRequest.ts +7 -0
  792. package/src/generated/api/SetUserFreeAccessRequest.ts +3 -0
  793. package/src/generated/api/SfuAddIceCandidateParams.ts +7 -0
  794. package/src/generated/api/SfuAnswerServerOfferParams.ts +7 -0
  795. package/src/generated/api/SfuCallJoinParams.ts +13 -0
  796. package/src/generated/api/SfuCallRenegotiationOffer.ts +29 -0
  797. package/src/generated/api/SfuCascadePipe.ts +3 -0
  798. package/src/generated/api/SfuCascadeStatus.ts +7 -0
  799. package/src/generated/api/SfuConfig.ts +53 -0
  800. package/src/generated/api/SfuDataMessage.ts +23 -0
  801. package/src/generated/api/SfuEnsureMembershipParams.ts +3 -0
  802. package/src/generated/api/SfuMigrateEvent.ts +20 -0
  803. package/src/generated/api/SfuNeighbourhoodParams.ts +3 -0
  804. package/src/generated/api/SfuParticipantQualityPreference.ts +6 -0
  805. package/src/generated/api/SfuPerspectiveParams.ts +6 -0
  806. package/src/generated/api/SfuQualityPreferenceParams.ts +7 -0
  807. package/src/generated/api/SfuRoomInfo.ts +7 -0
  808. package/src/generated/api/SfuRoomParams.ts +3 -0
  809. package/src/generated/api/SfuRoomParticipantInfo.ts +8 -0
  810. package/src/generated/api/SfuRoomRoster.ts +12 -0
  811. package/src/generated/api/SfuSendDataParams.ts +7 -0
  812. package/src/generated/api/SfuSetConfigParams.ts +4 -0
  813. package/src/generated/api/SfuStatus.ts +24 -0
  814. package/src/generated/api/ShaclLinkTriple.ts +8 -0
  815. package/src/generated/api/SignalRequest.ts +3 -0
  816. package/src/generated/api/SubscribeQueryRequest.ts +3 -0
  817. package/src/generated/api/TokenizerSource.ts +3 -0
  818. package/src/generated/api/TokenizerSourceInput.ts +3 -0
  819. package/src/generated/api/TrackMapEntry.ts +18 -0
  820. package/src/generated/api/TranscriptionTextFilter.ts +3 -0
  821. package/src/generated/api/TriggeredNotification.ts +4 -0
  822. package/src/generated/api/TrustedAgentsWrapper.ts +6 -0
  823. package/src/generated/api/UnlockAgentRequest.ts +1 -1
  824. package/src/generated/api/UnytVersionInfo.ts +20 -0
  825. package/src/generated/api/UpdateLinkRequest.ts +1 -1
  826. package/src/generated/api/UpdateProfileRequest.ts +4 -0
  827. package/src/generated/api/UpdateSubjectRequest.ts +10 -0
  828. package/src/generated/api/UserCreationResult.ts +3 -0
  829. package/src/generated/api/UserStatistics.ts +2 -1
  830. package/src/generated/api/UsersAppInfo.ts +6 -0
  831. package/src/generated/api/UsersEmailParams.ts +3 -0
  832. package/src/generated/api/UsersEmailTestAction.ts +3 -0
  833. package/src/generated/api/UsersEmailTestParams.ts +12 -0
  834. package/src/generated/api/UsersEmailTestResult.ts +7 -0
  835. package/src/generated/api/UsersLoginParams.ts +7 -0
  836. package/src/generated/api/UsersRequestVerificationParams.ts +4 -0
  837. package/src/generated/api/UsersSetCreditsParams.ts +3 -0
  838. package/src/generated/api/UsersVerifyEmailParams.ts +11 -0
  839. package/src/generated/api/ValidOutput.ts +30 -0
  840. package/src/generated/api/VoiceActivityParamsInput.ts +3 -0
  841. package/src/generated/api/index.ts +14 -2
  842. package/src/generated/api/serde_json/JsonValue.ts +3 -0
  843. package/src/index.ts +9 -3
  844. package/src/language/LanguageClient.ts +12 -13
  845. package/src/links/Links.ts +49 -3
  846. package/src/model/Ad4mModel.test.ts +480 -173
  847. package/src/model/Ad4mModel.ts +407 -77
  848. package/src/model/ModelQueryBuilder.ts +95 -255
  849. package/src/model/abstract-classes.test.ts +225 -0
  850. package/src/model/decorators.ts +145 -9
  851. package/src/model/query-sparql.ts +2 -3
  852. package/src/model/relation-filtering.test.ts +191 -0
  853. package/src/model/shacl-gen.ts +32 -9
  854. package/src/model/shacl-roundtrip.test.ts +52 -0
  855. package/src/model/types.ts +19 -0
  856. package/src/neighbourhood/MeshManager.test.ts +2640 -0
  857. package/src/neighbourhood/MeshManager.ts +1350 -0
  858. package/src/neighbourhood/NeighbourhoodClient.test.ts +60 -0
  859. package/src/neighbourhood/NeighbourhoodClient.ts +298 -27
  860. package/src/neighbourhood/NeighbourhoodProxy.test.ts +37 -9
  861. package/src/neighbourhood/NeighbourhoodProxy.ts +247 -1
  862. package/src/neighbourhood/Session.test.ts +800 -0
  863. package/src/neighbourhood/Session.ts +525 -0
  864. package/src/neighbourhood/SfuManager.test.ts +677 -0
  865. package/src/neighbourhood/SfuManager.ts +803 -0
  866. package/src/neighbourhood/SfuTypes.ts +40 -0
  867. package/src/notifyListeners.test.ts +19 -0
  868. package/src/notifyListeners.ts +10 -0
  869. package/src/perspectives/AutoProcessor.ts +13 -82
  870. package/src/perspectives/FlowInstance.ts +136 -32
  871. package/src/perspectives/FlowModels.ts +46 -11
  872. package/src/perspectives/InterpretationModels.ts +4 -0
  873. package/src/perspectives/LiveQuery.test.ts +197 -0
  874. package/src/perspectives/LiveQuery.ts +189 -0
  875. package/src/perspectives/Perspective.ts +18 -2
  876. package/src/perspectives/PerspectiveClient.test.ts +122 -45
  877. package/src/perspectives/PerspectiveClient.ts +146 -343
  878. package/src/perspectives/PerspectiveHandle.ts +32 -9
  879. package/src/perspectives/PerspectiveProxy.test.ts +216 -528
  880. package/src/perspectives/PerspectiveProxy.ts +259 -736
  881. package/src/perspectives/TextContent.test.ts +123 -0
  882. package/src/perspectives/TextContent.ts +36 -0
  883. package/src/perspectives/WakerSubscriptionManager.test.ts +136 -1
  884. package/src/perspectives/WakerSubscriptionManager.ts +69 -22
  885. package/src/perspectives/link-updated-type.test.ts +55 -0
  886. package/src/perspectives/listener-leaks.test.ts +204 -0
  887. package/src/perspectives/shacl-rpc.test.ts +22 -27
  888. package/src/runtime/RuntimeClient.ts +75 -157
  889. package/src/runtime/RuntimeTypes.ts +3 -3
  890. package/src/shacl/SHACLFlow.test.ts +49 -1
  891. package/src/shacl/SHACLFlow.ts +73 -15
  892. package/src/shacl/SHACLShape.test.ts +161 -16
  893. package/src/shacl/SHACLShape.ts +210 -439
  894. package/lib/shims/reflect-metadata.d.ts +0 -0
  895. package/lib/shims/reflect-metadata.js +0 -0
  896. package/lib/shims/type-graphql.d.ts +0 -32
  897. package/lib/shims/type-graphql.js +0 -70
  898. package/lib/src/PubSub.d.ts +0 -17
  899. package/lib/src/PubSub.js +0 -17
  900. package/lib/src/agent/AgentResolver.d.ts +0 -30
  901. package/lib/src/agent/AgentResolver.js +0 -325
  902. package/lib/src/ai/AIResolver.d.ts +0 -75
  903. package/lib/src/ai/AIResolver.js +0 -455
  904. package/lib/src/buildSchema.d.ts +0 -1
  905. package/lib/src/buildSchema.js +0 -38
  906. package/lib/src/expression/ExpressionResolver.d.ts +0 -10
  907. package/lib/src/expression/ExpressionResolver.js +0 -106
  908. package/lib/src/language/LanguageContext.d.ts +0 -37
  909. package/lib/src/language/LanguageContext.js +0 -2
  910. package/lib/src/language/LanguageResolver.d.ts +0 -19
  911. package/lib/src/language/LanguageResolver.js +0 -143
  912. package/lib/src/links/Links.test.js +0 -33
  913. package/lib/src/model/Ad4mModel.test.js +0 -2055
  914. package/lib/src/model/Subject.d.ts +0 -25
  915. package/lib/src/model/Subject.js +0 -164
  916. package/lib/src/model/hydration-batch.d.ts +0 -34
  917. package/lib/src/model/hydration-batch.js +0 -147
  918. package/lib/src/model/hydration-batching.test.d.ts +0 -7
  919. package/lib/src/model/hydration-batching.test.js +0 -456
  920. package/lib/src/model/model-manifest.d.ts +0 -41
  921. package/lib/src/model/model-manifest.js +0 -11
  922. package/lib/src/model/prolog-facts.d.ts +0 -37
  923. package/lib/src/model/prolog-facts.js +0 -134
  924. package/lib/src/model/query-cache.test.js +0 -43
  925. package/lib/src/model/query-prolog.d.ts +0 -15
  926. package/lib/src/model/query-prolog.js +0 -140
  927. package/lib/src/model/query-sparql-batch.d.ts +0 -17
  928. package/lib/src/model/query-sparql-batch.js +0 -260
  929. package/lib/src/model/query-sparql.test.js +0 -312
  930. package/lib/src/model/relation-filtering.test.js +0 -838
  931. package/lib/src/model/subscription-delta.test.d.ts +0 -24
  932. package/lib/src/model/subscription-delta.test.js +0 -180
  933. package/lib/src/model/subscription-pool.d.ts +0 -39
  934. package/lib/src/model/subscription-pool.js +0 -165
  935. package/lib/src/neighbourhood/NeighbourhoodProxy.test.js +0 -73
  936. package/lib/src/neighbourhood/NeighbourhoodResolver.d.ts +0 -24
  937. package/lib/src/neighbourhood/NeighbourhoodResolver.js +0 -182
  938. package/lib/src/perspectives/Perspective.test.js +0 -20
  939. package/lib/src/perspectives/PerspectiveClient.test.js +0 -224
  940. package/lib/src/perspectives/PerspectiveResolver.d.ts +0 -56
  941. package/lib/src/perspectives/PerspectiveResolver.js +0 -519
  942. package/lib/src/runtime/RuntimeResolver.d.ts +0 -173
  943. package/lib/src/runtime/RuntimeResolver.js +0 -1122
  944. package/lib/src/schema.gql +0 -631
  945. package/lib/src/shacl/SHACLFlow.test.js +0 -205
  946. package/lib/src/shacl/SHACLShape.test.js +0 -418
  947. package/lib/src/unwrapApolloResult.d.ts +0 -2
  948. package/lib/src/unwrapApolloResult.js +0 -14
  949. /package/lib/src/{links/Links.test.d.ts → generated/api/AITask.js} +0 -0
  950. /package/lib/src/{model/Ad4mModel.test.d.ts → generated/api/AITaskInput.js} +0 -0
  951. /package/lib/src/{model/query-cache.test.d.ts → generated/api/Agent.js} +0 -0
  952. /package/lib/src/{model/query-sparql.test.d.ts → generated/api/AgentAddEntanglementProofsParams.js} +0 -0
  953. /package/lib/src/{model/relation-filtering.test.d.ts → generated/api/AgentStatus.js} +0 -0
  954. /package/lib/src/{neighbourhood/NeighbourhoodProxy.test.d.ts → generated/api/AgentStatusChangedEvent.js} +0 -0
  955. /package/lib/src/{perspectives/Perspective.test.d.ts → generated/api/AgentUpdatedEvent.js} +0 -0
  956. /package/lib/src/{perspectives/PerspectiveClient.test.d.ts → generated/api/AiAddModelParams.js} +0 -0
  957. /package/lib/src/{shacl/SHACLFlow.test.d.ts → generated/api/AiAddTaskParams.js} +0 -0
  958. /package/lib/src/{shacl/SHACLShape.test.d.ts → generated/api/AiGetDefaultModelParams.js} +0 -0
@@ -1,2055 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- var __metadata = (this && this.__metadata) || function (k, v) {
8
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
- };
10
- import { Ad4mModel } from "./Ad4mModel";
11
- import { Model, Property, Optional, ReadOnly, HasMany, Flag } from "./decorators";
12
- describe("Ad4mModel.getModelMetadata()", () => {
13
- it("should extract basic model metadata with className", () => {
14
- let SimpleModel = class SimpleModel extends Ad4mModel {
15
- };
16
- SimpleModel = __decorate([
17
- Model({ name: "SimpleModel" })
18
- ], SimpleModel);
19
- const metadata = SimpleModel.getModelMetadata();
20
- expect(metadata.className).toBe("SimpleModel");
21
- expect(metadata.properties).toEqual({});
22
- expect(metadata.relations).toEqual({});
23
- });
24
- it("should extract property metadata with all fields", () => {
25
- let PropertyModel = class PropertyModel extends Ad4mModel {
26
- constructor() {
27
- super(...arguments);
28
- this.name = "";
29
- this.optional = "";
30
- this.readonly = "";
31
- this.type = "";
32
- }
33
- };
34
- __decorate([
35
- Property({ through: "test://name", resolveLanguage: "literal" }),
36
- __metadata("design:type", String)
37
- ], PropertyModel.prototype, "name", void 0);
38
- __decorate([
39
- Optional({ through: "test://optional" }),
40
- __metadata("design:type", String)
41
- ], PropertyModel.prototype, "optional", void 0);
42
- __decorate([
43
- ReadOnly({ through: "test://readonly", prologGetter: "custom_getter" }),
44
- __metadata("design:type", String)
45
- ], PropertyModel.prototype, "readonly", void 0);
46
- __decorate([
47
- Flag({ through: "test://type", value: "test://flag" }),
48
- __metadata("design:type", String)
49
- ], PropertyModel.prototype, "type", void 0);
50
- PropertyModel = __decorate([
51
- Model({ name: "PropertyModel" })
52
- ], PropertyModel);
53
- const metadata = PropertyModel.getModelMetadata();
54
- // Should have 4 properties
55
- expect(Object.keys(metadata.properties)).toHaveLength(4);
56
- // Verify "name" property
57
- expect(metadata.properties.name.predicate).toBe("test://name");
58
- expect(metadata.properties.name.required).toBe(false);
59
- expect(metadata.properties.name.readOnly).toBe(false);
60
- expect(metadata.properties.name.resolveLanguage).toBe("literal");
61
- // Verify "optional" property
62
- expect(metadata.properties.optional.predicate).toBe("test://optional");
63
- expect(metadata.properties.optional.readOnly).toBe(false);
64
- // Verify "readonly" property
65
- expect(metadata.properties.readonly.predicate).toBe("test://readonly");
66
- expect(metadata.properties.readonly.readOnly).toBe(true);
67
- expect(metadata.properties.readonly.prologGetter).toBe("custom_getter");
68
- // Verify "type" property (flag)
69
- expect(metadata.properties.type.predicate).toBe("test://type");
70
- expect(metadata.properties.type.flag).toBe(true);
71
- expect(metadata.properties.type.initial).toBe("test://flag");
72
- });
73
- it("should extract relation metadata with various options", () => {
74
- let RelationModel = class RelationModel extends Ad4mModel {
75
- constructor() {
76
- super(...arguments);
77
- this.items = [];
78
- this.local = [];
79
- }
80
- };
81
- __decorate([
82
- HasMany({ through: "test://items" }),
83
- __metadata("design:type", Array)
84
- ], RelationModel.prototype, "items", void 0);
85
- __decorate([
86
- HasMany({ through: "test://local", local: true }),
87
- __metadata("design:type", Array)
88
- ], RelationModel.prototype, "local", void 0);
89
- RelationModel = __decorate([
90
- Model({ name: "RelationModel" })
91
- ], RelationModel);
92
- const metadata = RelationModel.getModelMetadata();
93
- // Should have 2 relations
94
- expect(Object.keys(metadata.relations)).toHaveLength(2);
95
- // Verify "items" relation
96
- expect(metadata.relations.items.predicate).toBe("test://items");
97
- // Verify "local" relation
98
- expect(metadata.relations.local.predicate).toBe("test://local");
99
- expect(metadata.relations.local.local).toBe(true);
100
- });
101
- it("should extract transform function from property metadata", () => {
102
- let TransformModel = class TransformModel extends Ad4mModel {
103
- constructor() {
104
- super(...arguments);
105
- this.data = "";
106
- }
107
- };
108
- __decorate([
109
- Optional({
110
- through: "test://data",
111
- transform: (value) => value.toUpperCase()
112
- }),
113
- __metadata("design:type", String)
114
- ], TransformModel.prototype, "data", void 0);
115
- TransformModel = __decorate([
116
- Model({ name: "TransformModel" })
117
- ], TransformModel);
118
- const metadata = TransformModel.getModelMetadata();
119
- // Assert transform is a function
120
- expect(typeof metadata.properties.data.transform).toBe("function");
121
- // Test the transform function
122
- const transformed = metadata.properties.data.transform("test");
123
- expect(transformed).toBe("TEST");
124
- });
125
- it("should extract custom getter and setter from property metadata", () => {
126
- let CustomModel = class CustomModel extends Ad4mModel {
127
- constructor() {
128
- super(...arguments);
129
- this.computed = 0;
130
- }
131
- };
132
- __decorate([
133
- Optional({
134
- through: "test://computed",
135
- prologGetter: "triple(Base, 'test://value', V), Value is V * 2",
136
- prologSetter: "Value is V / 2, Actions = [{action: 'setSingleTarget', source: 'this', predicate: 'test://value', target: Value}]"
137
- }),
138
- __metadata("design:type", Number)
139
- ], CustomModel.prototype, "computed", void 0);
140
- CustomModel = __decorate([
141
- Model({ name: "CustomModel" })
142
- ], CustomModel);
143
- const metadata = CustomModel.getModelMetadata();
144
- // Assert prologGetter and prologSetter contain the custom code
145
- expect(metadata.properties.computed.prologGetter).toContain("triple(Base, 'test://value', V), Value is V * 2");
146
- expect(metadata.properties.computed.prologSetter).toContain("Value is V / 2");
147
- expect(metadata.properties.computed.prologSetter).toContain("setSingleTarget");
148
- });
149
- it("should handle relation with typed target relation", () => {
150
- let Comment = class Comment extends Ad4mModel {
151
- };
152
- Comment = __decorate([
153
- Model({ name: "Comment" })
154
- ], Comment);
155
- let Post = class Post extends Ad4mModel {
156
- constructor() {
157
- super(...arguments);
158
- this.comments = [];
159
- }
160
- };
161
- __decorate([
162
- HasMany({
163
- through: "post://comment",
164
- target: () => Comment
165
- }),
166
- __metadata("design:type", Array)
167
- ], Post.prototype, "comments", void 0);
168
- Post = __decorate([
169
- Model({ name: "Post" })
170
- ], Post);
171
- const metadata = Post.getModelMetadata();
172
- // Assert relation exists with correct predicate
173
- expect(metadata.relations.comments).toBeDefined();
174
- expect(metadata.relations.comments.predicate).toBe("post://comment");
175
- });
176
- it("should throw error for class without @Model decorator", () => {
177
- class NoDecoratorModel extends Ad4mModel {
178
- }
179
- // Assert that calling getModelMetadata throws an error
180
- expect(() => NoDecoratorModel.getModelMetadata()).toThrow("Model class must be decorated with @Model");
181
- });
182
- it("should handle complex model with mixed property and relation types", () => {
183
- let Recipe = class Recipe extends Ad4mModel {
184
- constructor() {
185
- super(...arguments);
186
- this.name = "";
187
- this.description = "";
188
- this.rating = 0;
189
- this.ingredients = [];
190
- this.steps = [];
191
- }
192
- };
193
- __decorate([
194
- Property({ through: "recipe://name", resolveLanguage: "literal" }),
195
- __metadata("design:type", String)
196
- ], Recipe.prototype, "name", void 0);
197
- __decorate([
198
- Optional({ through: "recipe://description" }),
199
- __metadata("design:type", String)
200
- ], Recipe.prototype, "description", void 0);
201
- __decorate([
202
- ReadOnly({ through: "recipe://rating", prologGetter: "avg_rating(Base, Value)" }),
203
- __metadata("design:type", Number)
204
- ], Recipe.prototype, "rating", void 0);
205
- __decorate([
206
- HasMany({ through: "recipe://ingredient" }),
207
- __metadata("design:type", Array)
208
- ], Recipe.prototype, "ingredients", void 0);
209
- __decorate([
210
- HasMany({ through: "recipe://step", local: true }),
211
- __metadata("design:type", Array)
212
- ], Recipe.prototype, "steps", void 0);
213
- Recipe = __decorate([
214
- Model({ name: "Recipe" })
215
- ], Recipe);
216
- const metadata = Recipe.getModelMetadata();
217
- // Assert className
218
- expect(metadata.className).toBe("Recipe");
219
- // Assert properties has 3 entries
220
- expect(Object.keys(metadata.properties)).toHaveLength(3);
221
- expect(metadata.properties.name).toBeDefined();
222
- expect(metadata.properties.description).toBeDefined();
223
- expect(metadata.properties.rating).toBeDefined();
224
- // Assert relations has 2 entries
225
- expect(Object.keys(metadata.relations)).toHaveLength(2);
226
- expect(metadata.relations.ingredients).toBeDefined();
227
- expect(metadata.relations.steps).toBeDefined();
228
- // Verify all metadata fields are correctly extracted
229
- expect(metadata.properties.name.predicate).toBe("recipe://name");
230
- expect(metadata.properties.name.resolveLanguage).toBe("literal");
231
- expect(metadata.properties.description.predicate).toBe("recipe://description");
232
- expect(metadata.properties.rating.predicate).toBe("recipe://rating");
233
- expect(metadata.properties.rating.prologGetter).toBe("avg_rating(Base, Value)");
234
- expect(metadata.relations.ingredients.predicate).toBe("recipe://ingredient");
235
- expect(metadata.relations.steps.predicate).toBe("recipe://step");
236
- expect(metadata.relations.steps.local).toBe(true);
237
- });
238
- });
239
- describe("Ad4mModel.fromJSONSchema() with getModelMetadata()", () => {
240
- it("should extract metadata from a model created via fromJSONSchema with basic properties", () => {
241
- const schema = {
242
- title: "Product",
243
- type: "object",
244
- properties: {
245
- name: { type: "string" },
246
- price: { type: "number" },
247
- description: { type: "string" }
248
- },
249
- required: ["name", "price"]
250
- };
251
- const ProductClass = Ad4mModel.fromJSONSchema(schema, {
252
- name: "Product",
253
- namespace: "product://",
254
- resolveLanguage: "literal"
255
- });
256
- const metadata = ProductClass.getModelMetadata();
257
- // Verify className
258
- expect(metadata.className).toBe("Product");
259
- // Verify properties are extracted
260
- expect(Object.keys(metadata.properties).length).toBeGreaterThan(0);
261
- expect(metadata.properties.name).toBeDefined();
262
- expect(metadata.properties.name.predicate).toBe("product://name");
263
- expect(metadata.properties.name.required).toBe(true);
264
- expect(metadata.properties.name.readOnly).toBe(false);
265
- expect(metadata.properties.name.resolveLanguage).toBe("literal");
266
- expect(metadata.properties.price).toBeDefined();
267
- expect(metadata.properties.price.predicate).toBe("product://price");
268
- expect(metadata.properties.price.required).toBe(true);
269
- expect(metadata.properties.price.resolveLanguage).toBe("literal");
270
- expect(metadata.properties.description).toBeDefined();
271
- expect(metadata.properties.description.predicate).toBe("product://description");
272
- expect(metadata.properties.description.required).toBe(false);
273
- });
274
- it("should extract relations from a model created via fromJSONSchema with arrays", () => {
275
- const schema = {
276
- title: "Post",
277
- type: "object",
278
- properties: {
279
- title: { type: "string" },
280
- tags: {
281
- type: "array",
282
- items: { type: "string" }
283
- },
284
- comments: {
285
- type: "array",
286
- items: { type: "string" }
287
- }
288
- },
289
- required: ["title"]
290
- };
291
- const PostClass = Ad4mModel.fromJSONSchema(schema, {
292
- name: "Post",
293
- namespace: "post://"
294
- });
295
- const metadata = PostClass.getModelMetadata();
296
- // Verify className
297
- expect(metadata.className).toBe("Post");
298
- // Verify relations are extracted
299
- expect(Object.keys(metadata.relations).length).toBeGreaterThan(0);
300
- expect(metadata.relations.tags).toBeDefined();
301
- expect(metadata.relations.tags.predicate).toBe("post://tags");
302
- expect(metadata.relations.comments).toBeDefined();
303
- expect(metadata.relations.comments.predicate).toBe("post://comments");
304
- // Verify properties (should include at least title)
305
- expect(metadata.properties.title).toBeDefined();
306
- expect(metadata.properties.title.predicate).toBe("post://title");
307
- expect(metadata.properties.title.required).toBe(true);
308
- });
309
- it("should handle x-ad4m metadata in JSON schema for property options", () => {
310
- const schema = {
311
- title: "Contact",
312
- "x-ad4m": {
313
- namespace: "contact://"
314
- },
315
- type: "object",
316
- properties: {
317
- name: {
318
- type: "string",
319
- "x-ad4m": {
320
- through: "foaf://name",
321
- resolveLanguage: "literal",
322
- writable: true
323
- }
324
- },
325
- email: {
326
- type: "string",
327
- "x-ad4m": {
328
- through: "foaf://mbox",
329
- local: true
330
- }
331
- }
332
- },
333
- required: ["name"]
334
- };
335
- const ContactClass = Ad4mModel.fromJSONSchema(schema, {
336
- name: "Contact"
337
- });
338
- const metadata = ContactClass.getModelMetadata();
339
- // Verify x-ad4m metadata is respected
340
- expect(metadata.properties.name.predicate).toBe("foaf://name");
341
- expect(metadata.properties.name.resolveLanguage).toBe("literal");
342
- expect(metadata.properties.name.readOnly).toBe(false);
343
- expect(metadata.properties.name.required).toBe(true);
344
- expect(metadata.properties.email.predicate).toBe("foaf://mbox");
345
- expect(metadata.properties.email.local).toBe(true);
346
- });
347
- it("should handle property mapping override in options", () => {
348
- const schema = {
349
- title: "User",
350
- type: "object",
351
- properties: {
352
- username: { type: "string" },
353
- fullName: { type: "string" }
354
- },
355
- required: ["username"]
356
- };
357
- const UserClass = Ad4mModel.fromJSONSchema(schema, {
358
- name: "User",
359
- namespace: "user://",
360
- propertyMapping: {
361
- username: "custom://identifier",
362
- fullName: "custom://name"
363
- }
364
- });
365
- const metadata = UserClass.getModelMetadata();
366
- // Verify property mappings are applied
367
- expect(metadata.properties.username.predicate).toBe("custom://identifier");
368
- expect(metadata.properties.fullName.predicate).toBe("custom://name");
369
- });
370
- it("should extract metadata from dynamically generated models with mixed types", () => {
371
- const schema = {
372
- title: "Article",
373
- type: "object",
374
- properties: {
375
- title: { type: "string" },
376
- views: { type: "number" },
377
- published: { type: "boolean" },
378
- authors: {
379
- type: "array",
380
- items: { type: "string" }
381
- },
382
- tags: {
383
- type: "array",
384
- items: { type: "string" },
385
- "x-ad4m": {
386
- local: true
387
- }
388
- }
389
- },
390
- required: ["title", "published"]
391
- };
392
- const ArticleClass = Ad4mModel.fromJSONSchema(schema, {
393
- name: "Article",
394
- namespace: "article://",
395
- resolveLanguage: "literal"
396
- });
397
- const metadata = ArticleClass.getModelMetadata();
398
- // Verify className
399
- expect(metadata.className).toBe("Article");
400
- // Verify properties
401
- expect(metadata.properties.title).toBeDefined();
402
- expect(metadata.properties.title.predicate).toBe("article://title");
403
- expect(metadata.properties.title.required).toBe(true);
404
- expect(metadata.properties.title.resolveLanguage).toBe("literal");
405
- expect(metadata.properties.views).toBeDefined();
406
- expect(metadata.properties.views.predicate).toBe("article://views");
407
- expect(metadata.properties.views.resolveLanguage).toBe("literal");
408
- expect(metadata.properties.published).toBeDefined();
409
- expect(metadata.properties.published.predicate).toBe("article://published");
410
- expect(metadata.properties.published.required).toBe(true);
411
- // Verify relations
412
- expect(metadata.relations.authors).toBeDefined();
413
- expect(metadata.relations.authors.predicate).toBe("article://authors");
414
- expect(metadata.relations.tags).toBeDefined();
415
- expect(metadata.relations.tags.predicate).toBe("article://tags");
416
- expect(metadata.relations.tags.local).toBe(true);
417
- });
418
- it("should handle models with no properties (open-world, no auto-flag)", () => {
419
- const schema = {
420
- title: "EmptyModel",
421
- type: "object",
422
- properties: {}
423
- };
424
- const EmptyModelClass = Ad4mModel.fromJSONSchema(schema, {
425
- name: "EmptyModel",
426
- namespace: "empty://"
427
- });
428
- const metadata = EmptyModelClass.getModelMetadata();
429
- // Should have className
430
- expect(metadata.className).toBe("EmptyModel");
431
- // Should NOT have an auto-generated __ad4m_type property —
432
- // models with all-optional properties use open-world structural matching.
433
- expect(metadata.properties.__ad4m_type).toBeUndefined();
434
- // SHACL shape should still be valid with empty constructor/destructor
435
- const { shape } = EmptyModelClass.generateSHACL();
436
- expect(shape.constructor_actions).toEqual([]);
437
- expect(shape.destructor_actions).toEqual([]);
438
- });
439
- });
440
- describe("Ad4mModel.queryToSPARQL()", () => {
441
- const mockPerspective = {};
442
- function normalizeQuery(query) {
443
- return query.replace(/\s+/g, ' ').trim();
444
- }
445
- let Recipe = class Recipe extends Ad4mModel {
446
- constructor() {
447
- super(...arguments);
448
- this.name = "";
449
- this.rating = 0;
450
- this.ingredients = [];
451
- }
452
- };
453
- __decorate([
454
- Property({ through: "recipe://name", required: true }),
455
- __metadata("design:type", String)
456
- ], Recipe.prototype, "name", void 0);
457
- __decorate([
458
- Property({ through: "recipe://rating", required: true }),
459
- __metadata("design:type", Number)
460
- ], Recipe.prototype, "rating", void 0);
461
- __decorate([
462
- HasMany({ through: "recipe://ingredient" }),
463
- __metadata("design:type", Array)
464
- ], Recipe.prototype, "ingredients", void 0);
465
- Recipe = __decorate([
466
- Model({ name: "Recipe" })
467
- ], Recipe);
468
- it("should generate basic SPARQL query with no filters", async () => {
469
- const query = await Recipe.queryToSPARQL(mockPerspective, {});
470
- const norm = normalizeQuery(query);
471
- // Must be a SPARQL SELECT
472
- expect(norm).toContain("SELECT ?source ?predicate ?target ?author ?timestamp");
473
- // Must have conformance JOIN for required properties using direct triple patterns
474
- expect(norm).toContain("cfTarget_name");
475
- expect(norm).toContain("recipe://name");
476
- });
477
- it("should generate query with simple property filter", async () => {
478
- const query = await Recipe.queryToSPARQL(mockPerspective, { where: { name: "Pasta" } });
479
- const norm = normalizeQuery(query);
480
- expect(norm).toContain("SELECT ?source ?predicate ?target ?author ?timestamp");
481
- // For literal-stored properties, SPARQL only adds a JOIN (no FILTER value) — filtering is in JS
482
- expect(norm).toContain("recipe://name");
483
- // Value should NOT be in SPARQL — filtering happens in JS post-filter
484
- expect(norm).toContain("?wTarget_name");
485
- });
486
- it("should generate query with NOT operator", async () => {
487
- const query = await Recipe.queryToSPARQL(mockPerspective, { where: { name: { not: "Salad" } } });
488
- const norm = normalizeQuery(query);
489
- // For literal-stored properties, NOT filtering is done in JS — no NOT EXISTS in SPARQL
490
- expect(norm).toContain("recipe://name");
491
- });
492
- it("should generate query with NOT IN operator (array)", async () => {
493
- const query = await Recipe.queryToSPARQL(mockPerspective, { where: { name: { not: ["Salad", "Soup"] } } });
494
- const norm = normalizeQuery(query);
495
- // For literal-stored properties, NOT IN filtering is done in JS — no filter values in SPARQL
496
- expect(norm).toContain("recipe://name");
497
- });
498
- it("should generate query with IN clause (array values)", async () => {
499
- const query = await Recipe.queryToSPARQL(mockPerspective, { where: { name: ["Pasta", "Pizza"] } });
500
- const norm = normalizeQuery(query);
501
- // For literal-stored properties, IN filtering is done in JS — only a JOIN exists
502
- expect(norm).toContain("recipe://name");
503
- expect(norm).toContain("?wTarget_name");
504
- });
505
- it("should generate query with base filter", async () => {
506
- const query = await Recipe.queryToSPARQL(mockPerspective, { where: { base: "ad4m://test123" } });
507
- const norm = normalizeQuery(query);
508
- expect(norm).toContain("?source =");
509
- expect(norm).toContain("ad4m://test123");
510
- });
511
- it("should escape special characters in SPARQL strings", async () => {
512
- const query = await Recipe.queryToSPARQL(mockPerspective, { where: { name: 'O\'Brien' } });
513
- const norm = normalizeQuery(query);
514
- // Should not break the query
515
- expect(norm).toContain("SELECT ?source");
516
- });
517
- // =========================================================================
518
- // Additional models for thorough SPARQL structure tests
519
- // =========================================================================
520
- let Task = class Task extends Ad4mModel {
521
- constructor() {
522
- super(...arguments);
523
- this.title = "";
524
- this.priority = 0;
525
- this.done = false;
526
- this.description = "";
527
- this.tags = [];
528
- this.assignees = [];
529
- }
530
- };
531
- __decorate([
532
- Property({ through: "task://title", resolveLanguage: "literal", required: true }),
533
- __metadata("design:type", String)
534
- ], Task.prototype, "title", void 0);
535
- __decorate([
536
- Property({ through: "task://priority", resolveLanguage: "literal" }),
537
- __metadata("design:type", Number)
538
- ], Task.prototype, "priority", void 0);
539
- __decorate([
540
- Property({ through: "task://done", resolveLanguage: "literal" }),
541
- __metadata("design:type", Boolean)
542
- ], Task.prototype, "done", void 0);
543
- __decorate([
544
- Optional({ through: "task://description" }),
545
- __metadata("design:type", String)
546
- ], Task.prototype, "description", void 0);
547
- __decorate([
548
- HasMany({ through: "task://tag" }),
549
- __metadata("design:type", Array)
550
- ], Task.prototype, "tags", void 0);
551
- __decorate([
552
- HasMany({ through: "task://assignee" }),
553
- __metadata("design:type", Array)
554
- ], Task.prototype, "assignees", void 0);
555
- Task = __decorate([
556
- Model({ name: "Task" })
557
- ], Task);
558
- let EmptyModel = class EmptyModel extends Ad4mModel {
559
- constructor() {
560
- super(...arguments);
561
- this.optField = "";
562
- }
563
- };
564
- __decorate([
565
- Optional({ through: "empty://optField" }),
566
- __metadata("design:type", String)
567
- ], EmptyModel.prototype, "optField", void 0);
568
- EmptyModel = __decorate([
569
- Model({ name: "EmptyModel" })
570
- ], EmptyModel);
571
- // ---- Comparison operators (gt, lt, gte, lte, between, contains) ----
572
- // These are handled in JS post-processing, NOT in SPARQL.
573
- // The tests verify that the SPARQL still generates valid output (conformance filters)
574
- // but does NOT inject FILTER clauses for these operators.
575
- it("should inject SPARQL FILTER for gt operator", async () => {
576
- const query = await Recipe.queryToSPARQL(mockPerspective, { where: { rating: { gt: 3 } } });
577
- const norm = normalizeQuery(query);
578
- expect(norm).toContain("SELECT ?source");
579
- // gt is now handled via JS post-filter — SPARQL just joins the property
580
- expect(norm).toContain("wTarget_cmp_rating");
581
- });
582
- it("should inject SPARQL FILTER for lt operator", async () => {
583
- const query = await Recipe.queryToSPARQL(mockPerspective, { where: { rating: { lt: 5 } } });
584
- const norm = normalizeQuery(query);
585
- expect(norm).toContain("SELECT ?source");
586
- // lt is now handled via JS post-filter
587
- expect(norm).toContain("wTarget_cmp_rating");
588
- });
589
- it("should inject SPARQL FILTER for gte/lte combined", async () => {
590
- const query = await Recipe.queryToSPARQL(mockPerspective, { where: { rating: { gte: 2, lte: 8 } } });
591
- const norm = normalizeQuery(query);
592
- expect(norm).toContain("SELECT ?source");
593
- // gte/lte are now handled via JS post-filter
594
- expect(norm).toContain("wTarget_cmp_rating");
595
- });
596
- it("should inject SPARQL FILTER for between operator", async () => {
597
- const query = await Recipe.queryToSPARQL(mockPerspective, { where: { rating: { between: [1, 10] } } });
598
- const norm = normalizeQuery(query);
599
- expect(norm).toContain("SELECT ?source");
600
- // between is now handled via JS post-filter
601
- expect(norm).toContain("wTarget_cmp_rating");
602
- });
603
- it("should inject SPARQL FILTER for contains operator", async () => {
604
- const query = await Recipe.queryToSPARQL(mockPerspective, { where: { name: { contains: "pasta" } } });
605
- const norm = normalizeQuery(query);
606
- expect(norm).toContain("SELECT ?source");
607
- // contains is now handled via JS post-filter
608
- expect(norm).toContain("wTarget_cmp_name");
609
- });
610
- // ---- Multiple property filters combined ----
611
- it("should combine multiple property equality filters with &&", async () => {
612
- const query = await Recipe.queryToSPARQL(mockPerspective, {
613
- where: { name: "Pasta", rating: ["4", "5"] }
614
- });
615
- const norm = normalizeQuery(query);
616
- // Should have EXISTS blocks for both name and rating
617
- expect(norm).toContain("recipe://name");
618
- expect(norm).toContain("recipe://rating");
619
- expect(norm).toContain("&&");
620
- });
621
- // ---- ORDER BY, LIMIT, OFFSET are JS post-processed ----
622
- it("should include ORDER BY/LIMIT/OFFSET in SPARQL pagination subquery", async () => {
623
- const query = await Recipe.queryToSPARQL(mockPerspective, { order: { name: "ASC" }, limit: 10, offset: 5 });
624
- const norm = normalizeQuery(query);
625
- expect(norm).toContain("SELECT ?source");
626
- // SPARQL-level pagination via subquery
627
- expect(norm).toContain("ORDER BY");
628
- expect(norm).toContain("LIMIT 10");
629
- expect(norm).toContain("OFFSET 5");
630
- expect(norm).toContain("SELECT DISTINCT ?source");
631
- });
632
- });
633
- describe("Ad4mModel query methods (modelQuery integration)", () => {
634
- // Test Recipe model
635
- let Recipe = class Recipe extends Ad4mModel {
636
- constructor() {
637
- super(...arguments);
638
- this.name = "";
639
- this.rating = 0;
640
- this.ingredients = [];
641
- }
642
- };
643
- __decorate([
644
- Property({ through: "recipe://name" }),
645
- __metadata("design:type", String)
646
- ], Recipe.prototype, "name", void 0);
647
- __decorate([
648
- Property({ through: "recipe://rating" }),
649
- __metadata("design:type", Number)
650
- ], Recipe.prototype, "rating", void 0);
651
- __decorate([
652
- HasMany({ through: "recipe://ingredient" }),
653
- __metadata("design:type", Array)
654
- ], Recipe.prototype, "ingredients", void 0);
655
- Recipe = __decorate([
656
- Model({ name: "Recipe" })
657
- ], Recipe);
658
- // Mock perspective with querySparql, modelQuery, and infer methods
659
- const mockPerspective = {
660
- querySparql: jest.fn(),
661
- modelQuery: jest.fn(),
662
- infer: jest.fn(),
663
- uuid: 'test-perspective-uuid',
664
- stringOrTemplateObjectToSubjectClassName: jest.fn().mockResolvedValue('Recipe')
665
- };
666
- beforeEach(() => {
667
- jest.clearAllMocks();
668
- });
669
- it("should use SPARQL when engine is 'sparql' in findAll()", async () => {
670
- // modelQuery returns already-hydrated instances from the Rust executor
671
- mockPerspective.modelQuery.mockResolvedValue({
672
- instances: [
673
- { id: "literal:recipe1", name: "Pasta", rating: 5, ingredients: ["pasta"] }
674
- ],
675
- totalCount: 1
676
- });
677
- const results = await Recipe.findAll(mockPerspective, {}, 'sparql');
678
- expect(mockPerspective.modelQuery).toHaveBeenCalledTimes(1);
679
- expect(mockPerspective.infer).not.toHaveBeenCalled();
680
- expect(results).toHaveLength(1);
681
- expect(results[0].name).toBe("Pasta");
682
- });
683
- it("should route through modelQuery when engine is 'prolog' in findAll() (prolog is now no-op)", async () => {
684
- mockPerspective.modelQuery.mockResolvedValue({
685
- instances: [
686
- { id: "literal:recipe1", name: "Pasta", rating: 5, ingredients: ["pasta"] }
687
- ],
688
- totalCount: 1
689
- });
690
- const results = await Recipe.findAll(mockPerspective, {}, false);
691
- expect(mockPerspective.modelQuery).toHaveBeenCalledTimes(1);
692
- expect(mockPerspective.infer).not.toHaveBeenCalled();
693
- expect(results).toHaveLength(1);
694
- });
695
- it("should use SPARQL when engine is 'sparql' in findAllAndCount()", async () => {
696
- mockPerspective.modelQuery.mockResolvedValue({
697
- instances: [
698
- { id: "literal:recipe1", name: "Pasta", rating: 5, ingredients: ["pasta"] }
699
- ],
700
- totalCount: 1
701
- });
702
- const { results, totalCount } = await Recipe.findAllAndCount(mockPerspective, {});
703
- expect(mockPerspective.modelQuery).toHaveBeenCalledTimes(1);
704
- expect(mockPerspective.infer).not.toHaveBeenCalled();
705
- expect(results).toHaveLength(1);
706
- expect(totalCount).toBe(1);
707
- });
708
- it("should use SPARQL when engine is 'sparql' in paginate()", async () => {
709
- mockPerspective.modelQuery.mockResolvedValue({
710
- instances: [
711
- { id: "literal:recipe1", name: "Pasta", rating: 5, ingredients: ["pasta"] }
712
- ],
713
- totalCount: 1
714
- });
715
- const page = await Recipe.paginate(mockPerspective, 10, 1, {});
716
- expect(mockPerspective.modelQuery).toHaveBeenCalledTimes(1);
717
- expect(mockPerspective.infer).not.toHaveBeenCalled();
718
- expect(page.results).toHaveLength(1);
719
- expect(page.pageSize).toBe(10);
720
- expect(page.pageNumber).toBe(1);
721
- expect(page.totalCount).toBe(1);
722
- });
723
- it("should use SPARQL in count()", async () => {
724
- mockPerspective.modelQuery.mockResolvedValue({
725
- instances: [],
726
- totalCount: 5
727
- });
728
- const count = await Recipe.count(mockPerspective, {});
729
- expect(mockPerspective.modelQuery).toHaveBeenCalledTimes(1);
730
- expect(mockPerspective.infer).not.toHaveBeenCalled();
731
- expect(count).toBe(5);
732
- });
733
- it("should return count from modelQuery", async () => {
734
- mockPerspective.modelQuery.mockResolvedValue({
735
- instances: [],
736
- totalCount: 10
737
- });
738
- const count = await Recipe.count(mockPerspective, {});
739
- expect(mockPerspective.modelQuery).toHaveBeenCalledTimes(1);
740
- expect(mockPerspective.querySparql).not.toHaveBeenCalled();
741
- expect(count).toBe(10);
742
- });
743
- it("should use SPARQL when engine is 'sparql' in ModelQueryBuilder.get()", async () => {
744
- mockPerspective.modelQuery.mockResolvedValue({
745
- instances: [
746
- { id: "literal:recipe1", name: "Pasta", rating: 5, ingredients: ["pasta"] }
747
- ],
748
- totalCount: 1
749
- });
750
- const results = await Recipe.query(mockPerspective)
751
- .where({ name: "Pasta" })
752
- .engine('sparql')
753
- .get();
754
- expect(mockPerspective.modelQuery).toHaveBeenCalledTimes(1);
755
- expect(mockPerspective.infer).not.toHaveBeenCalled();
756
- expect(results).toHaveLength(1);
757
- expect(results[0].name).toBe("Pasta");
758
- });
759
- it("should use modelQuery when .engine('prolog') is called (engine is now a no-op)", async () => {
760
- mockPerspective.modelQuery.mockResolvedValue({
761
- instances: [
762
- { id: "literal:recipe1", name: "Pasta", rating: 5, ingredients: ["pasta"] }
763
- ],
764
- totalCount: 1
765
- });
766
- const results = await Recipe.query(mockPerspective)
767
- .where({ name: "Pasta" })
768
- .engine('prolog')
769
- .get();
770
- // engine('prolog') is now a no-op — everything goes through modelQuery
771
- expect(mockPerspective.modelQuery).toHaveBeenCalledTimes(1);
772
- expect(mockPerspective.infer).not.toHaveBeenCalled();
773
- expect(results).toHaveLength(1);
774
- });
775
- it("should use SPARQL when engine is 'sparql' in ModelQueryBuilder.count()", async () => {
776
- mockPerspective.modelQuery.mockResolvedValue({
777
- instances: [],
778
- totalCount: 3
779
- });
780
- const count = await Recipe.query(mockPerspective)
781
- .where({ rating: { gt: 4 } })
782
- .engine('sparql')
783
- .count();
784
- expect(mockPerspective.modelQuery).toHaveBeenCalledTimes(1);
785
- expect(mockPerspective.infer).not.toHaveBeenCalled();
786
- expect(count).toBe(3);
787
- });
788
- it("should use SPARQL when engine is 'sparql' in ModelQueryBuilder.paginate()", async () => {
789
- mockPerspective.modelQuery.mockResolvedValue({
790
- instances: [
791
- { id: "literal:recipe1", name: "Pasta", rating: 5, ingredients: ["pasta"] }
792
- ],
793
- totalCount: 1
794
- });
795
- const page = await Recipe.query(mockPerspective)
796
- .where({ rating: { gt: 3 } })
797
- .engine('sparql')
798
- .paginate(10, 1);
799
- expect(mockPerspective.modelQuery).toHaveBeenCalledTimes(1);
800
- expect(mockPerspective.infer).not.toHaveBeenCalled();
801
- expect(page.results).toHaveLength(1);
802
- expect(page.pageSize).toBe(10);
803
- expect(page.pageNumber).toBe(1);
804
- });
805
- });
806
- describe("Ad4mModel.count() with advanced where conditions", () => {
807
- // Test Recipe model
808
- let Recipe = class Recipe extends Ad4mModel {
809
- constructor() {
810
- super(...arguments);
811
- this.name = "";
812
- this.rating = 0;
813
- this.ingredients = [];
814
- }
815
- };
816
- __decorate([
817
- Property({ through: "recipe://name" }),
818
- __metadata("design:type", String)
819
- ], Recipe.prototype, "name", void 0);
820
- __decorate([
821
- Property({ through: "recipe://rating" }),
822
- __metadata("design:type", Number)
823
- ], Recipe.prototype, "rating", void 0);
824
- __decorate([
825
- HasMany({ through: "recipe://ingredient" }),
826
- __metadata("design:type", Array)
827
- ], Recipe.prototype, "ingredients", void 0);
828
- Recipe = __decorate([
829
- Model({ name: "Recipe" })
830
- ], Recipe);
831
- // Mock perspective
832
- const mockPerspective = {
833
- querySparql: jest.fn(),
834
- modelQuery: jest.fn(),
835
- infer: jest.fn(),
836
- uuid: 'test-perspective-uuid',
837
- stringOrTemplateObjectToSubjectClassName: jest.fn().mockResolvedValue('Recipe')
838
- };
839
- beforeEach(() => {
840
- jest.clearAllMocks();
841
- });
842
- it("should apply filtering for gt operator on properties in SPARQL count()", async () => {
843
- // With the new modelQuery endpoint, filtering happens server-side in Rust
844
- mockPerspective.modelQuery.mockResolvedValue({
845
- instances: [],
846
- totalCount: 2
847
- });
848
- // Count recipes with rating > 3 (should match 2 recipes: rating 4 and 5)
849
- const count = await Recipe.count(mockPerspective, { where: { rating: { gt: 3 } } });
850
- expect(count).toBe(2);
851
- expect(mockPerspective.modelQuery).toHaveBeenCalled();
852
- });
853
- it("should apply filtering for between operator on properties in SPARQL count()", async () => {
854
- mockPerspective.modelQuery.mockResolvedValue({
855
- instances: [],
856
- totalCount: 3
857
- });
858
- // Count recipes with rating between 2 and 4 (should match 3 recipes: rating 2, 3, 4)
859
- const count = await Recipe.count(mockPerspective, { where: { rating: { between: [2, 4] } } });
860
- expect(count).toBe(3);
861
- expect(mockPerspective.modelQuery).toHaveBeenCalled();
862
- });
863
- it("should apply filtering for timestamp gt operator in SPARQL count()", async () => {
864
- mockPerspective.modelQuery.mockResolvedValue({
865
- instances: [],
866
- totalCount: 2
867
- });
868
- const targetTimestamp = new Date("2023-01-03T00:00:00Z").getTime();
869
- const count = await Recipe.count(mockPerspective, { where: { timestamp: { gt: targetTimestamp } } });
870
- expect(count).toBe(2);
871
- expect(mockPerspective.modelQuery).toHaveBeenCalled();
872
- });
873
- it("should apply filtering for timestamp between operator in SPARQL count()", async () => {
874
- mockPerspective.modelQuery.mockResolvedValue({
875
- instances: [],
876
- totalCount: 3
877
- });
878
- const startTimestamp = new Date("2023-01-02T00:00:00Z").getTime();
879
- const endTimestamp = new Date("2023-01-04T00:00:00Z").getTime();
880
- const count = await Recipe.count(mockPerspective, {
881
- where: { timestamp: { between: [startTimestamp, endTimestamp] } }
882
- });
883
- expect(count).toBe(3);
884
- expect(mockPerspective.modelQuery).toHaveBeenCalled();
885
- });
886
- it("should apply filtering for author filtering in SPARQL count()", async () => {
887
- mockPerspective.modelQuery.mockResolvedValue({
888
- instances: [],
889
- totalCount: 3
890
- });
891
- // Count recipes by Alice (should match 3 recipes)
892
- const count = await Recipe.count(mockPerspective, { where: { author: "did:key:alice" } });
893
- expect(count).toBe(3);
894
- expect(mockPerspective.modelQuery).toHaveBeenCalled();
895
- });
896
- it("should apply filtering in ModelQueryBuilder.count() with gt operator", async () => {
897
- mockPerspective.modelQuery.mockResolvedValue({
898
- instances: [],
899
- totalCount: 2
900
- });
901
- // Count recipes with rating > 3 using ModelQueryBuilder
902
- const count = await Recipe.query(mockPerspective)
903
- .where({ rating: { gt: 3 } })
904
- .engine('sparql')
905
- .count();
906
- expect(count).toBe(2);
907
- expect(mockPerspective.modelQuery).toHaveBeenCalled();
908
- });
909
- it("should apply filtering in ModelQueryBuilder.count() with timestamp between", async () => {
910
- mockPerspective.modelQuery.mockResolvedValue({
911
- instances: [],
912
- totalCount: 3
913
- });
914
- const startTimestamp = new Date("2023-01-02T00:00:00Z").getTime();
915
- const endTimestamp = new Date("2023-01-04T00:00:00Z").getTime();
916
- // Count using ModelQueryBuilder
917
- const count = await Recipe.query(mockPerspective)
918
- .where({ timestamp: { between: [startTimestamp, endTimestamp] } })
919
- .engine('sparql')
920
- .count();
921
- expect(count).toBe(3);
922
- expect(mockPerspective.modelQuery).toHaveBeenCalled();
923
- });
924
- });
925
- describe("SPARQL comparison filters", () => {
926
- let Item = class Item extends Ad4mModel {
927
- };
928
- __decorate([
929
- Property({ through: "item://price", required: true }),
930
- __metadata("design:type", String)
931
- ], Item.prototype, "price", void 0);
932
- __decorate([
933
- Property({ through: "item://name", required: true }),
934
- __metadata("design:type", String)
935
- ], Item.prototype, "name", void 0);
936
- Item = __decorate([
937
- Model({ name: "Item" })
938
- ], Item);
939
- it("should generate gt filter", async () => {
940
- const mockPersp = { getLinks: jest.fn().mockResolvedValue([]) };
941
- const query = await Item.queryToSPARQL(mockPersp, { where: { price: { gt: 10 } } });
942
- // gt is now JS post-filter — SPARQL just joins the property
943
- expect(query).toContain("item://price");
944
- });
945
- it("should generate between filter", async () => {
946
- const mockPersp = { getLinks: jest.fn().mockResolvedValue([]) };
947
- const query = await Item.queryToSPARQL(mockPersp, { where: { price: { between: [5, 20] } } });
948
- // between is now JS post-filter
949
- expect(query).toContain("item://price");
950
- });
951
- it("should generate contains filter", async () => {
952
- const mockPersp = { getLinks: jest.fn().mockResolvedValue([]) };
953
- const query = await Item.queryToSPARQL(mockPersp, { where: { name: { contains: "widget" } } });
954
- // contains is now JS post-filter
955
- expect(query).toContain("item://name");
956
- });
957
- });
958
- // ──────────────────────────────────────────────────────────
959
- // SPARQL Direct Triple Pattern & IRI Tests
960
- // ──────────────────────────────────────────────────────────
961
- import { buildSPARQLQuery, formatSPARQLValue } from "./query-sparql";
962
- describe("SPARQL direct triple pattern generation", () => {
963
- let Channel = class Channel extends Ad4mModel {
964
- constructor() {
965
- super(...arguments);
966
- this.type = "";
967
- this.name = "";
968
- this.description = "";
969
- this.messages = [];
970
- }
971
- };
972
- __decorate([
973
- Flag({ through: "flux://entry_type", value: "flux://channel" }),
974
- __metadata("design:type", String)
975
- ], Channel.prototype, "type", void 0);
976
- __decorate([
977
- Property({ through: "flux://name", resolveLanguage: "literal", required: true }),
978
- __metadata("design:type", String)
979
- ], Channel.prototype, "name", void 0);
980
- __decorate([
981
- Optional({ through: "flux://description" }),
982
- __metadata("design:type", String)
983
- ], Channel.prototype, "description", void 0);
984
- __decorate([
985
- HasMany({ through: "flux://has_message" }),
986
- __metadata("design:type", Array)
987
- ], Channel.prototype, "messages", void 0);
988
- Channel = __decorate([
989
- Model({ name: "Channel" })
990
- ], Channel);
991
- const mockPersp = {};
992
- it("generates direct triple pattern with ?source ?predicate ?target", async () => {
993
- const query = await Channel.queryToSPARQL(mockPersp, {});
994
- // Must use direct triple pattern, not link-node reification
995
- expect(query).toContain("?source ?predicate ?target");
996
- expect(query).not.toContain("rdf:type");
997
- expect(query).not.toContain("ad4m:Link");
998
- });
999
- it("generates Flag filter as ?source <predicate> <value>", async () => {
1000
- const query = await Channel.queryToSPARQL(mockPersp, {});
1001
- expect(query).toContain("<flux://entry_type>");
1002
- expect(query).toContain("<flux://channel>");
1003
- });
1004
- it("generates Property binding as ?source <predicate> ?varName", async () => {
1005
- const query = await Channel.queryToSPARQL(mockPersp, {});
1006
- expect(query).toContain("<flux://name>");
1007
- expect(query).toMatch(/\?source\s+<flux:\/\/name>\s+\?cfTarget_name/);
1008
- });
1009
- it("uses RDF 1.2 reifier pattern for author/timestamp", async () => {
1010
- const query = await Channel.queryToSPARQL(mockPersp, {});
1011
- expect(query).toContain("<http://www.w3.org/1999/02/22-rdf-syntax-ns#reifies>");
1012
- expect(query).toContain("?source ?predicate ?target .");
1013
- expect(query).toContain("?_reifier <http://www.w3.org/1999/02/22-rdf-syntax-ns#reifies> <<( ?source ?predicate ?target )>>");
1014
- expect(query).toContain("?_reifier <ad4m://ontology/author> ?author");
1015
- expect(query).toContain("?_reifier <ad4m://ontology/timestamp> ?timestamp");
1016
- expect(query).not.toContain("GRAPH");
1017
- });
1018
- it("uses FILTER(isIRI(?source)) to exclude non-IRI subjects", async () => {
1019
- const query = await Channel.queryToSPARQL(mockPersp, {});
1020
- expect(query).toContain("FILTER(isIRI(?source)");
1021
- });
1022
- });
1023
- describe("formatSPARQLValue", () => {
1024
- it("wraps strings in double quotes", () => {
1025
- expect(formatSPARQLValue("hello")).toBe('"hello"');
1026
- });
1027
- it("escapes special characters", () => {
1028
- expect(formatSPARQLValue('say "hi"')).toBe('"say \\"hi\\""');
1029
- });
1030
- it("converts numbers to quoted strings", () => {
1031
- expect(formatSPARQLValue(42)).toBe('"42"');
1032
- });
1033
- });
1034
- // ──────────────────────────────────────────────────────────
1035
- // Comprehensive SPARQL migration unit tests
1036
- // ──────────────────────────────────────────────────────────
1037
- import { matchesCondition } from "./hydration";
1038
- import { Literal } from "../Literal";
1039
- // Helper: create literal URLs using JSON encoding (which handles all types including booleans)
1040
- function literalUrl(value) {
1041
- if (typeof value === 'string')
1042
- return Literal.from(value).toUrl();
1043
- // Use JSON encoding for numbers and booleans since Literal.get() doesn't handle boolean: prefix
1044
- return `literal:json:${encodeURIComponent(JSON.stringify(value))}`;
1045
- }
1046
- describe("matchesCondition()", () => {
1047
- // Simple equality
1048
- it("simple string equality — match", () => {
1049
- expect(matchesCondition("hello", "hello")).toBe(true);
1050
- });
1051
- it("simple string equality — mismatch", () => {
1052
- expect(matchesCondition("hello", "world")).toBe(false);
1053
- });
1054
- it("simple boolean equality — true", () => {
1055
- expect(matchesCondition(true, true)).toBe(true);
1056
- });
1057
- it("simple boolean equality — false", () => {
1058
- expect(matchesCondition(false, false)).toBe(true);
1059
- });
1060
- it("boolean mismatch", () => {
1061
- expect(matchesCondition(true, false)).toBe(false);
1062
- });
1063
- it("simple number equality", () => {
1064
- expect(matchesCondition(42, 42)).toBe(true);
1065
- });
1066
- it("number mismatch", () => {
1067
- expect(matchesCondition(42, 99)).toBe(false);
1068
- });
1069
- // Array IN clause
1070
- it("array IN clause — value present", () => {
1071
- expect(matchesCondition("a", ["a", "b", "c"])).toBe(true);
1072
- });
1073
- it("array IN clause — value absent", () => {
1074
- expect(matchesCondition("d", ["a", "b", "c"])).toBe(false);
1075
- });
1076
- // NOT operator
1077
- it("not operator with string", () => {
1078
- expect(matchesCondition("bob", { not: "alice" })).toBe(true);
1079
- expect(matchesCondition("alice", { not: "alice" })).toBe(false);
1080
- });
1081
- it("not operator with array (NOT IN)", () => {
1082
- expect(matchesCondition("a", { not: ["b", "c"] })).toBe(true);
1083
- expect(matchesCondition("b", { not: ["b", "c"] })).toBe(false);
1084
- });
1085
- // Comparison operators
1086
- it("gt", () => {
1087
- expect(matchesCondition(10, { gt: 5 })).toBe(true);
1088
- expect(matchesCondition(5, { gt: 5 })).toBe(false);
1089
- });
1090
- it("gte", () => {
1091
- expect(matchesCondition(5, { gte: 5 })).toBe(true);
1092
- expect(matchesCondition(4, { gte: 5 })).toBe(false);
1093
- });
1094
- it("lt", () => {
1095
- expect(matchesCondition(3, { lt: 5 })).toBe(true);
1096
- expect(matchesCondition(5, { lt: 5 })).toBe(false);
1097
- });
1098
- it("lte", () => {
1099
- expect(matchesCondition(5, { lte: 5 })).toBe(true);
1100
- expect(matchesCondition(6, { lte: 5 })).toBe(false);
1101
- });
1102
- it("combined gt + lt (range)", () => {
1103
- expect(matchesCondition(5, { gt: 3, lt: 7 })).toBe(true);
1104
- expect(matchesCondition(3, { gt: 3, lt: 7 })).toBe(false);
1105
- expect(matchesCondition(7, { gt: 3, lt: 7 })).toBe(false);
1106
- });
1107
- // Between
1108
- it("between — inclusive range", () => {
1109
- expect(matchesCondition(5, { between: [3, 7] })).toBe(true);
1110
- expect(matchesCondition(3, { between: [3, 7] })).toBe(true);
1111
- expect(matchesCondition(7, { between: [3, 7] })).toBe(true);
1112
- expect(matchesCondition(2, { between: [3, 7] })).toBe(false);
1113
- expect(matchesCondition(8, { between: [3, 7] })).toBe(false);
1114
- });
1115
- // Contains
1116
- it("contains with string", () => {
1117
- expect(matchesCondition("hello world", { contains: "world" })).toBe(true);
1118
- expect(matchesCondition("hello world", { contains: "xyz" })).toBe(false);
1119
- });
1120
- it("contains with array", () => {
1121
- expect(matchesCondition(["a", "b", "c"], { contains: "b" })).toBe(true);
1122
- expect(matchesCondition(["a", "b", "c"], { contains: "d" })).toBe(false);
1123
- });
1124
- // Edge cases
1125
- it("returns false for undefined value with equality check", () => {
1126
- expect(matchesCondition(undefined, "hello")).toBe(false);
1127
- });
1128
- it("returns false for empty string when condition is non-empty", () => {
1129
- expect(matchesCondition("", "Recipe 2")).toBe(false);
1130
- });
1131
- it("returns true for undefined with not operator", () => {
1132
- expect(matchesCondition(undefined, { not: "hello" })).toBe(true);
1133
- });
1134
- });
1135
- describe("buildSPARQLQuery edge cases", () => {
1136
- let FlagModel = class FlagModel extends Ad4mModel {
1137
- constructor() {
1138
- super(...arguments);
1139
- this.type = "";
1140
- this.name = "";
1141
- }
1142
- };
1143
- __decorate([
1144
- Flag({ through: "flag://type", value: "flag://FlagModel" }),
1145
- __metadata("design:type", String)
1146
- ], FlagModel.prototype, "type", void 0);
1147
- __decorate([
1148
- Property({ through: "flag://name", resolveLanguage: "literal", required: true }),
1149
- __metadata("design:type", String)
1150
- ], FlagModel.prototype, "name", void 0);
1151
- FlagModel = __decorate([
1152
- Model({ name: "FlagModel" })
1153
- ], FlagModel);
1154
- let NoFlagModel = class NoFlagModel extends Ad4mModel {
1155
- constructor() {
1156
- super(...arguments);
1157
- this.title = "";
1158
- }
1159
- };
1160
- __decorate([
1161
- Property({ through: "noflag://title", resolveLanguage: "literal" }),
1162
- __metadata("design:type", String)
1163
- ], NoFlagModel.prototype, "title", void 0);
1164
- NoFlagModel = __decorate([
1165
- Model({ name: "NoFlagModel" })
1166
- ], NoFlagModel);
1167
- it("adds conformance JOIN for flag + required properties", () => {
1168
- const metadata = FlagModel.getModelMetadata();
1169
- const allRelsMeta = {};
1170
- const sparql = buildSPARQLQuery(metadata, allRelsMeta, {}, FlagModel);
1171
- // Should contain flag triple pattern
1172
- expect(sparql).toContain("<flag://type>");
1173
- expect(sparql).toContain("<flag://FlagModel>");
1174
- // Should contain required property pattern
1175
- expect(sparql).toContain("<flag://name>");
1176
- });
1177
- it("uses structural subquery when no conformance patterns exist", () => {
1178
- const metadata = NoFlagModel.getModelMetadata();
1179
- const allRelsMeta = {};
1180
- const sparql = buildSPARQLQuery(metadata, allRelsMeta, {}, NoFlagModel);
1181
- // Should contain structural subquery with DISTINCT
1182
- expect(sparql).toContain("SELECT DISTINCT ?source");
1183
- expect(sparql).toContain("<noflag://title>");
1184
- });
1185
- it("adds JOIN for where-clause on literal-stored fields", () => {
1186
- const metadata = FlagModel.getModelMetadata();
1187
- const allRelsMeta = {};
1188
- const sparql = buildSPARQLQuery(metadata, allRelsMeta, { where: { name: "test" } }, FlagModel);
1189
- // Where clause should add a join pattern for name
1190
- expect(sparql).toContain("flag://name");
1191
- });
1192
- it("handles where: {id: 'specific-id'} with FILTER on ?source", () => {
1193
- const metadata = FlagModel.getModelMetadata();
1194
- const allRelsMeta = {};
1195
- const sparql = buildSPARQLQuery(metadata, allRelsMeta, { where: { id: "expr:123" } }, FlagModel);
1196
- // Should filter by source
1197
- expect(sparql).toContain("expr:123");
1198
- });
1199
- });
1200
- // ── Batch hydration for reverse relations (3.4) ─────────────────────────────
1201
- describe("Batch hydration for reverse relations", () => {
1202
- it("batch hydration should correctly group targets by parent instance ID", () => {
1203
- // Test the grouping logic used in batch SPARQL hydration
1204
- const sparqlResults = [
1205
- { target: "inst:1", source: "child:a" },
1206
- { target: "inst:1", source: "child:b" },
1207
- { target: "inst:2", source: "child:c" },
1208
- { target: "inst:3", source: "child:d" },
1209
- { target: "inst:3", source: "child:e" },
1210
- { target: "inst:3", source: "child:f" },
1211
- ];
1212
- const reverseLinksMap = new Map();
1213
- for (const row of sparqlResults) {
1214
- if (!reverseLinksMap.has(row.target))
1215
- reverseLinksMap.set(row.target, []);
1216
- reverseLinksMap.get(row.target).push(row.source);
1217
- }
1218
- expect(reverseLinksMap.get("inst:1")).toEqual(["child:a", "child:b"]);
1219
- expect(reverseLinksMap.get("inst:2")).toEqual(["child:c"]);
1220
- expect(reverseLinksMap.get("inst:3")).toEqual(["child:d", "child:e", "child:f"]);
1221
- });
1222
- it("batch hydration should handle empty relation sets without error", () => {
1223
- const sparqlResults = [];
1224
- const reverseLinksMap = new Map();
1225
- for (const row of sparqlResults) {
1226
- if (!reverseLinksMap.has(row.target))
1227
- reverseLinksMap.set(row.target, []);
1228
- reverseLinksMap.get(row.target).push(row.source);
1229
- }
1230
- expect(reverseLinksMap.size).toBe(0);
1231
- expect(reverseLinksMap.get("nonexistent") || []).toEqual([]);
1232
- });
1233
- it("batch hydration should return identical results to N+1 hydration (grouping equivalence)", () => {
1234
- // Simulate N+1: each instance queries separately
1235
- const instances = [{ id: "inst:1" }, { id: "inst:2" }];
1236
- const allLinks = [
1237
- { data: { source: "child:a", predicate: "rel://has", target: "inst:1" } },
1238
- { data: { source: "child:b", predicate: "rel://has", target: "inst:1" } },
1239
- { data: { source: "child:c", predicate: "rel://has", target: "inst:2" } },
1240
- ];
1241
- // N+1 approach
1242
- const n1Results = new Map();
1243
- for (const inst of instances) {
1244
- const links = allLinks.filter(l => l.data.target === inst.id);
1245
- n1Results.set(inst.id, links.map(l => l.data.source));
1246
- }
1247
- // Batch approach
1248
- const batchResults = new Map();
1249
- const sparqlRows = allLinks.map(l => ({ target: l.data.target, source: l.data.source }));
1250
- for (const row of sparqlRows) {
1251
- if (!batchResults.has(row.target))
1252
- batchResults.set(row.target, []);
1253
- batchResults.get(row.target).push(row.source);
1254
- }
1255
- // Results should be identical
1256
- for (const inst of instances) {
1257
- expect(batchResults.get(inst.id)).toEqual(n1Results.get(inst.id));
1258
- }
1259
- });
1260
- it("batch hydration with nested includes should use batched queries at each level", () => {
1261
- // This test verifies the structure: nested includes result in multiple
1262
- // batch operations, one per relation depth level
1263
- const depth0Rows = [
1264
- { target: "root:1", source: "mid:a" },
1265
- { target: "root:1", source: "mid:b" },
1266
- ];
1267
- const depth1Rows = [
1268
- { target: "mid:a", source: "leaf:x" },
1269
- { target: "mid:b", source: "leaf:y" },
1270
- ];
1271
- // Group each level
1272
- const level0Map = new Map();
1273
- for (const r of depth0Rows) {
1274
- if (!level0Map.has(r.target))
1275
- level0Map.set(r.target, []);
1276
- level0Map.get(r.target).push(r.source);
1277
- }
1278
- const level1Map = new Map();
1279
- for (const r of depth1Rows) {
1280
- if (!level1Map.has(r.target))
1281
- level1Map.set(r.target, []);
1282
- level1Map.get(r.target).push(r.source);
1283
- }
1284
- expect(level0Map.get("root:1")).toEqual(["mid:a", "mid:b"]);
1285
- expect(level1Map.get("mid:a")).toEqual(["leaf:x"]);
1286
- expect(level1Map.get("mid:b")).toEqual(["leaf:y"]);
1287
- });
1288
- });
1289
- // ── Push-down FILTER for literal equality (3.5) ──────────────────────────────
1290
- describe("Push-down FILTER for literal equality", () => {
1291
- const mockPerspective = {};
1292
- let FilterTest = class FilterTest extends Ad4mModel {
1293
- constructor() {
1294
- super(...arguments);
1295
- this.name = "";
1296
- this.rating = 0;
1297
- }
1298
- };
1299
- __decorate([
1300
- Property({ through: "ft://name", required: true }),
1301
- __metadata("design:type", String)
1302
- ], FilterTest.prototype, "name", void 0);
1303
- __decorate([
1304
- Property({ through: "ft://rating", required: true }),
1305
- __metadata("design:type", Number)
1306
- ], FilterTest.prototype, "rating", void 0);
1307
- FilterTest = __decorate([
1308
- Model({ name: "FilterTest" })
1309
- ], FilterTest);
1310
- const normalizeQuery = (q) => q.replace(/\s+/g, " ").trim();
1311
- it("SPARQL query for where: { name: 'Alice' } should use <ad4m://fn/parse_literal> FILTER", async () => {
1312
- const query = await FilterTest.queryToSPARQL(mockPerspective, { where: { name: "Alice" } });
1313
- const norm = normalizeQuery(query);
1314
- // JOIN pattern exists
1315
- expect(norm).toContain("?wTarget_name");
1316
- // parse_literal push-down FILTER is present (using correct SPARQL IRI syntax)
1317
- expect(norm).toContain("ad4m://fn/parse_literal");
1318
- expect(norm).not.toContain("fn::parse_literal");
1319
- });
1320
- it("SPARQL query for where: { name: ['Alice', 'Bob'] } should use <ad4m://fn/parse_literal> IN FILTER", async () => {
1321
- const query = await FilterTest.queryToSPARQL(mockPerspective, { where: { name: ["Alice", "Bob"] } });
1322
- const norm = normalizeQuery(query);
1323
- expect(norm).toContain("?wTarget_name");
1324
- expect(norm).toContain("ad4m://fn/parse_literal");
1325
- expect(norm).not.toContain("fn::parse_literal");
1326
- });
1327
- it("SPARQL query for where: { rating: { gt: 5 } } should NOT include parse_literal FILTER", async () => {
1328
- const query = await FilterTest.queryToSPARQL(mockPerspective, { where: { rating: { gt: 5 } } });
1329
- const norm = normalizeQuery(query);
1330
- expect(norm).not.toContain("parse_literal");
1331
- });
1332
- it("literal property where clause adds JOIN for JS post-filter", async () => {
1333
- const query = await FilterTest.queryToSPARQL(mockPerspective, { where: { name: "Alice" } });
1334
- const norm = normalizeQuery(query);
1335
- expect(norm).toContain("?wTarget_name");
1336
- });
1337
- });
1338
- // ── Lightweight fingerprint (3.7) ────────────────────────────────────────────
1339
- describe("Lightweight fingerprint optimization", () => {
1340
- // Replicate the buildFingerprint logic for testing
1341
- const buildFingerprint = (results) => {
1342
- if (results.length === 0)
1343
- return '0:';
1344
- const ids = results.map((r) => r.id || '').sort().join(',');
1345
- const ts = results.map((r) => r.updatedAt || r.timestamp || '').join(',');
1346
- return `${results.length}:${ids}:${ts}`;
1347
- };
1348
- const base = [
1349
- { id: "a", updatedAt: "100" },
1350
- { id: "b", updatedAt: "200" },
1351
- ];
1352
- it("lightweight fingerprint should detect instance addition", () => {
1353
- const fp1 = buildFingerprint(base);
1354
- const fp2 = buildFingerprint([...base, { id: "c", updatedAt: "300" }]);
1355
- expect(fp1).not.toBe(fp2);
1356
- });
1357
- it("lightweight fingerprint should detect instance removal", () => {
1358
- const fp1 = buildFingerprint(base);
1359
- const fp2 = buildFingerprint([base[0]]);
1360
- expect(fp1).not.toBe(fp2);
1361
- });
1362
- it("lightweight fingerprint should detect timestamp change", () => {
1363
- const fp1 = buildFingerprint(base);
1364
- const fp2 = buildFingerprint([{ id: "a", updatedAt: "999" }, base[1]]);
1365
- expect(fp1).not.toBe(fp2);
1366
- });
1367
- it("lightweight fingerprint should NOT false-positive for identical sets", () => {
1368
- const fp1 = buildFingerprint(base);
1369
- const fp2 = buildFingerprint([...base]); // same data, new array
1370
- expect(fp1).toBe(fp2);
1371
- });
1372
- });
1373
- // ── Native SPARQL getter evaluation ──────────────────────────────────────────
1374
- describe("Native SPARQL getter evaluation", () => {
1375
- const { evaluateCustomGettersForInstance } = require("./hydration");
1376
- const mockPerspective = {
1377
- getLinks: jest.fn().mockResolvedValue([]),
1378
- querySparql: jest.fn(),
1379
- get: jest.fn().mockResolvedValue([]),
1380
- };
1381
- beforeEach(() => {
1382
- jest.clearAllMocks();
1383
- });
1384
- it("should execute SELECT getter directly via querySparql", async () => {
1385
- const metadata = {
1386
- properties: {
1387
- replyingTo: {
1388
- predicate: "flux://has_reply",
1389
- getter: 'SELECT ?target WHERE { ?target <flux://has_reply> ?source . } LIMIT 1',
1390
- type: "string",
1391
- }
1392
- },
1393
- relations: {},
1394
- };
1395
- mockPerspective.querySparql.mockResolvedValue([
1396
- { target: { value: "literal:string:msg123" } }
1397
- ]);
1398
- const instance = { id: "test://msg1", replyingTo: undefined };
1399
- await evaluateCustomGettersForInstance(instance, mockPerspective, metadata);
1400
- expect(mockPerspective.querySparql).toHaveBeenCalledWith(expect.stringContaining("SELECT ?target WHERE"));
1401
- expect(instance.replyingTo).toBe("literal:string:msg123");
1402
- });
1403
- it("should execute ASK getter and return boolean", async () => {
1404
- const metadata = {
1405
- properties: {
1406
- isPopular: {
1407
- predicate: "flux://is_popular",
1408
- getter: 'ASK WHERE { SELECT (COUNT(DISTINCT ?reactor) AS ?count) WHERE { ?reactor <flux://reaction> ?source . } HAVING(?count > 5) }',
1409
- type: "boolean",
1410
- readOnly: true,
1411
- }
1412
- },
1413
- relations: {},
1414
- };
1415
- mockPerspective.querySparql.mockResolvedValue(true);
1416
- const instance = { id: "test://msg1", isPopular: false };
1417
- await evaluateCustomGettersForInstance(instance, mockPerspective, metadata);
1418
- expect(mockPerspective.querySparql).toHaveBeenCalledWith(expect.stringContaining("ASK WHERE"));
1419
- expect(instance.isPopular).toBe(true);
1420
- });
1421
- it("should replace ?source with instance ID in SPARQL getter", async () => {
1422
- const metadata = {
1423
- properties: {
1424
- author: {
1425
- predicate: "test://author",
1426
- getter: 'SELECT ?target WHERE { ?source <test://author> ?target . }',
1427
- type: "string",
1428
- }
1429
- },
1430
- relations: {},
1431
- };
1432
- mockPerspective.querySparql.mockResolvedValue([
1433
- { target: { value: "did:key:abc123" } }
1434
- ]);
1435
- const instance = { id: "test://post1", author: undefined };
1436
- await evaluateCustomGettersForInstance(instance, mockPerspective, metadata);
1437
- expect(mockPerspective.querySparql).toHaveBeenCalledWith(expect.stringContaining("<test://post1>"));
1438
- expect(mockPerspective.querySparql).not.toHaveBeenCalledWith(expect.stringContaining("?source"));
1439
- });
1440
- it("should handle empty SPARQL results gracefully", async () => {
1441
- const metadata = {
1442
- properties: {
1443
- replyingTo: {
1444
- predicate: "flux://has_reply",
1445
- getter: 'SELECT ?target WHERE { ?target <flux://has_reply> ?source . } LIMIT 1',
1446
- type: "string",
1447
- }
1448
- },
1449
- relations: {},
1450
- };
1451
- mockPerspective.querySparql.mockResolvedValue([]);
1452
- const instance = { id: "test://msg1", replyingTo: "original" };
1453
- await evaluateCustomGettersForInstance(instance, mockPerspective, metadata);
1454
- // Should not overwrite with undefined
1455
- expect(instance.replyingTo).toBe("original");
1456
- });
1457
- it("should handle SPARQL getter errors without crashing", async () => {
1458
- const metadata = {
1459
- properties: {
1460
- broken: {
1461
- predicate: "test://broken",
1462
- getter: 'SELECT ?target WHERE { INVALID SPARQL }',
1463
- type: "string",
1464
- }
1465
- },
1466
- relations: {},
1467
- };
1468
- mockPerspective.querySparql.mockRejectedValue(new Error("SPARQL parse error"));
1469
- const instance = { id: "test://msg1", broken: undefined };
1470
- const consoleSpy = jest.spyOn(console, "warn").mockImplementation();
1471
- await evaluateCustomGettersForInstance(instance, mockPerspective, metadata);
1472
- consoleSpy.mockRestore();
1473
- // Should not throw, should warn
1474
- expect(instance.broken).toBeUndefined();
1475
- });
1476
- it("should execute SPARQL getter for relations", async () => {
1477
- const metadata = {
1478
- properties: {},
1479
- relations: {
1480
- tags: {
1481
- predicate: "test://has_tag",
1482
- getter: 'SELECT ?target WHERE { ?source <test://has_tag> ?target . }',
1483
- direction: "forward",
1484
- }
1485
- },
1486
- };
1487
- mockPerspective.querySparql.mockResolvedValue([
1488
- { target: { value: "tag:a" } },
1489
- { target: { value: "tag:b" } },
1490
- ]);
1491
- const instance = { id: "test://post1", tags: [] };
1492
- await evaluateCustomGettersForInstance(instance, mockPerspective, metadata);
1493
- expect(instance.tags).toEqual(["tag:a", "tag:b"]);
1494
- });
1495
- it("should warn for legacy SurrealDB-style getter syntax instead of converting", async () => {
1496
- const metadata = {
1497
- properties: {
1498
- legacy: {
1499
- predicate: "test://legacy",
1500
- getter: "(<-link[WHERE predicate = 'test://legacy'].in.uri)[0]",
1501
- type: "string",
1502
- }
1503
- },
1504
- relations: {},
1505
- };
1506
- const warnSpy = jest.spyOn(console, 'warn').mockImplementation(() => { });
1507
- const instance = { id: "test://msg1", legacy: undefined };
1508
- await evaluateCustomGettersForInstance(instance, mockPerspective, metadata);
1509
- // Should NOT call querySparql — legacy getters are no longer converted
1510
- expect(mockPerspective.querySparql).not.toHaveBeenCalled();
1511
- // Should warn about unsupported syntax
1512
- expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining("Unsupported legacy getter syntax"));
1513
- // Value should remain undefined
1514
- expect(instance.legacy).toBeUndefined();
1515
- warnSpy.mockRestore();
1516
- });
1517
- });
1518
- // ── Subscribe callback timing ──────────────────────────────────────────
1519
- describe("ModelQueryBuilder subscribe callback timing", () => {
1520
- it("subscribe should not invoke callback synchronously before Promise resolves", async () => {
1521
- // This test verifies that subscribe() uses the Rust model subscription endpoint
1522
- // and properly handles the subscription lifecycle.
1523
- const mockSubscriptionId = "test-sub-123";
1524
- let updateCallback = null;
1525
- const mockClient = {
1526
- modelSubscribe: jest.fn().mockResolvedValue({
1527
- subscriptionId: mockSubscriptionId,
1528
- result: { instances: [], totalCount: 0 },
1529
- }),
1530
- subscribeToQueryUpdates: jest.fn().mockImplementation((_id, cb) => {
1531
- updateCallback = cb;
1532
- return () => { }; // unsubscribe function
1533
- }),
1534
- keepAliveQuery: jest.fn().mockResolvedValue(true),
1535
- disposeQuerySubscription: jest.fn().mockResolvedValue(true),
1536
- };
1537
- const mockPerspective = {
1538
- uuid: "test-uuid",
1539
- client: mockClient,
1540
- modelSubscribe: jest.fn().mockImplementation(async (className, queryJson, shapeJson) => {
1541
- return mockClient.modelSubscribe("test-uuid", className, queryJson, shapeJson);
1542
- }),
1543
- getLinks: jest.fn().mockResolvedValue([]),
1544
- modelQuery: jest.fn().mockResolvedValue({ instances: [], totalCount: 0 }),
1545
- };
1546
- const { Ad4mModel, Model, Property, Flag } = require("./index");
1547
- let TimingTest = class TimingTest extends Ad4mModel {
1548
- constructor() {
1549
- super(...arguments);
1550
- this.type = "test://timing";
1551
- this.name = "";
1552
- }
1553
- };
1554
- __decorate([
1555
- Flag({ through: "test://type", value: "test://timing" }),
1556
- __metadata("design:type", String)
1557
- ], TimingTest.prototype, "type", void 0);
1558
- __decorate([
1559
- Property({ through: "test://name" }),
1560
- __metadata("design:type", String)
1561
- ], TimingTest.prototype, "name", void 0);
1562
- TimingTest = __decorate([
1563
- Model({ name: "TimingTest" })
1564
- ], TimingTest);
1565
- let callbackInvokedBeforeResolve = false;
1566
- let promiseResolved = false;
1567
- const query = TimingTest.query(mockPerspective);
1568
- const promise = query.subscribe((results) => {
1569
- if (!promiseResolved) {
1570
- callbackInvokedBeforeResolve = true;
1571
- }
1572
- });
1573
- // At this point the Promise hasn't resolved yet
1574
- // The callback should NOT have fired synchronously
1575
- expect(callbackInvokedBeforeResolve).toBe(false);
1576
- const initialResults = await promise;
1577
- promiseResolved = true;
1578
- expect(initialResults).toEqual([]);
1579
- expect(mockPerspective.modelSubscribe).toHaveBeenCalled();
1580
- });
1581
- });
1582
- describe("ModelQueryBuilder paginateSubscribe", () => {
1583
- it("paginateSubscribe should use a single query with count: true", async () => {
1584
- const mockSubscriptionId = "paginate-sub-123";
1585
- const mockClient = {
1586
- modelSubscribe: jest.fn().mockResolvedValue({
1587
- subscriptionId: mockSubscriptionId,
1588
- result: { instances: [], totalCount: 0 },
1589
- }),
1590
- subscribeToQueryUpdates: jest.fn().mockImplementation((_id, _cb) => {
1591
- return () => { };
1592
- }),
1593
- keepAliveQuery: jest.fn().mockResolvedValue(true),
1594
- disposeQuerySubscription: jest.fn().mockResolvedValue(true),
1595
- };
1596
- const mockPerspective = {
1597
- uuid: "test-uuid",
1598
- client: mockClient,
1599
- modelSubscribe: jest.fn().mockImplementation(async (className, queryJson, shapeJson) => {
1600
- return mockClient.modelSubscribe("test-uuid", className, queryJson, shapeJson);
1601
- }),
1602
- modelQuery: jest.fn().mockResolvedValue({ instances: [{ id: "item1", type: "test://paginate" }], totalCount: 42 }),
1603
- };
1604
- const { Ad4mModel, Model, Flag, Property } = require("./index");
1605
- let PaginateTest = class PaginateTest extends Ad4mModel {
1606
- constructor() {
1607
- super(...arguments);
1608
- this.type = "test://paginate";
1609
- this.name = "";
1610
- }
1611
- };
1612
- __decorate([
1613
- Flag({ through: "test://type", value: "test://paginate" }),
1614
- __metadata("design:type", String)
1615
- ], PaginateTest.prototype, "type", void 0);
1616
- __decorate([
1617
- Property({ through: "test://name" }),
1618
- __metadata("design:type", String)
1619
- ], PaginateTest.prototype, "name", void 0);
1620
- PaginateTest = __decorate([
1621
- Model({ name: "PaginateTest" })
1622
- ], PaginateTest);
1623
- const builder = PaginateTest.query(mockPerspective);
1624
- const result = await builder.paginateSubscribe(10, 1, () => { });
1625
- // Should return paginated result structure
1626
- expect(result).toHaveProperty("results");
1627
- expect(result).toHaveProperty("totalCount");
1628
- expect(result).toHaveProperty("pageSize", 10);
1629
- expect(result).toHaveProperty("pageNumber", 1);
1630
- // modelQuery should be called exactly once (not twice — no separate count query)
1631
- expect(mockPerspective.modelQuery).toHaveBeenCalledTimes(1);
1632
- // The query should have count: true
1633
- const callArgs = mockPerspective.modelQuery.mock.calls[0];
1634
- const queryJson = JSON.parse(callArgs[1]);
1635
- expect(queryJson.count).toBe(true);
1636
- expect(queryJson.limit).toBe(10);
1637
- expect(queryJson.offset).toBe(0);
1638
- });
1639
- it("paginateSubscribe should skip isInit messages from subscription", async () => {
1640
- const mockSubscriptionId = "paginate-init-sub";
1641
- let capturedCallback = null;
1642
- const mockClient = {
1643
- modelSubscribe: jest.fn().mockResolvedValue({
1644
- subscriptionId: mockSubscriptionId,
1645
- result: { instances: [], totalCount: 0 },
1646
- }),
1647
- subscribeToQueryUpdates: jest.fn().mockImplementation((_id, cb) => {
1648
- capturedCallback = cb;
1649
- return () => { };
1650
- }),
1651
- keepAliveQuery: jest.fn().mockResolvedValue(true),
1652
- disposeQuerySubscription: jest.fn().mockResolvedValue(true),
1653
- };
1654
- let modelQueryCallCount = 0;
1655
- const mockPerspective = {
1656
- uuid: "test-uuid",
1657
- client: mockClient,
1658
- modelSubscribe: jest.fn().mockImplementation(async (className, queryJson, shapeJson) => {
1659
- return mockClient.modelSubscribe("test-uuid", className, queryJson, shapeJson);
1660
- }),
1661
- modelQuery: jest.fn().mockImplementation(async () => {
1662
- modelQueryCallCount++;
1663
- return { instances: [], totalCount: 0 };
1664
- }),
1665
- };
1666
- const { Ad4mModel, Model, Flag, Property } = require("./index");
1667
- let InitGuardTest = class InitGuardTest extends Ad4mModel {
1668
- constructor() {
1669
- super(...arguments);
1670
- this.type = "test://init";
1671
- this.name = "";
1672
- }
1673
- };
1674
- __decorate([
1675
- Flag({ through: "test://type", value: "test://init" }),
1676
- __metadata("design:type", String)
1677
- ], InitGuardTest.prototype, "type", void 0);
1678
- __decorate([
1679
- Property({ through: "test://name" }),
1680
- __metadata("design:type", String)
1681
- ], InitGuardTest.prototype, "name", void 0);
1682
- InitGuardTest = __decorate([
1683
- Model({ name: "InitGuardTest" })
1684
- ], InitGuardTest);
1685
- const userCallback = jest.fn();
1686
- const builder = InitGuardTest.query(mockPerspective);
1687
- await builder.paginateSubscribe(10, 1, userCallback);
1688
- // Reset the count after initial fetch
1689
- const initialCallCount = modelQueryCallCount;
1690
- // Simulate an isInit message from subscription
1691
- expect(capturedCallback).not.toBeNull();
1692
- capturedCallback({ isInit: true });
1693
- // Wait for any async processing
1694
- await new Promise(r => setTimeout(r, 50));
1695
- // modelQuery should NOT have been called again (isInit was filtered)
1696
- expect(modelQueryCallCount).toBe(initialCallCount);
1697
- // User callback should NOT have been invoked by isInit
1698
- expect(userCallback).not.toHaveBeenCalled();
1699
- });
1700
- it("paginateSubscribe should re-fetch on real subscription updates", async () => {
1701
- const mockSubscriptionId = "paginate-update-sub";
1702
- let capturedCallback = null;
1703
- const mockClient = {
1704
- modelSubscribe: jest.fn().mockResolvedValue({
1705
- subscriptionId: mockSubscriptionId,
1706
- result: { instances: [], totalCount: 0 },
1707
- }),
1708
- subscribeToQueryUpdates: jest.fn().mockImplementation((_id, cb) => {
1709
- capturedCallback = cb;
1710
- return () => { };
1711
- }),
1712
- keepAliveQuery: jest.fn().mockResolvedValue(true),
1713
- disposeQuerySubscription: jest.fn().mockResolvedValue(true),
1714
- };
1715
- let modelQueryCallCount = 0;
1716
- const mockPerspective = {
1717
- uuid: "test-uuid",
1718
- client: mockClient,
1719
- modelSubscribe: jest.fn().mockImplementation(async (className, queryJson, shapeJson) => {
1720
- return mockClient.modelSubscribe("test-uuid", className, queryJson, shapeJson);
1721
- }),
1722
- modelQuery: jest.fn().mockImplementation(async () => {
1723
- modelQueryCallCount++;
1724
- return { instances: [{ id: "new-item", type: "test://update" }], totalCount: 1 };
1725
- }),
1726
- };
1727
- const { Ad4mModel, Model, Flag, Property } = require("./index");
1728
- let UpdateTest = class UpdateTest extends Ad4mModel {
1729
- constructor() {
1730
- super(...arguments);
1731
- this.type = "test://update";
1732
- this.name = "";
1733
- }
1734
- };
1735
- __decorate([
1736
- Flag({ through: "test://type", value: "test://update" }),
1737
- __metadata("design:type", String)
1738
- ], UpdateTest.prototype, "type", void 0);
1739
- __decorate([
1740
- Property({ through: "test://name" }),
1741
- __metadata("design:type", String)
1742
- ], UpdateTest.prototype, "name", void 0);
1743
- UpdateTest = __decorate([
1744
- Model({ name: "UpdateTest" })
1745
- ], UpdateTest);
1746
- const userCallback = jest.fn();
1747
- const builder = UpdateTest.query(mockPerspective);
1748
- await builder.paginateSubscribe(10, 1, userCallback);
1749
- const initialCallCount = modelQueryCallCount;
1750
- // Simulate a real subscription update (not isInit)
1751
- capturedCallback({ instances: [{ id: "new-item" }], totalCount: 1 });
1752
- // Wait for async processing
1753
- await new Promise(r => setTimeout(r, 100));
1754
- // modelQuery should have been called again for the re-fetch
1755
- expect(modelQueryCallCount).toBeGreaterThan(initialCallCount);
1756
- // User callback should have been invoked with paginated results
1757
- expect(userCallback).toHaveBeenCalled();
1758
- const callArg = userCallback.mock.calls[0][0];
1759
- expect(callArg).toHaveProperty("totalCount");
1760
- expect(callArg).toHaveProperty("pageSize", 10);
1761
- expect(callArg).toHaveProperty("pageNumber", 1);
1762
- });
1763
- });
1764
- // ============================================================================
1765
- // Performance Optimisation Tests
1766
- // ============================================================================
1767
- import { getCachedResult, setCachedResult, clearQueryCache, queryCacheSize } from "./query-cache";
1768
- import { getPropertiesMetadata, getRelationsMetadata } from "./decorators";
1769
- describe("QueryCache", () => {
1770
- beforeEach(() => clearQueryCache());
1771
- it("should return undefined for cache miss", () => {
1772
- expect(getCachedResult("uuid1", "SELECT ?s WHERE {}")).toBeUndefined();
1773
- });
1774
- it("should return cached result within TTL", () => {
1775
- const result = [{ s: "test" }];
1776
- setCachedResult("uuid1", "SELECT ?s WHERE {}", result);
1777
- expect(getCachedResult("uuid1", "SELECT ?s WHERE {}")).toBe(result);
1778
- });
1779
- it("should expire after TTL", async () => {
1780
- setCachedResult("uuid1", "SELECT ?s WHERE {}", [{ s: "test" }], 50);
1781
- await new Promise(r => setTimeout(r, 60));
1782
- expect(getCachedResult("uuid1", "SELECT ?s WHERE {}")).toBeUndefined();
1783
- });
1784
- it("should cache independently per perspective", () => {
1785
- setCachedResult("uuid1", "SELECT ?s WHERE {}", "result1");
1786
- setCachedResult("uuid2", "SELECT ?s WHERE {}", "result2");
1787
- expect(getCachedResult("uuid1", "SELECT ?s WHERE {}")).toBe("result1");
1788
- expect(getCachedResult("uuid2", "SELECT ?s WHERE {}")).toBe("result2");
1789
- });
1790
- it("should cache independently per query", () => {
1791
- setCachedResult("uuid1", "query1", "r1");
1792
- setCachedResult("uuid1", "query2", "r2");
1793
- expect(getCachedResult("uuid1", "query1")).toBe("r1");
1794
- expect(getCachedResult("uuid1", "query2")).toBe("r2");
1795
- });
1796
- it("should clear all entries", () => {
1797
- setCachedResult("uuid1", "q1", "r1");
1798
- setCachedResult("uuid2", "q2", "r2");
1799
- expect(queryCacheSize()).toBe(2);
1800
- clearQueryCache();
1801
- expect(queryCacheSize()).toBe(0);
1802
- });
1803
- });
1804
- describe("SHACL Memoisation", () => {
1805
- it("should memoise generateSHACL() per class", () => {
1806
- let MemoTest1 = class MemoTest1 extends Ad4mModel {
1807
- constructor() {
1808
- super(...arguments);
1809
- this.name = "";
1810
- }
1811
- };
1812
- __decorate([
1813
- Property({ through: "test://name" }),
1814
- __metadata("design:type", String)
1815
- ], MemoTest1.prototype, "name", void 0);
1816
- MemoTest1 = __decorate([
1817
- Model({ name: "MemoTest1" })
1818
- ], MemoTest1);
1819
- const result1 = MemoTest1.generateSHACL();
1820
- const result2 = MemoTest1.generateSHACL();
1821
- expect(result1).toBe(result2); // Same reference = memoised
1822
- });
1823
- it("should memoise getPropertiesMetadata per class", () => {
1824
- let PropMemoTest = class PropMemoTest extends Ad4mModel {
1825
- constructor() {
1826
- super(...arguments);
1827
- this.x = "";
1828
- }
1829
- };
1830
- __decorate([
1831
- Property({ through: "test://x" }),
1832
- __metadata("design:type", String)
1833
- ], PropMemoTest.prototype, "x", void 0);
1834
- PropMemoTest = __decorate([
1835
- Model({ name: "PropMemoTest" })
1836
- ], PropMemoTest);
1837
- const r1 = getPropertiesMetadata(PropMemoTest);
1838
- const r2 = getPropertiesMetadata(PropMemoTest);
1839
- expect(r1).toBe(r2); // Same reference
1840
- });
1841
- it("should memoise getRelationsMetadata per class", () => {
1842
- let RelMemoTest = class RelMemoTest extends Ad4mModel {
1843
- constructor() {
1844
- super(...arguments);
1845
- this.items = [];
1846
- }
1847
- };
1848
- __decorate([
1849
- HasMany({ through: "test://items" }),
1850
- __metadata("design:type", Array)
1851
- ], RelMemoTest.prototype, "items", void 0);
1852
- RelMemoTest = __decorate([
1853
- Model({ name: "RelMemoTest" })
1854
- ], RelMemoTest);
1855
- const r1 = getRelationsMetadata(RelMemoTest);
1856
- const r2 = getRelationsMetadata(RelMemoTest);
1857
- expect(r1).toBe(r2); // Same reference
1858
- });
1859
- it("should return different results for different classes", () => {
1860
- let ClassA = class ClassA extends Ad4mModel {
1861
- constructor() {
1862
- super(...arguments);
1863
- this.a = "";
1864
- }
1865
- };
1866
- __decorate([
1867
- Property({ through: "test://a" }),
1868
- __metadata("design:type", String)
1869
- ], ClassA.prototype, "a", void 0);
1870
- ClassA = __decorate([
1871
- Model({ name: "ClassA" })
1872
- ], ClassA);
1873
- let ClassB = class ClassB extends Ad4mModel {
1874
- constructor() {
1875
- super(...arguments);
1876
- this.b = "";
1877
- }
1878
- };
1879
- __decorate([
1880
- Property({ through: "test://b" }),
1881
- __metadata("design:type", String)
1882
- ], ClassB.prototype, "b", void 0);
1883
- ClassB = __decorate([
1884
- Model({ name: "ClassB" })
1885
- ], ClassB);
1886
- const propsA = getPropertiesMetadata(ClassA);
1887
- const propsB = getPropertiesMetadata(ClassB);
1888
- expect(propsA).not.toBe(propsB);
1889
- expect(propsA).toHaveProperty("a");
1890
- expect(propsB).toHaveProperty("b");
1891
- });
1892
- });
1893
- describe("Lazy Conformance Filters", () => {
1894
- it("should defer conformance filter resolution until property access", () => {
1895
- let LazyTarget2 = class LazyTarget2 extends Ad4mModel {
1896
- constructor() {
1897
- super(...arguments);
1898
- this.type = "test://lazy";
1899
- this.name = "";
1900
- }
1901
- };
1902
- __decorate([
1903
- Flag({ through: "test://type", value: "test://lazy" }),
1904
- __metadata("design:type", String)
1905
- ], LazyTarget2.prototype, "type", void 0);
1906
- __decorate([
1907
- Property({ through: "test://name", required: true }),
1908
- __metadata("design:type", String)
1909
- ], LazyTarget2.prototype, "name", void 0);
1910
- LazyTarget2 = __decorate([
1911
- Model({ name: "LazyTarget2" })
1912
- ], LazyTarget2);
1913
- let LazyParent2 = class LazyParent2 extends Ad4mModel {
1914
- constructor() {
1915
- super(...arguments);
1916
- this.children = [];
1917
- }
1918
- };
1919
- __decorate([
1920
- HasMany(() => LazyTarget2, { through: "test://children" }),
1921
- __metadata("design:type", Array)
1922
- ], LazyParent2.prototype, "children", void 0);
1923
- LazyParent2 = __decorate([
1924
- Model({ name: "LazyParent2" })
1925
- ], LazyParent2);
1926
- // generateSHACL was called during @Model — the shape exists
1927
- const shacl = LazyParent2.generateSHACL();
1928
- expect(shacl).toBeDefined();
1929
- expect(shacl.shape).toBeDefined();
1930
- expect(shacl.name).toBe("LazyParent2");
1931
- });
1932
- });
1933
- // ──────────────────────────────────────────────────────────
1934
- // deepQuery opt-in — getter evaluation on collection queries
1935
- // ──────────────────────────────────────────────────────────
1936
- describe("deepQuery opt-in — getter evaluation", () => {
1937
- let DeepQueryTestMessage = class DeepQueryTestMessage extends Ad4mModel {
1938
- constructor() {
1939
- super(...arguments);
1940
- this.type = "";
1941
- this.body = "";
1942
- this.isPopular = false;
1943
- this.reactions = [];
1944
- }
1945
- };
1946
- __decorate([
1947
- Flag({ through: "flux://entry_type", value: "flux://message" }),
1948
- __metadata("design:type", String)
1949
- ], DeepQueryTestMessage.prototype, "type", void 0);
1950
- __decorate([
1951
- Property({ through: "flux://body", resolveLanguage: "literal" }),
1952
- __metadata("design:type", String)
1953
- ], DeepQueryTestMessage.prototype, "body", void 0);
1954
- __decorate([
1955
- Property({
1956
- through: "flux://has_reply",
1957
- getter: `SELECT ?target WHERE { ?source <flux://has_reply> ?target . } LIMIT 1`,
1958
- }),
1959
- __metadata("design:type", String)
1960
- ], DeepQueryTestMessage.prototype, "replyingTo", void 0);
1961
- __decorate([
1962
- ReadOnly({
1963
- through: "flux://is_popular",
1964
- getter: `ASK WHERE { ?source <flux://is_popular> "true" . }`,
1965
- }),
1966
- __metadata("design:type", Boolean)
1967
- ], DeepQueryTestMessage.prototype, "isPopular", void 0);
1968
- __decorate([
1969
- HasMany({ through: "flux://reaction" }),
1970
- __metadata("design:type", Array)
1971
- ], DeepQueryTestMessage.prototype, "reactions", void 0);
1972
- DeepQueryTestMessage = __decorate([
1973
- Model({ name: "DeepQueryTestMessage" })
1974
- ], DeepQueryTestMessage);
1975
- let sparqlCalls;
1976
- const mockPerspective = {
1977
- uuid: "test-uuid",
1978
- modelQuery: jest.fn(async (className, queryJson, shapeJson) => {
1979
- // Return a basic result for the single-instance getData() path
1980
- const query = JSON.parse(queryJson);
1981
- const id = query?.where?.id;
1982
- if (id) {
1983
- return {
1984
- instances: [{ id, body: "Hello" }],
1985
- totalCount: 1,
1986
- };
1987
- }
1988
- return { instances: [], totalCount: 0 };
1989
- }),
1990
- querySparql: jest.fn(async (q) => {
1991
- sparqlCalls.push(q);
1992
- return [];
1993
- }),
1994
- get: jest.fn().mockResolvedValue([]),
1995
- getExpression: jest.fn().mockResolvedValue(null),
1996
- stringOrTemplateObjectToSubjectClassName: jest.fn().mockResolvedValue("DeepQueryTestMessage"),
1997
- };
1998
- beforeEach(() => {
1999
- sparqlCalls = [];
2000
- mockPerspective.querySparql.mockClear();
2001
- mockPerspective.get.mockClear();
2002
- });
2003
- function makeInstances(count) {
2004
- return Array.from({ length: count }, (_, i) => new DeepQueryTestMessage(mockPerspective, `flux://msg-${i}`));
2005
- }
2006
- it("single-instance get() delegates getter evaluation to Rust (no JS-side SPARQL)", async () => {
2007
- const instance = new DeepQueryTestMessage(mockPerspective, "flux://msg-single");
2008
- mockPerspective.querySparql.mockImplementation(async (q) => {
2009
- sparqlCalls.push(q);
2010
- if (q.includes("flux://msg-single") && !q.includes("flux://has_reply") && !q.includes("flux://is_popular")) {
2011
- return [
2012
- { source: "flux://msg-single", predicate: "flux://entry_type", target: "flux://message", author: "did:key:a", timestamp: "3000" },
2013
- { source: "flux://msg-single", predicate: "flux://body", target: "literal:string:Hello", author: "did:key:a", timestamp: "3000" },
2014
- ];
2015
- }
2016
- return [];
2017
- });
2018
- await instance.get();
2019
- // Getter evaluation now happens Rust-side via evaluate_getters() — no JS SPARQL calls
2020
- const getterCalls = sparqlCalls.filter((q) => q.includes("flux://has_reply") || q.includes("flux://is_popular"));
2021
- expect(getterCalls.length).toBe(0);
2022
- });
2023
- describe("Ad4mModel.evaluateGetters()", () => {
2024
- it("resolves getters for a batch of instances", async () => {
2025
- const instances = makeInstances(4);
2026
- sparqlCalls = [];
2027
- await DeepQueryTestMessage.evaluateGetters(instances.slice(0, 2), mockPerspective, ["replyingTo"]);
2028
- const replyCalls = sparqlCalls.filter((q) => q.includes("flux://has_reply"));
2029
- expect(replyCalls.length).toBe(2);
2030
- const popularCalls = sparqlCalls.filter((q) => q.includes("flux://is_popular"));
2031
- expect(popularCalls.length).toBe(0);
2032
- });
2033
- it("evaluates all getters when propertyNames is omitted", async () => {
2034
- const instances = makeInstances(2);
2035
- sparqlCalls = [];
2036
- await DeepQueryTestMessage.evaluateGetters(instances, mockPerspective);
2037
- const replyCalls = sparqlCalls.filter((q) => q.includes("flux://has_reply"));
2038
- const popularCalls = sparqlCalls.filter((q) => q.includes("flux://is_popular"));
2039
- expect(replyCalls.length).toBe(2);
2040
- expect(popularCalls.length).toBe(2);
2041
- });
2042
- it("handles empty array gracefully", async () => {
2043
- sparqlCalls = [];
2044
- await DeepQueryTestMessage.evaluateGetters([], mockPerspective);
2045
- expect(sparqlCalls.length).toBe(0);
2046
- });
2047
- });
2048
- describe("deepQuery via ModelQueryBuilder", () => {
2049
- it("deepQuery() method sets deepQuery flag on queryParams", () => {
2050
- const builder = DeepQueryTestMessage.query(mockPerspective);
2051
- builder.deepQuery();
2052
- expect(builder.queryParams.deepQuery).toBe(true);
2053
- });
2054
- });
2055
- });