@coasys/ad4m 0.13.0-test-6 → 0.13.0-test-8

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 (279) hide show
  1. package/lib/index.cjs +1103 -747
  2. package/lib/index.js +1090 -747
  3. package/lib/src/Ad4mClient.d.ts +4 -1
  4. package/lib/src/Ad4mClient.js +2 -2
  5. package/lib/src/agent/AgentClient.js +17 -0
  6. package/lib/src/ai/AIClient.js +1 -1
  7. package/lib/src/apiClient.d.ts +5 -1
  8. package/lib/src/apiClient.js +14 -6
  9. package/lib/src/generated/rest/AIModelLoadingStatus.d.ts +7 -0
  10. package/lib/src/generated/rest/AIModelLoadingStatus.js +2 -0
  11. package/lib/src/generated/rest/AddAgentInfosRequest.d.ts +3 -0
  12. package/lib/src/generated/rest/AddAgentInfosRequest.js +2 -0
  13. package/lib/src/generated/rest/AddLinkExpressionRequest.d.ts +6 -0
  14. package/lib/src/generated/rest/AddLinkExpressionRequest.js +1 -0
  15. package/lib/src/generated/rest/AddLinkRequest.d.ts +6 -0
  16. package/lib/src/generated/rest/AddLinkRequest.js +1 -0
  17. package/lib/src/generated/rest/AddLinksBulkRequest.d.ts +6 -0
  18. package/lib/src/generated/rest/AddLinksBulkRequest.js +1 -0
  19. package/lib/src/generated/rest/AddSdnaRequest.d.ts +6 -0
  20. package/lib/src/generated/rest/AddSdnaRequest.js +2 -0
  21. package/lib/src/generated/rest/ApplyTemplateRequest.d.ts +4 -0
  22. package/lib/src/generated/rest/ApplyTemplateRequest.js +2 -0
  23. package/lib/src/generated/rest/AuthInfoInput.d.ts +10 -0
  24. package/lib/src/generated/rest/AuthInfoInput.js +1 -0
  25. package/lib/src/generated/rest/BroadcastRequest.d.ts +6 -0
  26. package/lib/src/generated/rest/BroadcastRequest.js +1 -0
  27. package/lib/src/generated/rest/CapabilityInput.d.ts +5 -0
  28. package/lib/src/generated/rest/CapabilityInput.js +1 -0
  29. package/lib/src/generated/rest/CommitBatchRequest.d.ts +3 -0
  30. package/lib/src/generated/rest/CommitBatchRequest.js +2 -0
  31. package/lib/src/generated/rest/ComputeLogEntry.d.ts +9 -0
  32. package/lib/src/generated/rest/ComputeLogEntry.js +2 -0
  33. package/lib/src/generated/rest/CreateExpressionRequest.d.ts +4 -0
  34. package/lib/src/generated/rest/CreateExpressionRequest.js +2 -0
  35. package/lib/src/generated/rest/CreatePerspectiveRequest.d.ts +3 -0
  36. package/lib/src/generated/rest/CreatePerspectiveRequest.js +2 -0
  37. package/lib/src/generated/rest/CreateSubjectRequest.d.ts +6 -0
  38. package/lib/src/generated/rest/CreateSubjectRequest.js +2 -0
  39. package/lib/src/generated/rest/CreateUserRequest.d.ts +4 -0
  40. package/lib/src/generated/rest/CreateUserRequest.js +2 -0
  41. package/lib/src/generated/rest/CreateUserResponse.d.ts +5 -0
  42. package/lib/src/generated/rest/CreateUserResponse.js +2 -0
  43. package/lib/src/generated/rest/DecoratedExpressionProof.d.ts +6 -0
  44. package/lib/src/generated/rest/DecoratedExpressionProof.js +2 -0
  45. package/lib/src/generated/rest/DecoratedLinkExpression.d.ts +10 -0
  46. package/lib/src/generated/rest/DecoratedLinkExpression.js +1 -0
  47. package/lib/src/generated/rest/DisposeQueryRequest.d.ts +3 -0
  48. package/lib/src/generated/rest/DisposeQueryRequest.js +2 -0
  49. package/lib/src/generated/rest/EmailTestRequest.d.ts +6 -0
  50. package/lib/src/generated/rest/EmailTestRequest.js +2 -0
  51. package/lib/src/generated/rest/EmbedRequest.d.ts +4 -0
  52. package/lib/src/generated/rest/EmbedRequest.js +2 -0
  53. package/lib/src/generated/rest/EntanglementProofInput.d.ts +6 -0
  54. package/lib/src/generated/rest/EntanglementProofInput.js +2 -0
  55. package/lib/src/generated/rest/EntanglementProofPreflightRequest.d.ts +4 -0
  56. package/lib/src/generated/rest/EntanglementProofPreflightRequest.js +2 -0
  57. package/lib/src/generated/rest/ExecuteCommandsRequest.d.ts +4 -0
  58. package/lib/src/generated/rest/ExecuteCommandsRequest.js +2 -0
  59. package/lib/src/generated/rest/ExportRequest.d.ts +5 -0
  60. package/lib/src/generated/rest/ExportRequest.js +2 -0
  61. package/lib/src/generated/rest/ExpressionManyRequest.d.ts +3 -0
  62. package/lib/src/generated/rest/ExpressionManyRequest.js +2 -0
  63. package/lib/src/generated/rest/ExpressionProof.d.ts +4 -0
  64. package/lib/src/generated/rest/ExpressionProof.js +2 -0
  65. package/lib/src/generated/rest/ExpressionProofInput.d.ts +6 -0
  66. package/lib/src/generated/rest/ExpressionProofInput.js +2 -0
  67. package/lib/src/generated/rest/FriendSendMessageRequest.d.ts +3 -0
  68. package/lib/src/generated/rest/FriendSendMessageRequest.js +2 -0
  69. package/lib/src/generated/rest/FriendsListRequest.d.ts +3 -0
  70. package/lib/src/generated/rest/FriendsListRequest.js +2 -0
  71. package/lib/src/generated/rest/GenerateAgentRequest.d.ts +3 -0
  72. package/lib/src/generated/rest/GenerateAgentRequest.js +2 -0
  73. package/lib/src/generated/rest/GenerateJwtRequest.d.ts +4 -0
  74. package/lib/src/generated/rest/GenerateJwtRequest.js +2 -0
  75. package/lib/src/generated/rest/GetSubjectDataRequest.d.ts +4 -0
  76. package/lib/src/generated/rest/GetSubjectDataRequest.js +2 -0
  77. package/lib/src/generated/rest/HostingInfoResponse.d.ts +5 -0
  78. package/lib/src/generated/rest/HostingInfoResponse.js +2 -0
  79. package/lib/src/generated/rest/HostingWalletResponse.d.ts +4 -0
  80. package/lib/src/generated/rest/HostingWalletResponse.js +2 -0
  81. package/lib/src/generated/rest/ImportAgentRequest.d.ts +6 -0
  82. package/lib/src/generated/rest/ImportAgentRequest.js +2 -0
  83. package/lib/src/generated/rest/ImportRequest.d.ts +4 -0
  84. package/lib/src/generated/rest/ImportRequest.js +2 -0
  85. package/lib/src/generated/rest/JoinNeighbourhoodRequest.d.ts +3 -0
  86. package/lib/src/generated/rest/JoinNeighbourhoodRequest.js +2 -0
  87. package/lib/src/generated/rest/KeepAliveQueryRequest.d.ts +3 -0
  88. package/lib/src/generated/rest/KeepAliveQueryRequest.js +2 -0
  89. package/lib/src/generated/rest/LanguageMetaInput.d.ts +6 -0
  90. package/lib/src/generated/rest/LanguageMetaInput.js +2 -0
  91. package/lib/src/generated/rest/Link.d.ts +5 -0
  92. package/lib/src/generated/rest/Link.js +2 -0
  93. package/lib/src/generated/rest/LinkExpression.d.ts +10 -0
  94. package/lib/src/generated/rest/LinkExpression.js +1 -0
  95. package/lib/src/generated/rest/LinkExpressionInput.d.ts +10 -0
  96. package/lib/src/generated/rest/LinkExpressionInput.js +1 -0
  97. package/lib/src/generated/rest/LinkInput.d.ts +5 -0
  98. package/lib/src/generated/rest/LinkInput.js +2 -0
  99. package/lib/src/generated/rest/LinkLanguageTemplatesRequest.d.ts +3 -0
  100. package/lib/src/generated/rest/LinkLanguageTemplatesRequest.js +2 -0
  101. package/lib/src/generated/rest/LinkMutationRequest.d.ts +12 -0
  102. package/lib/src/generated/rest/LinkMutationRequest.js +1 -0
  103. package/lib/src/generated/rest/LinkMutationResponse.d.ts +9 -0
  104. package/lib/src/generated/rest/LinkMutationResponse.js +1 -0
  105. package/lib/src/generated/rest/LinkMutations.d.ts +6 -0
  106. package/lib/src/generated/rest/LinkMutations.js +1 -0
  107. package/lib/src/generated/rest/LinkMutationsRequest.d.ts +5 -0
  108. package/lib/src/generated/rest/LinkMutationsRequest.js +1 -0
  109. package/lib/src/generated/rest/LinkStatus.d.ts +1 -0
  110. package/lib/src/generated/rest/LinkStatus.js +2 -0
  111. package/lib/src/generated/rest/LinkUpdateInput.d.ts +5 -0
  112. package/lib/src/generated/rest/LinkUpdateInput.js +1 -0
  113. package/lib/src/generated/rest/LockAgentRequest.d.ts +3 -0
  114. package/lib/src/generated/rest/LockAgentRequest.js +2 -0
  115. package/lib/src/generated/rest/LoginUserRequest.d.ts +5 -0
  116. package/lib/src/generated/rest/LoginUserRequest.js +2 -0
  117. package/lib/src/generated/rest/ModelType.d.ts +1 -0
  118. package/lib/src/generated/rest/ModelType.js +2 -0
  119. package/lib/src/generated/rest/NotificationGrantRequest.d.ts +3 -0
  120. package/lib/src/generated/rest/NotificationGrantRequest.js +2 -0
  121. package/lib/src/generated/rest/NotificationInput.d.ts +10 -0
  122. package/lib/src/generated/rest/NotificationInput.js +2 -0
  123. package/lib/src/generated/rest/OpenLinkRequest.d.ts +3 -0
  124. package/lib/src/generated/rest/OpenLinkRequest.js +2 -0
  125. package/lib/src/generated/rest/PermitCapabilityRequest.d.ts +3 -0
  126. package/lib/src/generated/rest/PermitCapabilityRequest.js +2 -0
  127. package/lib/src/generated/rest/PerspectiveInput.d.ts +4 -0
  128. package/lib/src/generated/rest/PerspectiveInput.js +1 -0
  129. package/lib/src/generated/rest/PromptRequest.d.ts +4 -0
  130. package/lib/src/generated/rest/PromptRequest.js +2 -0
  131. package/lib/src/generated/rest/PublicPerspectiveInput.d.ts +4 -0
  132. package/lib/src/generated/rest/PublicPerspectiveInput.js +1 -0
  133. package/lib/src/generated/rest/PublishLanguageRequest.d.ts +5 -0
  134. package/lib/src/generated/rest/PublishLanguageRequest.js +1 -0
  135. package/lib/src/generated/rest/PublishNeighbourhoodRequest.d.ts +6 -0
  136. package/lib/src/generated/rest/PublishNeighbourhoodRequest.js +1 -0
  137. package/lib/src/generated/rest/QueryRequest.d.ts +7 -0
  138. package/lib/src/generated/rest/QueryRequest.js +2 -0
  139. package/lib/src/generated/rest/RemoveLinkRequest.d.ts +5 -0
  140. package/lib/src/generated/rest/RemoveLinkRequest.js +1 -0
  141. package/lib/src/generated/rest/RemoveLinksBulkRequest.d.ts +5 -0
  142. package/lib/src/generated/rest/RemoveLinksBulkRequest.js +1 -0
  143. package/lib/src/generated/rest/RequestCapabilityRequest.d.ts +4 -0
  144. package/lib/src/generated/rest/RequestCapabilityRequest.js +1 -0
  145. package/lib/src/generated/rest/RequestPaymentRequest.d.ts +3 -0
  146. package/lib/src/generated/rest/RequestPaymentRequest.js +2 -0
  147. package/lib/src/generated/rest/RequestVerificationRequest.d.ts +4 -0
  148. package/lib/src/generated/rest/RequestVerificationRequest.js +2 -0
  149. package/lib/src/generated/rest/ResourceInput.d.ts +4 -0
  150. package/lib/src/generated/rest/ResourceInput.js +2 -0
  151. package/lib/src/generated/rest/SetDefaultModelRequest.d.ts +4 -0
  152. package/lib/src/generated/rest/SetDefaultModelRequest.js +1 -0
  153. package/lib/src/generated/rest/SetFreeHostingEnabledRequest.d.ts +3 -0
  154. package/lib/src/generated/rest/SetFreeHostingEnabledRequest.js +2 -0
  155. package/lib/src/generated/rest/SetHotWalletAddressRequest.d.ts +3 -0
  156. package/lib/src/generated/rest/SetHotWalletAddressRequest.js +2 -0
  157. package/lib/src/generated/rest/SetMultiUserRequest.d.ts +3 -0
  158. package/lib/src/generated/rest/SetMultiUserRequest.js +2 -0
  159. package/lib/src/generated/rest/SetOnlineStatusRequest.d.ts +5 -0
  160. package/lib/src/generated/rest/SetOnlineStatusRequest.js +1 -0
  161. package/lib/src/generated/rest/SetStatusRequest.d.ts +3 -0
  162. package/lib/src/generated/rest/SetStatusRequest.js +2 -0
  163. package/lib/src/generated/rest/SetUserFreeAccessRequest.d.ts +4 -0
  164. package/lib/src/generated/rest/SetUserFreeAccessRequest.js +2 -0
  165. package/lib/src/generated/rest/SignMessageRequest.d.ts +3 -0
  166. package/lib/src/generated/rest/SignMessageRequest.js +2 -0
  167. package/lib/src/generated/rest/SignalRequest.d.ts +6 -0
  168. package/lib/src/generated/rest/SignalRequest.js +1 -0
  169. package/lib/src/generated/rest/SubscribeQueryRequest.d.ts +3 -0
  170. package/lib/src/generated/rest/SubscribeQueryRequest.js +2 -0
  171. package/lib/src/generated/rest/SubscribeQueryResponse.d.ts +4 -0
  172. package/lib/src/generated/rest/SubscribeQueryResponse.js +2 -0
  173. package/lib/src/generated/rest/TrustedAgentsRequest.d.ts +3 -0
  174. package/lib/src/generated/rest/TrustedAgentsRequest.js +2 -0
  175. package/lib/src/generated/rest/UnlockAgentRequest.d.ts +4 -0
  176. package/lib/src/generated/rest/UnlockAgentRequest.js +2 -0
  177. package/lib/src/generated/rest/UpdateLinkRequest.d.ts +7 -0
  178. package/lib/src/generated/rest/UpdateLinkRequest.js +1 -0
  179. package/lib/src/generated/rest/UpdatePerspectiveRequest.d.ts +3 -0
  180. package/lib/src/generated/rest/UpdatePerspectiveRequest.js +2 -0
  181. package/lib/src/generated/rest/UpdateProfileRequest.d.ts +5 -0
  182. package/lib/src/generated/rest/UpdateProfileRequest.js +1 -0
  183. package/lib/src/generated/rest/UserStatistics.d.ts +9 -0
  184. package/lib/src/generated/rest/UserStatistics.js +2 -0
  185. package/lib/src/generated/rest/VerificationRequestResult.d.ts +6 -0
  186. package/lib/src/generated/rest/VerificationRequestResult.js +2 -0
  187. package/lib/src/generated/rest/VerifyEmailRequest.d.ts +6 -0
  188. package/lib/src/generated/rest/VerifyEmailRequest.js +2 -0
  189. package/lib/src/generated/rest/VerifySignatureRequest.d.ts +5 -0
  190. package/lib/src/generated/rest/VerifySignatureRequest.js +2 -0
  191. package/lib/src/generated/rest/WriteSettingsRequest.d.ts +3 -0
  192. package/lib/src/generated/rest/WriteSettingsRequest.js +2 -0
  193. package/lib/src/generated/rest/index.d.ts +73 -0
  194. package/lib/src/generated/rest/index.js +8 -0
  195. package/lib/src/generated/rest/routes.d.ts +587 -0
  196. package/lib/src/generated/rest/routes.js +3 -0
  197. package/lib/src/index.d.ts +4 -0
  198. package/lib/src/index.js +4 -0
  199. package/lib/src/model/Ad4mModel.d.ts +30 -21
  200. package/lib/src/model/Ad4mModel.js +93 -316
  201. package/lib/src/model/Ad4mModel.test.js +1536 -535
  202. package/lib/src/model/ModelQueryBuilder.d.ts +5 -10
  203. package/lib/src/model/ModelQueryBuilder.js +136 -47
  204. package/lib/src/model/Subject.js +6 -6
  205. package/lib/src/model/decorators.d.ts +7 -4
  206. package/lib/src/model/decorators.js +0 -7
  207. package/lib/src/model/hydration-batch.d.ts +34 -0
  208. package/lib/src/model/hydration-batch.js +147 -0
  209. package/lib/src/model/hydration-batching.test.d.ts +7 -0
  210. package/lib/src/model/hydration-batching.test.js +456 -0
  211. package/lib/src/model/query-cache.test.d.ts +1 -0
  212. package/lib/src/model/query-cache.test.js +43 -0
  213. package/lib/src/model/query-sparql-batch.d.ts +17 -0
  214. package/lib/src/model/query-sparql-batch.js +260 -0
  215. package/lib/src/model/query-sparql.d.ts +0 -10
  216. package/lib/src/model/query-sparql.js +10 -15
  217. package/lib/src/model/query-sparql.test.d.ts +1 -0
  218. package/lib/src/model/query-sparql.test.js +230 -0
  219. package/lib/src/model/relation-filtering.test.js +15 -15
  220. package/lib/src/model/shacl-gen.js +120 -47
  221. package/lib/src/model/subscription-delta.test.d.ts +24 -0
  222. package/lib/src/model/subscription-delta.test.js +180 -0
  223. package/lib/src/model/subscription-pool.d.ts +39 -0
  224. package/lib/src/model/subscription-pool.js +165 -0
  225. package/lib/src/model/types.d.ts +140 -4
  226. package/lib/src/neighbourhood/NeighbourhoodProxy.test.js +33 -33
  227. package/lib/src/perspectives/PerspectiveClient.d.ts +13 -4
  228. package/lib/src/perspectives/PerspectiveClient.js +22 -6
  229. package/lib/src/perspectives/PerspectiveClient.test.d.ts +1 -0
  230. package/lib/src/perspectives/PerspectiveClient.test.js +224 -0
  231. package/lib/src/perspectives/PerspectiveProxy.d.ts +27 -7
  232. package/lib/src/perspectives/PerspectiveProxy.js +60 -12
  233. package/lib/src/perspectives/PerspectiveProxy.test.d.ts +1 -0
  234. package/lib/src/perspectives/PerspectiveProxy.test.js +34 -0
  235. package/lib/src/perspectives/PerspectiveResolver.d.ts +0 -1
  236. package/lib/src/perspectives/PerspectiveResolver.js +0 -11
  237. package/lib/src/perspectives/SparqlBindings.d.ts +47 -0
  238. package/lib/src/perspectives/SparqlBindings.js +65 -0
  239. package/lib/src/perspectives/WakerSubscriptionManager.js +5 -4
  240. package/lib/src/restClient.d.ts +52 -0
  241. package/lib/src/restClient.js +227 -0
  242. package/lib/src/runtime/RuntimeResolver.d.ts +28 -1
  243. package/lib/src/runtime/RuntimeResolver.js +197 -4
  244. package/lib/src/schema.gql +27 -1
  245. package/lib/src/shacl/NodeExpression.d.ts +44 -0
  246. package/lib/src/shacl/NodeExpression.js +39 -0
  247. package/lib/src/shacl/SHACLShape.d.ts +23 -0
  248. package/lib/src/shacl/SHACLShape.js +115 -1
  249. package/lib/src/shacl/builders.d.ts +58 -0
  250. package/lib/src/shacl/builders.js +76 -0
  251. package/lib/src/shacl/index.d.ts +36 -0
  252. package/lib/src/shacl/index.js +33 -0
  253. package/package.json +1 -1
  254. package/src/Ad4mClient.ts +7 -2
  255. package/src/agent/AgentClient.ts +23 -0
  256. package/src/ai/AIClient.ts +1 -1
  257. package/src/apiClient.ts +17 -6
  258. package/src/index.ts +4 -0
  259. package/src/model/Ad4mModel.test.ts +274 -72
  260. package/src/model/Ad4mModel.ts +141 -350
  261. package/src/model/ModelQueryBuilder.ts +131 -56
  262. package/src/model/decorators.ts +7 -13
  263. package/src/model/query-sparql.test.ts +35 -19
  264. package/src/model/query-sparql.ts +10 -16
  265. package/src/model/relation-filtering.test.ts +46 -39
  266. package/src/model/shacl-gen.ts +128 -54
  267. package/src/model/shacl-roundtrip.test.ts +197 -0
  268. package/src/model/types-typed-query.test.ts +360 -0
  269. package/src/model/types.ts +196 -4
  270. package/src/perspectives/PerspectiveClient.ts +24 -8
  271. package/src/perspectives/PerspectiveProxy.test.ts +85 -1
  272. package/src/perspectives/PerspectiveProxy.ts +65 -20
  273. package/src/perspectives/SparqlBindings.ts +79 -0
  274. package/src/perspectives/WakerSubscriptionManager.ts +5 -4
  275. package/src/shacl/NodeExpression.ts +54 -0
  276. package/src/shacl/SHACLShape.test.ts +172 -0
  277. package/src/shacl/SHACLShape.ts +173 -1
  278. package/src/shacl/builders.ts +86 -0
  279. package/src/shacl/index.ts +72 -0
@@ -2,7 +2,7 @@ import { Literal } from "../Literal";
2
2
  import { Link } from "../links/Links";
3
3
  import { LinkQuery } from "../perspectives/LinkQuery";
4
4
  import { makeRandomId } from "./util";
5
- import { getPropertiesMetadata, getRelationsMetadata, buildConformanceFilter, setPropertyRegistryEntry, setRelationRegistryEntry, Model } from "./decorators";
5
+ import { getPropertiesMetadata, getRelationsMetadata, setPropertyRegistryEntry, setRelationRegistryEntry, Model } from "./decorators";
6
6
  import { resolveParentPredicate } from "./query-common";
7
7
  import { isArrayType, determinePredicate, determineNamespace, buildModelFromJSONSchema } from "./json-schema";
8
8
  import { buildSPARQLQuery } from "./query-sparql";
@@ -11,46 +11,6 @@ import { normalizeValue, } from "./hydration";
11
11
  // ---------------------------------------------------------------------------
12
12
  // Helpers for Rust-side include resolution
13
13
  // ---------------------------------------------------------------------------
14
- /**
15
- * Recursively enrich relation metadata in the shape with target class shapes
16
- * so the Rust endpoint can resolve includes in-process (no extra GraphQL
17
- * round-trips per relation).
18
- */
19
- function enrichShapeForIncludes(metadata, include, allRelMeta) {
20
- for (const [relName, includeVal] of Object.entries(include)) {
21
- if (!includeVal)
22
- continue;
23
- const meta = allRelMeta[relName];
24
- if (!meta?.target)
25
- continue;
26
- const TargetClass = meta.target();
27
- // Deep-copy so we don't mutate the cached metadata
28
- const targetMeta = JSON.parse(JSON.stringify(TargetClass.getModelMetadata()));
29
- // Ensure the relation is in metadata.relations (fallback for edge cases)
30
- if (!metadata.relations[relName]) {
31
- metadata.relations[relName] = {
32
- name: relName,
33
- predicate: meta.predicate,
34
- direction: meta.kind === 'belongsToMany' || meta.kind === 'belongsToOne'
35
- ? 'reverse'
36
- : 'forward',
37
- };
38
- }
39
- const rel = metadata.relations[relName];
40
- rel.kind = meta.kind;
41
- rel.maxCount = meta.maxCount;
42
- rel.targetShape = targetMeta;
43
- rel.targetClassName = targetMeta.className;
44
- // Recurse for nested includes
45
- const nested = typeof includeVal === 'object' && includeVal !== null
46
- ? includeVal.include
47
- : undefined;
48
- if (nested) {
49
- const targetRelMeta = getRelationsMetadata(TargetClass);
50
- enrichShapeForIncludes(targetMeta, nested, targetRelMeta);
51
- }
52
- }
53
- }
54
14
  /**
55
15
  * Construct a model class instance from a plain JSON object returned by the
56
16
  * Rust endpoint. Recursively converts included relation values (which come
@@ -95,22 +55,6 @@ function jsonToModelInstance(ModelClass, perspective, json, include, properties)
95
55
  }
96
56
  instance[key] = value;
97
57
  }
98
- // Apply property transform functions from decorators (only for literal-resolved
99
- // or no-resolveLanguage properties; non-literal properties are resolved + transformed
100
- // asynchronously in executeModelQuery).
101
- try {
102
- const propsMeta = getPropertiesMetadata(ModelClass);
103
- for (const [propName, opts] of Object.entries(propsMeta)) {
104
- const o = opts;
105
- if (typeof o.transform !== 'function' || !(propName in json))
106
- continue;
107
- // Skip non-literal resolveLanguage props — they need async expression resolution first
108
- if (o.resolveLanguage != null && o.resolveLanguage !== 'literal')
109
- continue;
110
- instance[propName] = o.transform(instance[propName]);
111
- }
112
- }
113
- catch (_) { /* no metadata available */ }
114
58
  // Recursively convert included relation values to class instances
115
59
  if (include) {
116
60
  const relMeta = getRelationsMetadata(ModelClass);
@@ -348,8 +292,8 @@ export class Ad4mModel {
348
292
  ...(options.getter !== undefined && { getter: options.getter }),
349
293
  ...(options.prologSetter !== undefined && { prologSetter: options.prologSetter }),
350
294
  ...(options.local !== undefined && { local: options.local }),
351
- ...(options.transform !== undefined && { transform: options.transform }),
352
- ...(options.flag !== undefined && { flag: options.flag })
295
+ ...(options.flag !== undefined && { flag: options.flag }),
296
+ ...(options.transform !== undefined && { transform: options.transform })
353
297
  };
354
298
  }
355
299
  // Extract relations (relations) from WeakMap registry
@@ -534,6 +478,7 @@ export class Ad4mModel {
534
478
  * • `null` / empty object — skip ALL relations (used by bare
535
479
  * subscriptions that don't eagerly load relations).
536
480
  */
481
+ /** @internal */
537
482
  takeSnapshot(includedRelations) {
538
483
  const ctor = this.constructor;
539
484
  const metadata = ctor.getModelMetadata();
@@ -729,115 +674,14 @@ export class Ad4mModel {
729
674
  }
730
675
  /**
731
676
  * Build the JSON parameters needed for a model query/subscription endpoint.
732
- * Returns the className, queryJson, and shapeJson that the Rust executor expects.
677
+ * Returns the className and queryJson that the Rust executor expects.
678
+ * Shape resolution happens server-side from the perspective's SHACL triples.
733
679
  * @internal
734
680
  */
735
681
  static prepareModelQueryParams(query = {}, classNameOverride) {
736
- const metadata = this.getModelMetadata();
737
- const className = classNameOverride || metadata.className;
738
- const queryInput = {};
739
- if (query.parent) {
740
- const parentPredicate = resolveParentPredicate(query.parent, this);
741
- queryInput.parent = { id: query.parent.id, predicate: parentPredicate };
742
- }
743
- if (query.properties)
744
- queryInput.properties = query.properties;
745
- if (query.include)
746
- queryInput.include = query.include;
747
- if (query.where)
748
- queryInput.where = query.where;
749
- if (query.order) {
750
- queryInput.order = Object.entries(query.order).map(([k, v]) => [k, v]);
751
- }
752
- if (query.offset !== undefined)
753
- queryInput.offset = query.offset;
754
- if (query.limit !== undefined)
755
- queryInput.limit = query.limit;
756
- if (query.count !== undefined)
757
- queryInput.count = query.count;
758
- queryInput.deepQuery = query.deepQuery ?? true;
759
- if (query.include) {
760
- const allRelMeta = getRelationsMetadata(this);
761
- enrichShapeForIncludes(metadata, query.include, allRelMeta);
762
- }
763
- // Pre-compute conformance getters for Rust-side evaluation.
764
- // Where clauses are NOT compiled into getter SPARQL because stored
765
- // property values are signed expression envelopes (literal:json:...),
766
- // not simple literal:string:X values. Instead, where clauses are
767
- // attached as metadata for Rust-side post-evaluation filtering.
768
- {
769
- const allRelMeta = getRelationsMetadata(this);
770
- for (const [relName, relMeta] of Object.entries(metadata.relations)) {
771
- const rel = relMeta;
772
- if (rel.getter || rel.direction === 'reverse' || rel.filter === false)
773
- continue;
774
- const meta = allRelMeta[relName];
775
- if (!meta?.target)
776
- continue;
777
- try {
778
- const TargetClass = meta.target();
779
- const filter = buildConformanceFilter(meta.predicate, TargetClass);
780
- if (filter) {
781
- rel.getter = filter.getter;
782
- }
783
- // Attach where-clause metadata for Rust-side post-getter filtering
784
- if (rel.where) {
785
- try {
786
- const targetMetadata = TargetClass.getModelMetadata?.() ?? null;
787
- if (targetMetadata) {
788
- const predicates = {};
789
- for (const propName of Object.keys(rel.where)) {
790
- if (['id', 'author', 'timestamp'].includes(propName))
791
- continue;
792
- const propMeta = targetMetadata.properties[propName];
793
- if (propMeta?.predicate) {
794
- predicates[propName] = propMeta.predicate;
795
- }
796
- }
797
- if (Object.keys(predicates).length > 0) {
798
- rel.whereFilter = rel.where;
799
- rel.wherePredicates = predicates;
800
- }
801
- }
802
- }
803
- catch (_) { }
804
- }
805
- }
806
- catch (_) { }
807
- }
808
- }
809
- return {
810
- className,
811
- queryJson: JSON.stringify(queryInput),
812
- shapeJson: JSON.stringify(metadata),
813
- };
814
- }
815
- /**
816
- * Parse raw model query/subscription result JSON into typed model instances.
817
- * Used by ModelQueryBuilder to convert subscription updates without circular imports.
818
- * @internal
819
- */
820
- static parseModelResult(perspective, raw, include, properties) {
821
- const data = typeof raw === 'string' ? JSON.parse(raw) : raw;
822
- const arr = data.instances || data;
823
- if (!Array.isArray(arr))
824
- return [];
825
- return arr.map((json) => jsonToModelInstance(this, perspective, json, include, properties));
826
- }
827
- // instancesFromQueryResult — removed (superseded by Rust executeModelQuery pipeline)
828
- /**
829
- * Execute a model query via the executor-side endpoint.
830
- *
831
- * This replaces the old SPARQL-build → hydrate → JS-filter → JS-sort → JS-paginate pipeline
832
- * with a single RPC to the executor that handles everything in Rust.
833
- *
834
- * @internal
835
- */
836
- static async executeModelQuery(perspective, query = {}, classNameOverride) {
837
682
  const metadata = this.getModelMetadata();
838
683
  const className = classNameOverride || metadata.className;
839
684
  // Expand includeAll: true to a full IncludeMap covering every forward relation.
840
- // Done before queryInput is built so all downstream uses of query.include see the expansion.
841
685
  if (query.includeAll) {
842
686
  const allRelMeta = getRelationsMetadata(this);
843
687
  const expanded = {};
@@ -846,11 +690,8 @@ export class Ad4mModel {
846
690
  expanded[relName] = true;
847
691
  }
848
692
  }
849
- // Explicit include entries take precedence over the expansion
850
693
  query = { ...query, include: { ...expanded, ...query.include } };
851
694
  }
852
- // Build the query input that the Rust endpoint expects.
853
- // Convert the TS Query type to the executor's ModelQueryInput format.
854
695
  const queryInput = {};
855
696
  if (query.parent) {
856
697
  const parentPredicate = resolveParentPredicate(query.parent, this);
@@ -874,19 +715,23 @@ export class Ad4mModel {
874
715
  if (Object.keys(normalIncludes).length > 0)
875
716
  queryInput.include = normalIncludes;
876
717
  if (Object.keys(projections).length > 0) {
877
- // Enrich projections with target shapes so Rust can apply where clause filtering
718
+ // Tag each projection with its target class name so the executor can
719
+ // resolve the target shape through its in-memory cache when applying
720
+ // projection where-clause filters.
878
721
  const allRelMeta = getRelationsMetadata(this);
879
722
  for (const [, proj] of Object.entries(projections)) {
880
723
  const relMeta = allRelMeta[proj.from];
881
- if (!proj.targetShape && relMeta?.target) {
724
+ if (!proj.targetClassName && relMeta?.target) {
882
725
  try {
883
726
  const TargetClass = relMeta.target();
884
727
  const targetMeta = TargetClass.getModelMetadata?.();
885
- if (targetMeta) {
886
- proj.targetShape = targetMeta;
728
+ if (targetMeta?.className) {
729
+ proj.targetClassName = targetMeta.className;
887
730
  }
888
731
  }
889
- catch (_) { /* target class may not be available */ }
732
+ catch (e) {
733
+ console.debug(`prepareModelQueryParams: target class unavailable for projection:`, e);
734
+ }
890
735
  }
891
736
  }
892
737
  queryInput.projections = projections;
@@ -895,7 +740,6 @@ export class Ad4mModel {
895
740
  if (query.where)
896
741
  queryInput.where = query.where;
897
742
  if (query.order) {
898
- // Convert { propName: 'ASC' | 'DESC' } to [[propName, 'ASC'|'DESC'], ...]
899
743
  queryInput.order = Object.entries(query.order).map(([k, v]) => [k, v]);
900
744
  }
901
745
  if (query.offset !== undefined)
@@ -905,113 +749,52 @@ export class Ad4mModel {
905
749
  if (query.count !== undefined)
906
750
  queryInput.count = query.count;
907
751
  queryInput.deepQuery = query.deepQuery ?? true;
908
- // Enrich relation metadata with target class shapes for Rust-side
909
- // include resolution. This eliminates per-relation GraphQL round-trips
910
- // by letting the Rust endpoint resolve includes in-process.
911
- if (queryInput.include) {
912
- const allRelMeta = getRelationsMetadata(this);
913
- enrichShapeForIncludes(metadata, queryInput.include, allRelMeta);
914
- }
915
- // ── Pre-compute conformance getters for Rust-side evaluation ──────
916
- // For each relation with a target class and filter !== false, compute
917
- // the conformance getter SPARQL so Rust can evaluate it in-process
918
- // (eliminating N × querySparql round-trips per instance).
919
- // When a relation has a `where` clause, compile the where conditions
920
- // into the getter SPARQL so Rust applies them during evaluation.
921
- {
922
- const allRelMeta = getRelationsMetadata(this);
923
- for (const [relName, relMeta] of Object.entries(metadata.relations)) {
924
- const rel = relMeta;
925
- if (rel.getter)
926
- continue; // explicit getter already set
927
- if (rel.direction === 'reverse')
928
- continue; // reverse relations use reverse link lookup
929
- if (rel.filter === false)
930
- continue; // opt-out of conformance filtering
931
- const meta = allRelMeta[relName];
932
- if (!meta?.target)
933
- continue;
934
- try {
935
- const TargetClass = meta.target();
936
- const filter = buildConformanceFilter(meta.predicate, TargetClass);
937
- if (filter) {
938
- rel.getter = filter.getter;
939
- }
940
- // Attach where-clause metadata for Rust-side post-getter filtering.
941
- // Property values are signed expression envelopes (literal:json:...)
942
- // and cannot be matched by SPARQL FILTER on the raw IRI.
943
- if (rel.where) {
944
- try {
945
- const targetMetadata = TargetClass.getModelMetadata?.() ?? null;
946
- if (targetMetadata) {
947
- const predicates = {};
948
- for (const propName of Object.keys(rel.where)) {
949
- if (['id', 'author', 'timestamp'].includes(propName))
950
- continue;
951
- const propMeta = targetMetadata.properties[propName];
952
- if (propMeta?.predicate) {
953
- predicates[propName] = propMeta.predicate;
954
- }
955
- }
956
- if (Object.keys(predicates).length > 0) {
957
- rel.whereFilter = rel.where;
958
- rel.wherePredicates = predicates;
959
- }
960
- }
961
- }
962
- catch (_) { /* target metadata unavailable */ }
963
- }
964
- }
965
- catch (e) {
966
- // Target class may not be available; skip silently
967
- }
968
- }
969
- }
970
- // Send shape metadata to the executor so it knows the model structure.
971
- // This is more reliable than reading SHACL from the store because
972
- // the TS decorators are the definitive source of truth.
973
- const shapeJson = JSON.stringify(metadata);
974
- const queryJson = JSON.stringify(queryInput);
975
- const result = await perspective.modelQuery(className, queryJson, shapeJson);
752
+ // Conformance getters, where filters, and target shapes for includes
753
+ // are all resolved by the executor from the perspective's SHACL triples
754
+ // — no client-side pre-computation is needed any more.
755
+ return {
756
+ className,
757
+ queryJson: JSON.stringify(queryInput),
758
+ metadata,
759
+ };
760
+ }
761
+ /**
762
+ * Parse raw model query/subscription result JSON into typed model instances.
763
+ * Used by ModelQueryBuilder to convert subscription updates without circular imports.
764
+ * @internal
765
+ */
766
+ static parseModelResult(perspective, raw, include, properties) {
767
+ const data = typeof raw === 'string' ? JSON.parse(raw) : raw;
768
+ const arr = data.instances || data;
769
+ if (!Array.isArray(arr))
770
+ return [];
771
+ return arr.map((json) => jsonToModelInstance(this, perspective, json, include, properties));
772
+ }
773
+ // instancesFromQueryResult — removed (superseded by Rust executeModelQuery pipeline)
774
+ /**
775
+ * Execute a model query via the executor-side endpoint.
776
+ *
777
+ * This replaces the old SPARQL-build → hydrate → JS-filter → JS-sort → JS-paginate pipeline
778
+ * with a single RPC to the executor that handles everything in Rust.
779
+ *
780
+ * @internal
781
+ */
782
+ static async executeModelQuery(perspective, query = {}, classNameOverride) {
783
+ // Delegate query input building to the shared prepareModelQueryParams
784
+ // helper. The executor resolves the shape from SHACL server-side.
785
+ const { className, queryJson } = this.prepareModelQueryParams(query, classNameOverride);
786
+ const result = await perspective.modelQuery(className, queryJson);
976
787
  // Convert JSON instances to model class instances, recursively constructing
977
788
  // class instances for any included relations resolved by Rust.
978
789
  const instances = result.instances.map((json) => {
979
790
  return jsonToModelInstance(this, perspective, json, query.include, query.properties);
980
791
  });
981
- // Resolve non-literal expressions (e.g. file languages where the stored
982
- // value is a content-addressed hash that must be fetched from the language
983
- // runtime). The Rust endpoint returns raw target URIs; we resolve them here.
984
- const propsMeta = getPropertiesMetadata(this);
985
- const resolveProps = Object.entries(propsMeta).filter(([, opts]) => opts.resolveLanguage != null &&
986
- opts.resolveLanguage !== 'literal');
987
- if (resolveProps.length > 0) {
988
- await Promise.all(instances.map(async (inst) => {
989
- for (const [propName, opts] of resolveProps) {
990
- const val = inst[propName];
991
- if (typeof val !== 'string' || !val || val.startsWith('literal:'))
992
- continue;
993
- try {
994
- const expression = await perspective.getExpression(val);
995
- if (expression) {
996
- let resolved;
997
- try {
998
- resolved = JSON.parse(expression.data);
999
- }
1000
- catch {
1001
- resolved = expression.data;
1002
- }
1003
- const transform = opts.transform;
1004
- inst[propName] = typeof transform === 'function' ? transform(resolved) : resolved;
1005
- }
1006
- }
1007
- catch (_) { /* resolution failed — keep raw value */ }
1008
- }
1009
- }));
1010
- }
1011
- // Take snapshots for dirty tracking
1012
- const snapshotRelations = queryInput.include;
792
+ // Take snapshots for dirty tracking (exclude $-prefixed projection keys)
793
+ const snapshotRelations = query.include
794
+ ? Object.fromEntries(Object.entries(query.include).filter(([k]) => !k.startsWith('$')))
795
+ : undefined;
1013
796
  for (const inst of instances) {
1014
- inst.takeSnapshot(snapshotRelations);
797
+ inst.takeSnapshot(snapshotRelations && Object.keys(snapshotRelations).length > 0 ? snapshotRelations : undefined);
1015
798
  }
1016
799
  return {
1017
800
  results: instances,
@@ -1023,15 +806,14 @@ export class Ad4mModel {
1023
806
  *
1024
807
  * @param perspective - The perspective to search in
1025
808
  * @param query - Optional query parameters to filter results
1026
- * @param useSPARQL - Whether to use SPARQL (default: true, 10-100x faster) or Prolog (legacy)
809
+ * @param _engine - **Deprecated.** Accepted for backward compatibility but ignored.
810
+ * All queries now use the Rust SPARQL pipeline.
1027
811
  * @returns Array of matching models
1028
812
  *
1029
813
  * @example
1030
814
  * ```typescript
1031
- * // Get all recipes (uses SPARQL by default)
1032
815
  * const allRecipes = await Recipe.findAll(perspective);
1033
816
  *
1034
- * // Get recipes with specific criteria (uses SPARQL)
1035
817
  * const recipes = await Recipe.findAll(perspective, {
1036
818
  * where: {
1037
819
  * name: "Pasta",
@@ -1040,16 +822,14 @@ export class Ad4mModel {
1040
822
  * order: { createdAt: "DESC" },
1041
823
  * limit: 10
1042
824
  * });
1043
- *
1044
- * // Explicitly use Prolog (legacy, for backward compatibility)
1045
- * const recipesProlog = await Recipe.findAll(perspective, {}, false);
1046
825
  * ```
1047
826
  */
1048
- static async findAll(perspective, query = {}, _engine) {
1049
- if (query.properties && query.properties.length === 0) {
827
+ static async findAll(perspective, query) {
828
+ const q = (query ?? {});
829
+ if (q.properties && q.properties.length === 0) {
1050
830
  throw new Error("properties[] must not be empty — omit the field to return all properties, or specify at least one field name");
1051
831
  }
1052
- const { results } = await this.executeModelQuery(perspective, query);
832
+ const { results } = await this.executeModelQuery(perspective, q);
1053
833
  return results;
1054
834
  }
1055
835
  /**
@@ -1059,7 +839,7 @@ export class Ad4mModel {
1059
839
  *
1060
840
  * @param perspective - The perspective to search in
1061
841
  * @param query - Optional query parameters to filter results
1062
- * @param useSPARQL - Whether to use SPARQL (default: true) or Prolog (legacy)
842
+ * @param _engine - **Deprecated.** Accepted for backward compatibility but ignored.
1063
843
  * @returns The first matching instance, or `null`
1064
844
  *
1065
845
  * @example
@@ -1072,8 +852,8 @@ export class Ad4mModel {
1072
852
  * }
1073
853
  * ```
1074
854
  */
1075
- static async findOne(perspective, query = {}, _engine) {
1076
- const limitedQuery = { ...query, limit: 1 };
855
+ static async findOne(perspective, query) {
856
+ const limitedQuery = { ...(query ?? {}), limit: 1 };
1077
857
  const results = await this.findAll(perspective, limitedQuery);
1078
858
  return results[0] ?? null;
1079
859
  }
@@ -1082,7 +862,7 @@ export class Ad4mModel {
1082
862
  *
1083
863
  * @param perspective - The perspective to search in
1084
864
  * @param query - Optional query parameters to filter results
1085
- * @param useSPARQL - Whether to use SPARQL (default: true, 10-100x faster) or Prolog (legacy)
865
+ * @param _engine - **Deprecated.** Accepted for backward compatibility but ignored.
1086
866
  * @returns Object containing results array and total count
1087
867
  *
1088
868
  * @example
@@ -1092,13 +872,11 @@ export class Ad4mModel {
1092
872
  * limit: 10
1093
873
  * });
1094
874
  * console.log(`Showing 10 of ${totalCount} dessert recipes`);
1095
- *
1096
- * // Use Prolog explicitly (legacy)
1097
- * const { results, totalCount } = await Recipe.findAllAndCount(perspective, {}, false);
1098
875
  * ```
1099
876
  */
1100
- static async findAllAndCount(perspective, query = {}, _engine) {
1101
- return await this.executeModelQuery(perspective, query);
877
+ static async findAllAndCount(perspective, query) {
878
+ const out = await this.executeModelQuery(perspective, (query ?? {}));
879
+ return out;
1102
880
  }
1103
881
  /**
1104
882
  * Helper function for pagination with explicit page size and number.
@@ -1117,10 +895,10 @@ export class Ad4mModel {
1117
895
  * console.log(`Page ${page.pageNumber} of recipes, ${page.results.length} items`);
1118
896
  * ```
1119
897
  */
1120
- static async paginate(perspective, pageSize, pageNumber, query, _engine) {
1121
- const paginationQuery = { ...(query || {}), limit: pageSize, offset: pageSize * (pageNumber - 1), count: true };
898
+ static async paginate(perspective, pageSize, pageNumber, query) {
899
+ const paginationQuery = { ...(query ?? {}), limit: pageSize, offset: pageSize * (pageNumber - 1), count: true };
1122
900
  const { results, totalCount } = await this.executeModelQuery(perspective, paginationQuery);
1123
- return { results, totalCount, pageSize, pageNumber };
901
+ return { results: results, totalCount, pageSize, pageNumber };
1124
902
  }
1125
903
  /**
1126
904
  * Generates a SPARQL COUNT query for the model.
@@ -1147,8 +925,8 @@ export class Ad4mModel {
1147
925
  * });
1148
926
  * ```
1149
927
  */
1150
- static async count(perspective, query = {}) {
1151
- const { totalCount } = await this.executeModelQuery(perspective, { ...query, limit: 0 });
928
+ static async count(perspective, query) {
929
+ const { totalCount } = await this.executeModelQuery(perspective, { ...(query ?? {}), limit: 0 });
1152
930
  return totalCount;
1153
931
  }
1154
932
  async setProperty(key, value, batchId) {
@@ -1459,27 +1237,10 @@ export class Ad4mModel {
1459
1237
  if (instances.length === 0)
1460
1238
  return;
1461
1239
  const metadata = this.getModelMetadata();
1462
- // Pre-compute conformance getters so the shape sent to Rust includes them
1463
- const allRelMeta = getRelationsMetadata(this);
1464
- for (const [relName, relMeta] of Object.entries(metadata.relations)) {
1465
- const rel = relMeta;
1466
- if (rel.getter || rel.direction === 'reverse' || rel.filter === false)
1467
- continue;
1468
- const meta = allRelMeta[relName];
1469
- if (!meta?.target)
1470
- continue;
1471
- try {
1472
- const TargetClass = meta.target();
1473
- const filter = buildConformanceFilter(meta.predicate, TargetClass);
1474
- if (filter)
1475
- rel.getter = filter.getter;
1476
- }
1477
- catch (_) { /* target class may not be available */ }
1478
- }
1479
- const shapeJson = JSON.stringify(metadata);
1480
1240
  const instanceIds = instances.map(inst => inst.id || inst._baseExpression);
1481
- // Single RPC call evaluates all getters in-process on the executor
1482
- const result = await perspective.evaluateGetters(metadata.className, instanceIds, shapeJson, propertyNames);
1241
+ // The executor reads getter SPARQL from the perspective's SHACL triples
1242
+ // (written by `addSdna`), so no shape JSON is shipped with the call.
1243
+ const result = await perspective.evaluateGetters(metadata.className, instanceIds, propertyNames);
1483
1244
  // Determine which property names were evaluated for snapshot sync
1484
1245
  const evaluatedPropertyNames = [];
1485
1246
  for (const [propName, propMeta] of Object.entries(metadata.properties)) {
@@ -1770,6 +1531,22 @@ export class Ad4mModel {
1770
1531
  static async register(perspective) {
1771
1532
  await perspective.ensureSDNASubjectClass(this);
1772
1533
  }
1534
+ /**
1535
+ * Batch-registers multiple model classes on a perspective in a single RPC call.
1536
+ * This is significantly faster than calling `register()` on each model individually
1537
+ * because it eliminates N-1 round-trips and mutex acquisitions.
1538
+ *
1539
+ * @param perspective - The perspective to register the models on
1540
+ * @param models - Array of Ad4mModel subclasses to register
1541
+ *
1542
+ * @example
1543
+ * ```typescript
1544
+ * await Ad4mModel.registerAll(perspective, [Community, Channel, Message, Task]);
1545
+ * ```
1546
+ */
1547
+ static async registerAll(perspective, models) {
1548
+ await perspective.ensureSubjectClasses(models);
1549
+ }
1773
1550
  /**
1774
1551
  * Executes a set of model operations inside a single batch (transaction).
1775
1552
  *
@@ -1827,7 +1604,7 @@ export class Ad4mModel {
1827
1604
  * ```
1828
1605
  */
1829
1606
  static query(perspective, query) {
1830
- return new ModelQueryBuilder(perspective, this, query);
1607
+ return new ModelQueryBuilder(perspective, this, (query ?? {}));
1831
1608
  }
1832
1609
  /**
1833
1610
  * Creates an Ad4mModel class from a JSON Schema definition.