@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
@@ -1,4 +1,6 @@
1
1
  import { Link } from "../links/Links";
2
+ import type { NodeExpression } from "./NodeExpression";
3
+ import { isNodeExpression } from "./NodeExpression";
2
4
 
3
5
  /**
4
6
  * Extract namespace from a URI
@@ -179,6 +181,34 @@ export interface SHACLPropertyShape {
179
181
  * Each entry has a `value` (the RDF term) and an optional `label` (human-readable name).
180
182
  * Standard SHACL `sh:in` only defines values; labels are an AD4M extension. */
181
183
  in?: Array<{ value: string; label?: string }>;
184
+
185
+ /** AD4M-specific: kind of relation this property describes.
186
+ * Drives direction (forward/reverse), scalar-vs-collection rendering,
187
+ * and default max-count. */
188
+ relationKind?: 'hasMany' | 'hasOne' | 'belongsToOne' | 'belongsToMany';
189
+
190
+ /** AD4M-specific: target class name (local-name) for a relation property.
191
+ * Complements `class` (the SHACL node-shape URI) by providing the bare
192
+ * model class name used by the executor to look up the target shape
193
+ * through the perspective's shape cache. */
194
+ targetClassName?: string;
195
+
196
+ /** AD4M-specific: post-getter where-clause filter for a relation property. */
197
+ whereFilter?: any;
198
+
199
+ /** AD4M-specific: predicate-IRI lookup map for `whereFilter` keys
200
+ * (property name → predicate URI on the target class). */
201
+ wherePredicates?: Record<string, string>;
202
+
203
+ /** AD4M-specific: whether conformance/type filtering is enabled for this
204
+ * relation. `false` opts out of DB-level type filtering while keeping
205
+ * hydration via `include`. */
206
+ filter?: boolean;
207
+
208
+ /** AD4M-specific: Transform expression (SHACL-AF Node Expression).
209
+ * Applied to resolved property values in the Rust model query engine.
210
+ * Only used for properties with resolveLanguage set. */
211
+ transform?: NodeExpression;
182
212
  }
183
213
 
184
214
  /**
@@ -494,7 +524,7 @@ export class SHACLShape {
494
524
  });
495
525
  }
496
526
 
497
- if (prop.resolveLanguage) {
527
+ if (prop.resolveLanguage != null) {
498
528
  links.push({
499
529
  source: propShapeId,
500
530
  predicate: "ad4m://resolveLanguage",
@@ -558,6 +588,54 @@ export class SHACLShape {
558
588
  target: `literal:string:${JSON.stringify(prop.in)}`
559
589
  });
560
590
  }
591
+
592
+ if (prop.relationKind) {
593
+ links.push({
594
+ source: propShapeId,
595
+ predicate: "ad4m://relationKind",
596
+ target: `literal:string:${prop.relationKind}`
597
+ });
598
+ }
599
+
600
+ if (prop.targetClassName) {
601
+ links.push({
602
+ source: propShapeId,
603
+ predicate: "ad4m://targetClassName",
604
+ target: `literal:string:${prop.targetClassName}`
605
+ });
606
+ }
607
+
608
+ if (prop.whereFilter !== undefined && prop.whereFilter !== null) {
609
+ links.push({
610
+ source: propShapeId,
611
+ predicate: "ad4m://whereFilter",
612
+ target: `literal:string:${JSON.stringify(prop.whereFilter)}`
613
+ });
614
+ }
615
+
616
+ if (prop.wherePredicates && Object.keys(prop.wherePredicates).length > 0) {
617
+ links.push({
618
+ source: propShapeId,
619
+ predicate: "ad4m://wherePredicates",
620
+ target: `literal:string:${JSON.stringify(prop.wherePredicates)}`
621
+ });
622
+ }
623
+
624
+ if (prop.filter !== undefined) {
625
+ links.push({
626
+ source: propShapeId,
627
+ predicate: "ad4m://filter",
628
+ target: `literal:${prop.filter}`
629
+ });
630
+ }
631
+
632
+ if (prop.transform && typeof prop.transform === 'object') {
633
+ links.push({
634
+ source: propShapeId,
635
+ predicate: "ad4m://transform",
636
+ target: `literal:string:${JSON.stringify(prop.transform)}`
637
+ });
638
+ }
561
639
  }
562
640
 
563
641
  return links;
@@ -800,6 +878,80 @@ export class SHACLShape {
800
878
  }
801
879
  }
802
880
 
881
+ const relationKindLink = links.find(l =>
882
+ l.source === propShapeId && l.predicate === "ad4m://relationKind"
883
+ );
884
+ if (relationKindLink) {
885
+ const val = relationKindLink.target.replace(/^literal:\/\/string:|^literal:string:/, '');
886
+ if (val === 'hasMany' || val === 'hasOne' || val === 'belongsToOne' || val === 'belongsToMany') {
887
+ prop.relationKind = val;
888
+ }
889
+ }
890
+
891
+ const targetClassNameLink = links.find(l =>
892
+ l.source === propShapeId && l.predicate === "ad4m://targetClassName"
893
+ );
894
+ if (targetClassNameLink) {
895
+ prop.targetClassName = targetClassNameLink.target.replace(
896
+ /^literal:\/\/string:|^literal:string:/, ''
897
+ );
898
+ }
899
+
900
+ const whereFilterLink = links.find(l =>
901
+ l.source === propShapeId && l.predicate === "ad4m://whereFilter"
902
+ );
903
+ if (whereFilterLink) {
904
+ try {
905
+ const jsonStr = whereFilterLink.target.replace(/^literal:\/\/string:|^literal:string:/, '');
906
+ prop.whereFilter = JSON.parse(jsonStr);
907
+ } catch (e) {
908
+ // Ignore parse errors
909
+ }
910
+ }
911
+
912
+ const wherePredicatesLink = links.find(l =>
913
+ l.source === propShapeId && l.predicate === "ad4m://wherePredicates"
914
+ );
915
+ if (wherePredicatesLink) {
916
+ try {
917
+ const jsonStr = wherePredicatesLink.target.replace(/^literal:\/\/string:|^literal:string:/, '');
918
+ prop.wherePredicates = JSON.parse(jsonStr);
919
+ } catch (e) {
920
+ // Ignore parse errors
921
+ }
922
+ }
923
+
924
+ const filterLink = links.find(l =>
925
+ l.source === propShapeId && l.predicate === "ad4m://filter"
926
+ );
927
+ if (filterLink) {
928
+ let val = filterLink.target.replace(/^literal:\/\/|^literal:/, '');
929
+ if (val.startsWith('boolean:')) val = val.substring(8);
930
+ prop.filter = val === 'true';
931
+ }
932
+
933
+ const transformLink = links.find(l =>
934
+ l.source === propShapeId && l.predicate === "ad4m://transform"
935
+ );
936
+ if (transformLink) {
937
+ const jsonStr = transformLink.target.replace(/^literal:\/\/string:|^literal:string:/, '');
938
+ try {
939
+ const parsed = JSON.parse(jsonStr);
940
+ if (!isNodeExpression(parsed)) {
941
+ throw new Error(
942
+ `Invalid transform for property ${propShapeId}: ` +
943
+ `payload is not a valid NodeExpression. Received: ${jsonStr}`
944
+ );
945
+ }
946
+ prop.transform = parsed;
947
+ } catch (e) {
948
+ throw new Error(
949
+ `Failed to deserialize transform for property ${propShapeId}: ` +
950
+ `${e instanceof Error ? e.message : String(e)}. Payload: ${jsonStr}`
951
+ );
952
+ }
953
+ }
954
+
803
955
  shape.addProperty(prop);
804
956
  }
805
957
 
@@ -838,6 +990,12 @@ export class SHACLShape {
838
990
  conformance_conditions: p.conformanceConditions,
839
991
  class: p.class,
840
992
  in: p.in,
993
+ relation_kind: p.relationKind,
994
+ target_class_name: p.targetClassName,
995
+ where_filter: p.whereFilter,
996
+ where_predicates: p.wherePredicates,
997
+ filter: p.filter,
998
+ transform: p.transform,
841
999
  })),
842
1000
  constructor_actions: this.constructor_actions,
843
1001
  destructor_actions: this.destructor_actions,
@@ -853,6 +1011,14 @@ export class SHACLShape {
853
1011
  : new SHACLShape(json.target_class);
854
1012
 
855
1013
  for (const p of json.properties || []) {
1014
+ // Validate transform if present
1015
+ if (p.transform && !isNodeExpression(p.transform)) {
1016
+ throw new Error(
1017
+ `Invalid transform for property ${p.name}: ` +
1018
+ `payload is not a valid NodeExpression. Received: ${JSON.stringify(p.transform)}`
1019
+ );
1020
+ }
1021
+
856
1022
  shape.addProperty({
857
1023
  path: p.path,
858
1024
  name: p.name,
@@ -874,6 +1040,12 @@ export class SHACLShape {
874
1040
  conformanceConditions: p.conformance_conditions,
875
1041
  class: p.class,
876
1042
  in: p.in,
1043
+ relationKind: p.relation_kind,
1044
+ targetClassName: p.target_class_name,
1045
+ whereFilter: p.where_filter,
1046
+ wherePredicates: p.where_predicates,
1047
+ filter: p.filter,
1048
+ transform: p.transform,
877
1049
  });
878
1050
  }
879
1051
 
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Builder functions for SHACL-AF Node Expressions.
3
+ *
4
+ * These functions construct JSON-serializable expression trees for property transforms.
5
+ * All builders return frozen objects to prevent accidental mutation.
6
+ */
7
+
8
+ import type { NodeExpression } from './NodeExpression';
9
+
10
+ /**
11
+ * Identity expression: pass the focus node through unchanged.
12
+ */
13
+ export function focus(): NodeExpression {
14
+ return Object.freeze({ type: 'focus' });
15
+ }
16
+
17
+ /**
18
+ * Literal constant expression.
19
+ */
20
+ export function literal(value: string | number | boolean): NodeExpression {
21
+ return Object.freeze({ type: 'literal', value });
22
+ }
23
+
24
+ /**
25
+ * Path expression: navigate to a property on the resolved object.
26
+ * The predicate can be a full IRI (e.g., "file_storage://data_base64")
27
+ * or a simple property name. The Rust evaluator will strip the namespace.
28
+ */
29
+ export function path(predicate: string): NodeExpression {
30
+ return Object.freeze({ type: 'path', predicate });
31
+ }
32
+
33
+ /**
34
+ * Existence check: returns true if the inner expression is non-null and non-empty.
35
+ */
36
+ export function exists(expr: NodeExpression): NodeExpression {
37
+ return Object.freeze({ type: 'exists', expr });
38
+ }
39
+
40
+ /**
41
+ * Conditional expression with optional else branch.
42
+ * Returns a chainable builder that supports `.then()` and `.else()`.
43
+ */
44
+ export function ifExpr(cond: NodeExpression) {
45
+ return {
46
+ then: (thenExpr: NodeExpression) => ({
47
+ else: (elseExpr?: NodeExpression) => {
48
+ return Object.freeze({
49
+ type: 'if',
50
+ cond,
51
+ then: thenExpr,
52
+ ...(elseExpr !== undefined && { else: elseExpr }),
53
+ } as const);
54
+ },
55
+ // Allow chaining without explicit else()
56
+ toExpression: () => Object.freeze({
57
+ type: 'if',
58
+ cond,
59
+ then: thenExpr,
60
+ } as const),
61
+ }),
62
+ };
63
+ }
64
+
65
+ /**
66
+ * String concatenation: joins evaluated arguments as strings.
67
+ * Null/undefined arguments are skipped.
68
+ */
69
+ export function concat(...args: NodeExpression[]): NodeExpression {
70
+ return Object.freeze({ type: 'concat', args });
71
+ }
72
+
73
+ /**
74
+ * Coalesce: returns the first non-null evaluated argument.
75
+ */
76
+ export function coalesce(...args: NodeExpression[]): NodeExpression {
77
+ return Object.freeze({ type: 'coalesce', args });
78
+ }
79
+
80
+ /**
81
+ * Function call: invoke a named transform function by IRI.
82
+ * Primarily used for built-in functions like "ad4m://fn/defaultFileDecode".
83
+ */
84
+ export function fn(iri: string, args: NodeExpression[] = []): NodeExpression {
85
+ return Object.freeze({ type: 'function', iri, args });
86
+ }
@@ -0,0 +1,72 @@
1
+ /**
2
+ * SHACL-AF Transform DSL — public API
3
+ *
4
+ * Re-exports builder functions and provides common built-in transforms.
5
+ */
6
+
7
+ import {
8
+ focus,
9
+ literal,
10
+ path,
11
+ exists,
12
+ ifExpr,
13
+ concat,
14
+ coalesce,
15
+ fn,
16
+ } from './builders';
17
+
18
+ export type { NodeExpression } from './NodeExpression';
19
+ export { isNodeExpression } from './NodeExpression';
20
+
21
+ export {
22
+ focus,
23
+ literal,
24
+ path,
25
+ exists,
26
+ ifExpr,
27
+ concat,
28
+ coalesce,
29
+ fn,
30
+ };
31
+
32
+ /**
33
+ * Built-in transform: FileData → data: URI
34
+ *
35
+ * Converts a file stored via FILE_STORAGE_LANGUAGE into a data: URL.
36
+ * If the object has a `data_base64` field, returns:
37
+ * `data:{file_type};base64,{data_base64}`
38
+ * Otherwise passes through the input unchanged.
39
+ *
40
+ * This is the Rust equivalent of the JS `defaultFileDecode` function.
41
+ *
42
+ * Usage:
43
+ * ```typescript
44
+ * @Property({
45
+ * through: 'we://image',
46
+ * resolveLanguage: FILE_STORAGE_LANGUAGE,
47
+ * transform: fileToDataUri,
48
+ * })
49
+ * avatar?: string;
50
+ * ```
51
+ */
52
+ export const fileToDataUri = ifExpr(exists(path('file_storage://data_base64')))
53
+ .then(
54
+ concat(
55
+ literal('data:'),
56
+ coalesce(
57
+ path('file_storage://file_type'),
58
+ literal('image/png'),
59
+ ),
60
+ literal(';base64,'),
61
+ path('file_storage://data_base64'),
62
+ ),
63
+ )
64
+ .else(focus());
65
+
66
+ // Re-export SHACL types for convenience
67
+ export {
68
+ SHACLShape,
69
+ SHACLPropertyShape,
70
+ AD4MAction,
71
+ ConformanceCondition,
72
+ } from './SHACLShape';
@@ -1,41 +0,0 @@
1
- /**
2
- * Types for the perspective model manifest — a human-readable, AI-friendly summary
3
- * of all Ad4mModel-compatible classes defined in a perspective's SHACL shapes.
4
- *
5
- * Used by `PerspectiveProxy.getModelManifest()` and consumed by WE's AI context
6
- * injection (`formatManifestForPrompt`) to describe external perspective models
7
- * to the schema-generation AI.
8
- *
9
- * @module
10
- */
11
- /** Normalised description of a single property on a model class. */
12
- export interface ModelManifestProperty {
13
- /** Property name as declared in the SHACL shape (e.g. "name", "body", "participants"). */
14
- name: string;
15
- /** The exact RDF predicate URI (e.g. "flux://has_name"). */
16
- predicate: string;
17
- /** Normalised scalar type; inferred from xsd:/sh: datatype + nodeKind. */
18
- type: 'string' | 'number' | 'boolean' | 'uri';
19
- /** `true` when maxCount is absent or > 1 (i.e. returned as an array). */
20
- isCollection: boolean;
21
- /** `true` when minCount >= 1. */
22
- required: boolean;
23
- writable: boolean;
24
- /** AD4M language used to resolve the value (e.g. "literal"). */
25
- resolveLanguage?: string;
26
- /**
27
- * Local name of the related model class when this is a typed relation property.
28
- * Derived from `SHACLPropertyShape.class` by stripping the URI prefix.
29
- * E.g. `flux://Message` → `"Message"`.
30
- */
31
- relatedModel?: string;
32
- }
33
- /** Normalised description of a single model class stored in a perspective. */
34
- export interface ModelManifestEntry {
35
- /** Class name — usable directly as the `model` field in a `$query` token. */
36
- name: string;
37
- /** The SHACL `targetClass` URI (e.g. "flux://Channel"). */
38
- targetClass: string;
39
- /** All data properties (flag/hasValue properties are excluded). */
40
- properties: ModelManifestProperty[];
41
- }
@@ -1,11 +0,0 @@
1
- /**
2
- * Types for the perspective model manifest — a human-readable, AI-friendly summary
3
- * of all Ad4mModel-compatible classes defined in a perspective's SHACL shapes.
4
- *
5
- * Used by `PerspectiveProxy.getModelManifest()` and consumed by WE's AI context
6
- * injection (`formatManifestForPrompt`) to describe external perspective models
7
- * to the schema-generation AI.
8
- *
9
- * @module
10
- */
11
- export {};