@coasys/ad4m 0.13.0-test-7 → 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 (264) hide show
  1. package/lib/index.cjs +1109 -828
  2. package/lib/index.js +1096 -828
  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 -36
  200. package/lib/src/model/Ad4mModel.js +93 -382
  201. package/lib/src/model/Ad4mModel.test.js +735 -480
  202. package/lib/src/model/ModelQueryBuilder.d.ts +5 -10
  203. package/lib/src/model/ModelQueryBuilder.js +142 -62
  204. package/lib/src/model/decorators.d.ts +7 -4
  205. package/lib/src/model/decorators.js +0 -7
  206. package/lib/src/model/query-sparql.d.ts +0 -10
  207. package/lib/src/model/query-sparql.js +10 -15
  208. package/lib/src/model/query-sparql.test.js +10 -92
  209. package/lib/src/model/query-surreal.d.ts +44 -0
  210. package/lib/src/model/query-surreal.js +249 -0
  211. package/lib/src/model/shacl-gen.js +120 -47
  212. package/lib/src/model/surreal-utils.d.ts +42 -0
  213. package/lib/src/model/surreal-utils.js +128 -0
  214. package/lib/src/model/types.d.ts +140 -4
  215. package/lib/src/neighbourhood/NeighbourhoodProxy.test.js +33 -33
  216. package/lib/src/perspectives/PerspectiveClient.d.ts +13 -4
  217. package/lib/src/perspectives/PerspectiveClient.js +22 -6
  218. package/lib/src/perspectives/PerspectiveProxy.d.ts +27 -7
  219. package/lib/src/perspectives/PerspectiveProxy.js +60 -12
  220. package/lib/src/perspectives/PerspectiveProxy.test.d.ts +1 -0
  221. package/lib/src/perspectives/PerspectiveProxy.test.js +34 -0
  222. package/lib/src/perspectives/SparqlBindings.d.ts +47 -0
  223. package/lib/src/perspectives/SparqlBindings.js +65 -0
  224. package/lib/src/perspectives/WakerSubscriptionManager.js +5 -4
  225. package/lib/src/restClient.d.ts +52 -0
  226. package/lib/src/restClient.js +227 -0
  227. package/lib/src/shacl/NodeExpression.d.ts +44 -0
  228. package/lib/src/shacl/NodeExpression.js +39 -0
  229. package/lib/src/shacl/SHACLShape.d.ts +23 -0
  230. package/lib/src/shacl/SHACLShape.js +115 -1
  231. package/lib/src/shacl/SHACLShape.test.js +0 -82
  232. package/lib/src/shacl/builders.d.ts +58 -0
  233. package/lib/src/shacl/builders.js +76 -0
  234. package/lib/src/shacl/index.d.ts +36 -0
  235. package/lib/src/shacl/index.js +33 -0
  236. package/package.json +11 -8
  237. package/src/Ad4mClient.ts +7 -2
  238. package/src/agent/AgentClient.ts +23 -0
  239. package/src/ai/AIClient.ts +1 -1
  240. package/src/apiClient.ts +17 -6
  241. package/src/index.ts +4 -0
  242. package/src/model/Ad4mModel.test.ts +274 -72
  243. package/src/model/Ad4mModel.ts +140 -420
  244. package/src/model/ModelQueryBuilder.ts +136 -71
  245. package/src/model/decorators.ts +7 -13
  246. package/src/model/query-sparql.test.ts +35 -19
  247. package/src/model/query-sparql.ts +10 -16
  248. package/src/model/relation-filtering.test.ts +46 -39
  249. package/src/model/shacl-gen.ts +128 -54
  250. package/src/model/shacl-roundtrip.test.ts +197 -0
  251. package/src/model/types-typed-query.test.ts +360 -0
  252. package/src/model/types.ts +196 -4
  253. package/src/perspectives/PerspectiveClient.ts +24 -8
  254. package/src/perspectives/PerspectiveProxy.test.ts +85 -1
  255. package/src/perspectives/PerspectiveProxy.ts +65 -20
  256. package/src/perspectives/SparqlBindings.ts +79 -0
  257. package/src/perspectives/WakerSubscriptionManager.ts +5 -4
  258. package/src/shacl/NodeExpression.ts +54 -0
  259. package/src/shacl/SHACLShape.test.ts +172 -0
  260. package/src/shacl/SHACLShape.ts +173 -1
  261. package/src/shacl/builders.ts +86 -0
  262. package/src/shacl/index.ts +72 -0
  263. package/lib/src/model/model-manifest.d.ts +0 -41
  264. package/lib/src/model/model-manifest.js +0 -11
@@ -2,97 +2,15 @@ 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";
9
9
  import { ModelQueryBuilder } from "./ModelQueryBuilder";
10
10
  import { normalizeValue, } from "./hydration";
11
11
  // ---------------------------------------------------------------------------
12
- // Default decoder for file-storage (non-literal resolveLanguage) properties
13
- // ---------------------------------------------------------------------------
14
- /**
15
- * When the Rust executor resolves a non-literal expression it may return a
16
- * `FileData`-shaped object (`{ data_base64, file_type, ... }`) rather than a
17
- * raw URI string. If the model class has no custom `transform` registered
18
- * (e.g. it was synthesised from a SHACL shape at runtime) we still want to
19
- * decode the content rather than passing raw `FileData` to callers.
20
- *
21
- * Decoding rules (mirrors the JS `decodeFileAsJson` / `decodeFileAsString` helpers):
22
- * - `application/json` (default when `file_type` is absent) → JSON.parse
23
- * - anything else → raw decoded string
24
- *
25
- * If `resolved` is not a `FileData` object the value is returned unchanged so
26
- * that callers can use this as a safe unconditional fallback.
27
- */
28
- function defaultFileDecode(resolved) {
29
- if (resolved !== null &&
30
- typeof resolved === 'object' &&
31
- 'data_base64' in resolved) {
32
- const fd = resolved;
33
- let raw;
34
- try {
35
- raw = atob(fd.data_base64);
36
- }
37
- catch {
38
- return resolved; // malformed base64 — keep as-is
39
- }
40
- const isJson = !fd.file_type || fd.file_type === 'application/json';
41
- if (isJson) {
42
- try {
43
- return JSON.parse(raw);
44
- }
45
- catch {
46
- return raw;
47
- }
48
- }
49
- return raw;
50
- }
51
- return resolved;
52
- }
53
- // ---------------------------------------------------------------------------
54
12
  // Helpers for Rust-side include resolution
55
13
  // ---------------------------------------------------------------------------
56
- /**
57
- * Recursively enrich relation metadata in the shape with target class shapes
58
- * so the Rust endpoint can resolve includes in-process (no extra GraphQL
59
- * round-trips per relation).
60
- */
61
- function enrichShapeForIncludes(metadata, include, allRelMeta) {
62
- for (const [relName, includeVal] of Object.entries(include)) {
63
- if (!includeVal)
64
- continue;
65
- const meta = allRelMeta[relName];
66
- if (!meta?.target)
67
- continue;
68
- const TargetClass = meta.target();
69
- // Deep-copy so we don't mutate the cached metadata
70
- const targetMeta = JSON.parse(JSON.stringify(TargetClass.getModelMetadata()));
71
- // Ensure the relation is in metadata.relations (fallback for edge cases)
72
- if (!metadata.relations[relName]) {
73
- metadata.relations[relName] = {
74
- name: relName,
75
- predicate: meta.predicate,
76
- direction: meta.kind === 'belongsToMany' || meta.kind === 'belongsToOne'
77
- ? 'reverse'
78
- : 'forward',
79
- };
80
- }
81
- const rel = metadata.relations[relName];
82
- rel.kind = meta.kind;
83
- rel.maxCount = meta.maxCount;
84
- rel.targetShape = targetMeta;
85
- rel.targetClassName = targetMeta.className;
86
- // Recurse for nested includes
87
- const nested = typeof includeVal === 'object' && includeVal !== null
88
- ? includeVal.include
89
- : undefined;
90
- if (nested) {
91
- const targetRelMeta = getRelationsMetadata(TargetClass);
92
- enrichShapeForIncludes(targetMeta, nested, targetRelMeta);
93
- }
94
- }
95
- }
96
14
  /**
97
15
  * Construct a model class instance from a plain JSON object returned by the
98
16
  * Rust endpoint. Recursively converts included relation values (which come
@@ -137,22 +55,6 @@ function jsonToModelInstance(ModelClass, perspective, json, include, properties)
137
55
  }
138
56
  instance[key] = value;
139
57
  }
140
- // Apply property transform functions from decorators (only for literal-resolved
141
- // or no-resolveLanguage properties; non-literal properties are resolved + transformed
142
- // asynchronously in executeModelQuery).
143
- try {
144
- const propsMeta = getPropertiesMetadata(ModelClass);
145
- for (const [propName, opts] of Object.entries(propsMeta)) {
146
- const o = opts;
147
- if (typeof o.transform !== 'function' || !(propName in json))
148
- continue;
149
- // Skip non-literal resolveLanguage props — they need async expression resolution first
150
- if (o.resolveLanguage != null && o.resolveLanguage !== 'literal')
151
- continue;
152
- instance[propName] = o.transform(instance[propName]);
153
- }
154
- }
155
- catch (_) { /* no metadata available */ }
156
58
  // Recursively convert included relation values to class instances
157
59
  if (include) {
158
60
  const relMeta = getRelationsMetadata(ModelClass);
@@ -390,8 +292,8 @@ export class Ad4mModel {
390
292
  ...(options.getter !== undefined && { getter: options.getter }),
391
293
  ...(options.prologSetter !== undefined && { prologSetter: options.prologSetter }),
392
294
  ...(options.local !== undefined && { local: options.local }),
393
- ...(options.transform !== undefined && { transform: options.transform }),
394
- ...(options.flag !== undefined && { flag: options.flag })
295
+ ...(options.flag !== undefined && { flag: options.flag }),
296
+ ...(options.transform !== undefined && { transform: options.transform })
395
297
  };
396
298
  }
397
299
  // Extract relations (relations) from WeakMap registry
@@ -576,6 +478,7 @@ export class Ad4mModel {
576
478
  * • `null` / empty object — skip ALL relations (used by bare
577
479
  * subscriptions that don't eagerly load relations).
578
480
  */
481
+ /** @internal */
579
482
  takeSnapshot(includedRelations) {
580
483
  const ctor = this.constructor;
581
484
  const metadata = ctor.getModelMetadata();
@@ -771,164 +674,14 @@ export class Ad4mModel {
771
674
  }
772
675
  /**
773
676
  * Build the JSON parameters needed for a model query/subscription endpoint.
774
- * 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.
775
679
  * @internal
776
680
  */
777
681
  static prepareModelQueryParams(query = {}, classNameOverride) {
778
- const metadata = this.getModelMetadata();
779
- const className = classNameOverride || metadata.className;
780
- const queryInput = {};
781
- if (query.parent) {
782
- const parentPredicate = resolveParentPredicate(query.parent, this);
783
- queryInput.parent = { id: query.parent.id, predicate: parentPredicate };
784
- }
785
- if (query.properties)
786
- queryInput.properties = query.properties;
787
- if (query.include)
788
- queryInput.include = query.include;
789
- if (query.where)
790
- queryInput.where = query.where;
791
- if (query.order) {
792
- queryInput.order = Object.entries(query.order).map(([k, v]) => [k, v]);
793
- }
794
- if (query.offset !== undefined)
795
- queryInput.offset = query.offset;
796
- if (query.limit !== undefined)
797
- queryInput.limit = query.limit;
798
- if (query.count !== undefined)
799
- queryInput.count = query.count;
800
- queryInput.deepQuery = query.deepQuery ?? true;
801
- if (query.include) {
802
- const allRelMeta = getRelationsMetadata(this);
803
- enrichShapeForIncludes(metadata, query.include, allRelMeta);
804
- }
805
- // Pre-compute conformance getters for Rust-side evaluation.
806
- // Where clauses are NOT compiled into getter SPARQL because stored
807
- // property values are signed expression envelopes (literal:json:...),
808
- // not simple literal:string:X values. Instead, where clauses are
809
- // attached as metadata for Rust-side post-evaluation filtering.
810
- {
811
- const allRelMeta = getRelationsMetadata(this);
812
- for (const [relName, relMeta] of Object.entries(metadata.relations)) {
813
- const rel = relMeta;
814
- if (rel.getter || rel.direction === 'reverse' || rel.filter === false)
815
- continue;
816
- const meta = allRelMeta[relName];
817
- if (!meta?.target)
818
- continue;
819
- try {
820
- const TargetClass = meta.target();
821
- const filter = buildConformanceFilter(meta.predicate, TargetClass);
822
- if (filter) {
823
- rel.getter = filter.getter;
824
- }
825
- // Attach where-clause metadata for Rust-side post-getter filtering
826
- if (rel.where) {
827
- try {
828
- const targetMetadata = TargetClass.getModelMetadata?.() ?? null;
829
- if (targetMetadata) {
830
- const predicates = {};
831
- for (const propName of Object.keys(rel.where)) {
832
- if (['id', 'author', 'timestamp'].includes(propName))
833
- continue;
834
- const propMeta = targetMetadata.properties[propName];
835
- if (propMeta?.predicate) {
836
- predicates[propName] = propMeta.predicate;
837
- }
838
- }
839
- if (Object.keys(predicates).length > 0) {
840
- rel.whereFilter = rel.where;
841
- rel.wherePredicates = predicates;
842
- }
843
- }
844
- }
845
- catch (_) { }
846
- }
847
- }
848
- catch (_) { }
849
- }
850
- }
851
- return {
852
- className,
853
- queryJson: JSON.stringify(queryInput),
854
- shapeJson: JSON.stringify(metadata),
855
- };
856
- }
857
- /**
858
- * Parse raw model query/subscription result JSON into typed model instances.
859
- * Used by ModelQueryBuilder to convert subscription updates without circular imports.
860
- * @internal
861
- */
862
- static parseModelResult(perspective, raw, include, properties) {
863
- const data = typeof raw === 'string' ? JSON.parse(raw) : raw;
864
- const arr = data.instances || data;
865
- if (!Array.isArray(arr))
866
- return [];
867
- return arr.map((json) => jsonToModelInstance(this, perspective, json, include, properties));
868
- }
869
- /**
870
- * Resolve non-literal (file-language) properties on an array of already-constructed
871
- * model instances. Handles two cases:
872
- *
873
- * 1. The Rust executor returned a raw URI string → fetch via `getExpression` then apply transform.
874
- * 2. The Rust executor already resolved the expression and returned a `FileData` object
875
- * (happens when the perspective backend eagerly fetches file content) → apply transform
876
- * (or `defaultFileDecode` if no transform is registered on the class, e.g. for SHACL-
877
- * synthesised model classes).
878
- *
879
- * Extracted as a public static so `ModelQueryBuilder.subscribe()` can reuse it without
880
- * duplicating logic or introducing a circular dependency.
881
- * @internal
882
- */
883
- static async resolveNonLiteralProps(perspective, instances) {
884
- const propsMeta = getPropertiesMetadata(this);
885
- const resolveProps = Object.entries(propsMeta).filter(([, opts]) => opts.resolveLanguage != null &&
886
- opts.resolveLanguage !== 'literal');
887
- if (resolveProps.length === 0)
888
- return;
889
- await Promise.all(instances.map(async (inst) => {
890
- for (const [propName, opts] of resolveProps) {
891
- const val = inst[propName];
892
- const transform = opts.transform;
893
- const applyTransform = (resolved) => typeof transform === 'function' ? transform(resolved) : defaultFileDecode(resolved);
894
- if (typeof val === 'string' && val && !val.startsWith('literal:')) {
895
- // Case 1: raw URI — fetch from language runtime
896
- try {
897
- const expression = await perspective.getExpression(val);
898
- if (expression) {
899
- let resolved;
900
- try {
901
- resolved = JSON.parse(expression.data);
902
- }
903
- catch {
904
- resolved = expression.data;
905
- }
906
- inst[propName] = applyTransform(resolved);
907
- }
908
- }
909
- catch (_) { /* resolution failed — keep raw value */ }
910
- }
911
- else if (val !== null && val !== undefined && typeof val === 'object') {
912
- // Case 2: already resolved by Rust — apply transform / default decode
913
- inst[propName] = applyTransform(val);
914
- }
915
- }
916
- }));
917
- }
918
- // instancesFromQueryResult — removed (superseded by Rust executeModelQuery pipeline)
919
- /**
920
- * Execute a model query via the executor-side endpoint.
921
- *
922
- * This replaces the old SPARQL-build → hydrate → JS-filter → JS-sort → JS-paginate pipeline
923
- * with a single RPC to the executor that handles everything in Rust.
924
- *
925
- * @internal
926
- */
927
- static async executeModelQuery(perspective, query = {}, classNameOverride) {
928
682
  const metadata = this.getModelMetadata();
929
683
  const className = classNameOverride || metadata.className;
930
684
  // Expand includeAll: true to a full IncludeMap covering every forward relation.
931
- // Done before queryInput is built so all downstream uses of query.include see the expansion.
932
685
  if (query.includeAll) {
933
686
  const allRelMeta = getRelationsMetadata(this);
934
687
  const expanded = {};
@@ -937,11 +690,8 @@ export class Ad4mModel {
937
690
  expanded[relName] = true;
938
691
  }
939
692
  }
940
- // Explicit include entries take precedence over the expansion
941
693
  query = { ...query, include: { ...expanded, ...query.include } };
942
694
  }
943
- // Build the query input that the Rust endpoint expects.
944
- // Convert the TS Query type to the executor's ModelQueryInput format.
945
695
  const queryInput = {};
946
696
  if (query.parent) {
947
697
  const parentPredicate = resolveParentPredicate(query.parent, this);
@@ -965,19 +715,23 @@ export class Ad4mModel {
965
715
  if (Object.keys(normalIncludes).length > 0)
966
716
  queryInput.include = normalIncludes;
967
717
  if (Object.keys(projections).length > 0) {
968
- // 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.
969
721
  const allRelMeta = getRelationsMetadata(this);
970
722
  for (const [, proj] of Object.entries(projections)) {
971
723
  const relMeta = allRelMeta[proj.from];
972
- if (!proj.targetShape && relMeta?.target) {
724
+ if (!proj.targetClassName && relMeta?.target) {
973
725
  try {
974
726
  const TargetClass = relMeta.target();
975
727
  const targetMeta = TargetClass.getModelMetadata?.();
976
- if (targetMeta) {
977
- proj.targetShape = targetMeta;
728
+ if (targetMeta?.className) {
729
+ proj.targetClassName = targetMeta.className;
978
730
  }
979
731
  }
980
- catch (_) { /* target class may not be available */ }
732
+ catch (e) {
733
+ console.debug(`prepareModelQueryParams: target class unavailable for projection:`, e);
734
+ }
981
735
  }
982
736
  }
983
737
  queryInput.projections = projections;
@@ -986,7 +740,6 @@ export class Ad4mModel {
986
740
  if (query.where)
987
741
  queryInput.where = query.where;
988
742
  if (query.order) {
989
- // Convert { propName: 'ASC' | 'DESC' } to [[propName, 'ASC'|'DESC'], ...]
990
743
  queryInput.order = Object.entries(query.order).map(([k, v]) => [k, v]);
991
744
  }
992
745
  if (query.offset !== undefined)
@@ -996,88 +749,52 @@ export class Ad4mModel {
996
749
  if (query.count !== undefined)
997
750
  queryInput.count = query.count;
998
751
  queryInput.deepQuery = query.deepQuery ?? true;
999
- // Enrich relation metadata with target class shapes for Rust-side
1000
- // include resolution. This eliminates per-relation GraphQL round-trips
1001
- // by letting the Rust endpoint resolve includes in-process.
1002
- if (queryInput.include) {
1003
- const allRelMeta = getRelationsMetadata(this);
1004
- enrichShapeForIncludes(metadata, queryInput.include, allRelMeta);
1005
- }
1006
- // ── Pre-compute conformance getters for Rust-side evaluation ──────
1007
- // For each relation with a target class and filter !== false, compute
1008
- // the conformance getter SPARQL so Rust can evaluate it in-process
1009
- // (eliminating N × querySparql round-trips per instance).
1010
- // When a relation has a `where` clause, compile the where conditions
1011
- // into the getter SPARQL so Rust applies them during evaluation.
1012
- {
1013
- const allRelMeta = getRelationsMetadata(this);
1014
- for (const [relName, relMeta] of Object.entries(metadata.relations)) {
1015
- const rel = relMeta;
1016
- if (rel.getter)
1017
- continue; // explicit getter already set
1018
- if (rel.direction === 'reverse')
1019
- continue; // reverse relations use reverse link lookup
1020
- if (rel.filter === false)
1021
- continue; // opt-out of conformance filtering
1022
- const meta = allRelMeta[relName];
1023
- if (!meta?.target)
1024
- continue;
1025
- try {
1026
- const TargetClass = meta.target();
1027
- const filter = buildConformanceFilter(meta.predicate, TargetClass);
1028
- if (filter) {
1029
- rel.getter = filter.getter;
1030
- }
1031
- // Attach where-clause metadata for Rust-side post-getter filtering.
1032
- // Property values are signed expression envelopes (literal:json:...)
1033
- // and cannot be matched by SPARQL FILTER on the raw IRI.
1034
- if (rel.where) {
1035
- try {
1036
- const targetMetadata = TargetClass.getModelMetadata?.() ?? null;
1037
- if (targetMetadata) {
1038
- const predicates = {};
1039
- for (const propName of Object.keys(rel.where)) {
1040
- if (['id', 'author', 'timestamp'].includes(propName))
1041
- continue;
1042
- const propMeta = targetMetadata.properties[propName];
1043
- if (propMeta?.predicate) {
1044
- predicates[propName] = propMeta.predicate;
1045
- }
1046
- }
1047
- if (Object.keys(predicates).length > 0) {
1048
- rel.whereFilter = rel.where;
1049
- rel.wherePredicates = predicates;
1050
- }
1051
- }
1052
- }
1053
- catch (_) { /* target metadata unavailable */ }
1054
- }
1055
- }
1056
- catch (e) {
1057
- // Target class may not be available; skip silently
1058
- }
1059
- }
1060
- }
1061
- // Send shape metadata to the executor so it knows the model structure.
1062
- // This is more reliable than reading SHACL from the store because
1063
- // the TS decorators are the definitive source of truth.
1064
- const shapeJson = JSON.stringify(metadata);
1065
- const queryJson = JSON.stringify(queryInput);
1066
- 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);
1067
787
  // Convert JSON instances to model class instances, recursively constructing
1068
788
  // class instances for any included relations resolved by Rust.
1069
789
  const instances = result.instances.map((json) => {
1070
790
  return jsonToModelInstance(this, perspective, json, query.include, query.properties);
1071
791
  });
1072
- // Resolve non-literal expressions (e.g. file languages where the stored
1073
- // value is a content-addressed hash that must be fetched from the language
1074
- // runtime). The Rust endpoint may return either a raw target URI (string)
1075
- // or an already-resolved FileData object — both cases are handled here.
1076
- await this.resolveNonLiteralProps(perspective, instances);
1077
- // Take snapshots for dirty tracking
1078
- 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;
1079
796
  for (const inst of instances) {
1080
- inst.takeSnapshot(snapshotRelations);
797
+ inst.takeSnapshot(snapshotRelations && Object.keys(snapshotRelations).length > 0 ? snapshotRelations : undefined);
1081
798
  }
1082
799
  return {
1083
800
  results: instances,
@@ -1089,15 +806,14 @@ export class Ad4mModel {
1089
806
  *
1090
807
  * @param perspective - The perspective to search in
1091
808
  * @param query - Optional query parameters to filter results
1092
- * @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.
1093
811
  * @returns Array of matching models
1094
812
  *
1095
813
  * @example
1096
814
  * ```typescript
1097
- * // Get all recipes (uses SPARQL by default)
1098
815
  * const allRecipes = await Recipe.findAll(perspective);
1099
816
  *
1100
- * // Get recipes with specific criteria (uses SPARQL)
1101
817
  * const recipes = await Recipe.findAll(perspective, {
1102
818
  * where: {
1103
819
  * name: "Pasta",
@@ -1106,16 +822,14 @@ export class Ad4mModel {
1106
822
  * order: { createdAt: "DESC" },
1107
823
  * limit: 10
1108
824
  * });
1109
- *
1110
- * // Explicitly use Prolog (legacy, for backward compatibility)
1111
- * const recipesProlog = await Recipe.findAll(perspective, {}, false);
1112
825
  * ```
1113
826
  */
1114
- static async findAll(perspective, query = {}, _engine) {
1115
- 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) {
1116
830
  throw new Error("properties[] must not be empty — omit the field to return all properties, or specify at least one field name");
1117
831
  }
1118
- const { results } = await this.executeModelQuery(perspective, query);
832
+ const { results } = await this.executeModelQuery(perspective, q);
1119
833
  return results;
1120
834
  }
1121
835
  /**
@@ -1125,7 +839,7 @@ export class Ad4mModel {
1125
839
  *
1126
840
  * @param perspective - The perspective to search in
1127
841
  * @param query - Optional query parameters to filter results
1128
- * @param useSPARQL - Whether to use SPARQL (default: true) or Prolog (legacy)
842
+ * @param _engine - **Deprecated.** Accepted for backward compatibility but ignored.
1129
843
  * @returns The first matching instance, or `null`
1130
844
  *
1131
845
  * @example
@@ -1138,8 +852,8 @@ export class Ad4mModel {
1138
852
  * }
1139
853
  * ```
1140
854
  */
1141
- static async findOne(perspective, query = {}, _engine) {
1142
- const limitedQuery = { ...query, limit: 1 };
855
+ static async findOne(perspective, query) {
856
+ const limitedQuery = { ...(query ?? {}), limit: 1 };
1143
857
  const results = await this.findAll(perspective, limitedQuery);
1144
858
  return results[0] ?? null;
1145
859
  }
@@ -1148,7 +862,7 @@ export class Ad4mModel {
1148
862
  *
1149
863
  * @param perspective - The perspective to search in
1150
864
  * @param query - Optional query parameters to filter results
1151
- * @param useSPARQL - Whether to use SPARQL (default: true, 10-100x faster) or Prolog (legacy)
865
+ * @param _engine - **Deprecated.** Accepted for backward compatibility but ignored.
1152
866
  * @returns Object containing results array and total count
1153
867
  *
1154
868
  * @example
@@ -1158,13 +872,11 @@ export class Ad4mModel {
1158
872
  * limit: 10
1159
873
  * });
1160
874
  * console.log(`Showing 10 of ${totalCount} dessert recipes`);
1161
- *
1162
- * // Use Prolog explicitly (legacy)
1163
- * const { results, totalCount } = await Recipe.findAllAndCount(perspective, {}, false);
1164
875
  * ```
1165
876
  */
1166
- static async findAllAndCount(perspective, query = {}, _engine) {
1167
- return await this.executeModelQuery(perspective, query);
877
+ static async findAllAndCount(perspective, query) {
878
+ const out = await this.executeModelQuery(perspective, (query ?? {}));
879
+ return out;
1168
880
  }
1169
881
  /**
1170
882
  * Helper function for pagination with explicit page size and number.
@@ -1183,10 +895,10 @@ export class Ad4mModel {
1183
895
  * console.log(`Page ${page.pageNumber} of recipes, ${page.results.length} items`);
1184
896
  * ```
1185
897
  */
1186
- static async paginate(perspective, pageSize, pageNumber, query, _engine) {
1187
- 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 };
1188
900
  const { results, totalCount } = await this.executeModelQuery(perspective, paginationQuery);
1189
- return { results, totalCount, pageSize, pageNumber };
901
+ return { results: results, totalCount, pageSize, pageNumber };
1190
902
  }
1191
903
  /**
1192
904
  * Generates a SPARQL COUNT query for the model.
@@ -1213,8 +925,8 @@ export class Ad4mModel {
1213
925
  * });
1214
926
  * ```
1215
927
  */
1216
- static async count(perspective, query = {}) {
1217
- 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 });
1218
930
  return totalCount;
1219
931
  }
1220
932
  async setProperty(key, value, batchId) {
@@ -1525,27 +1237,10 @@ export class Ad4mModel {
1525
1237
  if (instances.length === 0)
1526
1238
  return;
1527
1239
  const metadata = this.getModelMetadata();
1528
- // Pre-compute conformance getters so the shape sent to Rust includes them
1529
- const allRelMeta = getRelationsMetadata(this);
1530
- for (const [relName, relMeta] of Object.entries(metadata.relations)) {
1531
- const rel = relMeta;
1532
- if (rel.getter || rel.direction === 'reverse' || rel.filter === false)
1533
- continue;
1534
- const meta = allRelMeta[relName];
1535
- if (!meta?.target)
1536
- continue;
1537
- try {
1538
- const TargetClass = meta.target();
1539
- const filter = buildConformanceFilter(meta.predicate, TargetClass);
1540
- if (filter)
1541
- rel.getter = filter.getter;
1542
- }
1543
- catch (_) { /* target class may not be available */ }
1544
- }
1545
- const shapeJson = JSON.stringify(metadata);
1546
1240
  const instanceIds = instances.map(inst => inst.id || inst._baseExpression);
1547
- // Single RPC call evaluates all getters in-process on the executor
1548
- 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);
1549
1244
  // Determine which property names were evaluated for snapshot sync
1550
1245
  const evaluatedPropertyNames = [];
1551
1246
  for (const [propName, propMeta] of Object.entries(metadata.properties)) {
@@ -1836,6 +1531,22 @@ export class Ad4mModel {
1836
1531
  static async register(perspective) {
1837
1532
  await perspective.ensureSDNASubjectClass(this);
1838
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
+ }
1839
1550
  /**
1840
1551
  * Executes a set of model operations inside a single batch (transaction).
1841
1552
  *
@@ -1893,7 +1604,7 @@ export class Ad4mModel {
1893
1604
  * ```
1894
1605
  */
1895
1606
  static query(perspective, query) {
1896
- return new ModelQueryBuilder(perspective, this, query);
1607
+ return new ModelQueryBuilder(perspective, this, (query ?? {}));
1897
1608
  }
1898
1609
  /**
1899
1610
  * Creates an Ad4mModel class from a JSON Schema definition.