@coasys/ad4m 0.12.1-dev → 0.13.0-postmessage-ws-proxy.3
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.
- package/README.md +2 -25
- package/jest-setup.ts +1 -1
- package/lib/index.cjs +8677 -15318
- package/lib/index.js +14507 -21223
- package/lib/src/Ad4mClient.d.ts +9 -3
- package/lib/src/Ad4mClient.js +40 -13
- package/lib/src/Literal.js +6 -5
- package/lib/src/agent/Agent.js +26 -272
- package/lib/src/agent/AgentClient.d.ts +33 -21
- package/lib/src/agent/AgentClient.js +180 -374
- package/lib/src/agent/AgentStatus.js +2 -37
- package/lib/src/ai/AIClient.d.ts +12 -4
- package/lib/src/ai/AIClient.js +81 -285
- package/lib/src/ai/AITypes.d.ts +55 -0
- package/lib/src/ai/AITypes.js +18 -0
- package/lib/src/ai/Tasks.js +10 -133
- package/lib/src/apiClient.d.ts +53 -0
- package/lib/src/apiClient.js +234 -0
- package/lib/src/cache/PersistentCache.d.ts +40 -0
- package/lib/src/cache/PersistentCache.js +139 -0
- package/lib/src/expression/Expression.d.ts +1 -1
- package/lib/src/expression/Expression.js +13 -122
- package/lib/src/expression/ExpressionClient.d.ts +11 -3
- package/lib/src/expression/ExpressionClient.js +120 -75
- package/lib/src/expression/ExpressionRef.js +4 -27
- package/lib/src/generated/api/AIModelLoadingStatus.d.ts +7 -0
- package/lib/src/generated/api/AIModelLoadingStatus.js +2 -0
- package/lib/src/generated/api/AddLinkExpressionRequest.d.ts +6 -0
- package/lib/src/generated/api/AddLinkExpressionRequest.js +1 -0
- package/lib/src/generated/api/AddLinkRequest.d.ts +6 -0
- package/lib/src/generated/api/AddLinkRequest.js +1 -0
- package/lib/src/generated/api/AddLinksBulkRequest.d.ts +6 -0
- package/lib/src/generated/api/AddLinksBulkRequest.js +1 -0
- package/lib/src/generated/api/AddSdnaRequest.d.ts +6 -0
- package/lib/src/generated/api/AddSdnaRequest.js +2 -0
- package/lib/src/generated/api/ApplyTemplateRequest.d.ts +4 -0
- package/lib/src/generated/api/ApplyTemplateRequest.js +2 -0
- package/lib/src/generated/api/AuthInfoInput.d.ts +10 -0
- package/lib/src/generated/api/AuthInfoInput.js +1 -0
- package/lib/src/generated/api/CapabilityInput.d.ts +5 -0
- package/lib/src/generated/api/CapabilityInput.js +1 -0
- package/lib/src/generated/api/CommitBatchRequest.d.ts +3 -0
- package/lib/src/generated/api/CommitBatchRequest.js +2 -0
- package/lib/src/generated/api/ComputeLogEntry.d.ts +9 -0
- package/lib/src/generated/api/ComputeLogEntry.js +2 -0
- package/lib/src/generated/api/CreateExpressionRequest.d.ts +4 -0
- package/lib/src/generated/api/CreateExpressionRequest.js +2 -0
- package/lib/src/generated/api/CreatePerspectiveRequest.d.ts +3 -0
- package/lib/src/generated/api/CreatePerspectiveRequest.js +2 -0
- package/lib/src/generated/api/CreateSubjectRequest.d.ts +6 -0
- package/lib/src/generated/api/CreateSubjectRequest.js +2 -0
- package/lib/src/generated/api/EmbedRequest.d.ts +4 -0
- package/lib/src/generated/api/EmbedRequest.js +2 -0
- package/lib/src/generated/api/EntanglementProofInput.d.ts +6 -0
- package/lib/src/generated/api/EntanglementProofInput.js +2 -0
- package/lib/src/generated/api/ExecuteCommandsRequest.d.ts +4 -0
- package/lib/src/generated/api/ExecuteCommandsRequest.js +2 -0
- package/lib/src/generated/api/ExportRequest.d.ts +5 -0
- package/lib/src/generated/api/ExportRequest.js +2 -0
- package/lib/src/generated/api/ExpressionManyRequest.d.ts +3 -0
- package/lib/src/generated/api/ExpressionManyRequest.js +2 -0
- package/lib/src/generated/api/ExpressionProof.d.ts +4 -0
- package/lib/src/generated/api/ExpressionProof.js +2 -0
- package/lib/src/generated/api/ExpressionProofInput.d.ts +6 -0
- package/lib/src/generated/api/ExpressionProofInput.js +2 -0
- package/lib/src/generated/api/FriendSendMessageRequest.d.ts +3 -0
- package/lib/src/generated/api/FriendSendMessageRequest.js +2 -0
- package/lib/src/generated/api/FriendsListRequest.d.ts +3 -0
- package/lib/src/generated/api/FriendsListRequest.js +2 -0
- package/lib/src/generated/api/GenerateAgentRequest.d.ts +3 -0
- package/lib/src/generated/api/GenerateAgentRequest.js +2 -0
- package/lib/src/generated/api/GenerateJwtRequest.d.ts +4 -0
- package/lib/src/generated/api/GenerateJwtRequest.js +2 -0
- package/lib/src/generated/api/GetSubjectDataRequest.d.ts +4 -0
- package/lib/src/generated/api/GetSubjectDataRequest.js +2 -0
- package/lib/src/generated/api/ImportAgentRequest.d.ts +6 -0
- package/lib/src/generated/api/ImportAgentRequest.js +2 -0
- package/lib/src/generated/api/ImportRequest.d.ts +4 -0
- package/lib/src/generated/api/ImportRequest.js +2 -0
- package/lib/src/generated/api/JoinNeighbourhoodRequest.d.ts +3 -0
- package/lib/src/generated/api/JoinNeighbourhoodRequest.js +2 -0
- package/lib/src/generated/api/LanguageMetaInput.d.ts +6 -0
- package/lib/src/generated/api/LanguageMetaInput.js +2 -0
- package/lib/src/generated/api/Link.d.ts +5 -0
- package/lib/src/generated/api/Link.js +2 -0
- package/lib/src/generated/api/LinkExpression.d.ts +10 -0
- package/lib/src/generated/api/LinkExpression.js +1 -0
- package/lib/src/generated/api/LinkExpressionInput.d.ts +10 -0
- package/lib/src/generated/api/LinkExpressionInput.js +1 -0
- package/lib/src/generated/api/LinkInput.d.ts +5 -0
- package/lib/src/generated/api/LinkInput.js +2 -0
- package/lib/src/generated/api/LinkLanguageTemplatesRequest.d.ts +3 -0
- package/lib/src/generated/api/LinkLanguageTemplatesRequest.js +2 -0
- package/lib/src/generated/api/LinkMutations.d.ts +6 -0
- package/lib/src/generated/api/LinkMutations.js +1 -0
- package/lib/src/generated/api/LinkStatus.d.ts +1 -0
- package/lib/src/generated/api/LinkStatus.js +2 -0
- package/lib/src/generated/api/LockAgentRequest.d.ts +3 -0
- package/lib/src/generated/api/LockAgentRequest.js +2 -0
- package/lib/src/generated/api/ModelType.d.ts +1 -0
- package/lib/src/generated/api/ModelType.js +2 -0
- package/lib/src/generated/api/NotificationInput.d.ts +10 -0
- package/lib/src/generated/api/NotificationInput.js +2 -0
- package/lib/src/generated/api/OpenLinkRequest.d.ts +3 -0
- package/lib/src/generated/api/OpenLinkRequest.js +2 -0
- package/lib/src/generated/api/PermitCapabilityRequest.d.ts +3 -0
- package/lib/src/generated/api/PermitCapabilityRequest.js +2 -0
- package/lib/src/generated/api/PerspectiveInput.d.ts +4 -0
- package/lib/src/generated/api/PerspectiveInput.js +1 -0
- package/lib/src/generated/api/PromptRequest.d.ts +4 -0
- package/lib/src/generated/api/PromptRequest.js +2 -0
- package/lib/src/generated/api/PublishLanguageRequest.d.ts +5 -0
- package/lib/src/generated/api/PublishLanguageRequest.js +1 -0
- package/lib/src/generated/api/PublishNeighbourhoodRequest.d.ts +6 -0
- package/lib/src/generated/api/PublishNeighbourhoodRequest.js +1 -0
- package/lib/src/generated/api/QueryRequest.d.ts +7 -0
- package/lib/src/generated/api/QueryRequest.js +2 -0
- package/lib/src/generated/api/RemoveLinkRequest.d.ts +5 -0
- package/lib/src/generated/api/RemoveLinkRequest.js +1 -0
- package/lib/src/generated/api/RemoveLinksBulkRequest.d.ts +5 -0
- package/lib/src/generated/api/RemoveLinksBulkRequest.js +1 -0
- package/lib/src/generated/api/ResourceInput.d.ts +4 -0
- package/lib/src/generated/api/ResourceInput.js +2 -0
- package/lib/src/generated/api/SetDefaultModelRequest.d.ts +4 -0
- package/lib/src/generated/api/SetDefaultModelRequest.js +1 -0
- package/lib/src/generated/api/SetFreeHostingEnabledRequest.d.ts +3 -0
- package/lib/src/generated/api/SetFreeHostingEnabledRequest.js +2 -0
- package/lib/src/generated/api/SetMultiUserRequest.d.ts +3 -0
- package/lib/src/generated/api/SetMultiUserRequest.js +2 -0
- package/lib/src/generated/api/SetStatusRequest.d.ts +3 -0
- package/lib/src/generated/api/SetStatusRequest.js +2 -0
- package/lib/src/generated/api/SignMessageRequest.d.ts +3 -0
- package/lib/src/generated/api/SignMessageRequest.js +2 -0
- package/lib/src/generated/api/TrustedAgentsRequest.d.ts +3 -0
- package/lib/src/generated/api/TrustedAgentsRequest.js +2 -0
- package/lib/src/generated/api/UnlockAgentRequest.d.ts +4 -0
- package/lib/src/generated/api/UnlockAgentRequest.js +2 -0
- package/lib/src/generated/api/UpdateLinkRequest.d.ts +7 -0
- package/lib/src/generated/api/UpdateLinkRequest.js +1 -0
- package/lib/src/generated/api/UpdatePerspectiveRequest.d.ts +3 -0
- package/lib/src/generated/api/UpdatePerspectiveRequest.js +2 -0
- package/lib/src/generated/api/UserStatistics.d.ts +9 -0
- package/lib/src/generated/api/UserStatistics.js +2 -0
- package/lib/src/generated/api/VerificationRequestResult.d.ts +6 -0
- package/lib/src/generated/api/VerificationRequestResult.js +2 -0
- package/lib/src/generated/api/VerifySignatureRequest.d.ts +5 -0
- package/lib/src/generated/api/VerifySignatureRequest.js +2 -0
- package/lib/src/generated/api/WriteSettingsRequest.d.ts +3 -0
- package/lib/src/generated/api/WriteSettingsRequest.js +2 -0
- package/lib/src/generated/api/index.d.ts +42 -0
- package/lib/src/generated/api/index.js +7 -0
- package/lib/src/index.d.ts +8 -2
- package/lib/src/index.js +8 -2
- package/lib/src/jestSetup.d.ts +0 -1
- package/lib/src/jestSetup.js +1 -1
- package/lib/src/language/Icon.js +2 -21
- package/lib/src/language/Language.d.ts +26 -176
- package/lib/src/language/Language.js +32 -72
- package/lib/src/language/LanguageClient.d.ts +2 -2
- package/lib/src/language/LanguageClient.js +15 -105
- package/lib/src/language/LanguageHandle.js +2 -41
- package/lib/src/language/LanguageMeta.js +4 -75
- package/lib/src/language/LanguageRef.js +2 -25
- package/lib/src/links/Links.js +14 -111
- package/lib/src/model/Ad4mModel.d.ts +143 -63
- package/lib/src/model/Ad4mModel.js +583 -425
- package/lib/src/model/Ad4mModel.test.js +1434 -688
- package/lib/src/model/ModelQueryBuilder.d.ts +61 -45
- package/lib/src/model/ModelQueryBuilder.js +315 -157
- package/lib/src/model/Subject.js +6 -6
- package/lib/src/model/decorators.d.ts +36 -8
- package/lib/src/model/decorators.js +41 -14
- package/lib/src/model/hydration-batch.d.ts +34 -0
- package/lib/src/model/hydration-batch.js +147 -0
- package/lib/src/model/hydration-batching.test.d.ts +7 -0
- package/lib/src/model/hydration-batching.test.js +456 -0
- package/lib/src/model/hydration.d.ts +3 -92
- package/lib/src/model/hydration.js +3 -691
- package/lib/src/model/index.d.ts +3 -4
- package/lib/src/model/index.js +3 -4
- package/lib/src/model/json-schema.js +2 -2
- package/lib/src/model/model-manifest.d.ts +41 -0
- package/lib/src/model/model-manifest.js +11 -0
- package/lib/src/model/query-cache.d.ts +30 -0
- package/lib/src/model/query-cache.js +66 -0
- package/lib/src/model/query-cache.test.d.ts +1 -0
- package/lib/src/model/query-cache.test.js +43 -0
- package/lib/src/model/query-common.d.ts +1 -1
- package/lib/src/model/query-common.js +1 -1
- package/lib/src/model/query-sparql-batch.d.ts +17 -0
- package/lib/src/model/query-sparql-batch.js +260 -0
- package/lib/src/model/query-sparql.d.ts +51 -0
- package/lib/src/model/query-sparql.js +466 -0
- package/lib/src/model/query-sparql.test.d.ts +1 -0
- package/lib/src/model/query-sparql.test.js +312 -0
- package/lib/src/model/{surreal-utils.d.ts → query-utils.d.ts} +13 -9
- package/lib/src/model/query-utils.js +189 -0
- package/lib/src/model/relation-filtering.test.js +15 -15
- package/lib/src/model/sdna.js +1 -1
- package/lib/src/model/shacl-gen.js +154 -57
- package/lib/src/model/subscription-delta.test.d.ts +24 -0
- package/lib/src/model/subscription-delta.test.js +180 -0
- package/lib/src/model/subscription-pool.d.ts +39 -0
- package/lib/src/model/subscription-pool.js +165 -0
- package/lib/src/model/types.d.ts +195 -5
- package/lib/src/model/types.js +5 -2
- package/lib/src/neighbourhood/Neighbourhood.js +4 -32
- package/lib/src/neighbourhood/NeighbourhoodClient.d.ts +3 -3
- package/lib/src/neighbourhood/NeighbourhoodClient.js +40 -203
- package/lib/src/perspectives/LinkQuery.js +2 -42
- package/lib/src/perspectives/Perspective.d.ts +1 -1
- package/lib/src/perspectives/Perspective.js +10 -52
- package/lib/src/perspectives/PerspectiveClient.d.ts +22 -32
- package/lib/src/perspectives/PerspectiveClient.js +188 -454
- package/lib/src/perspectives/PerspectiveClient.test.d.ts +1 -0
- package/lib/src/perspectives/PerspectiveClient.test.js +224 -0
- package/lib/src/perspectives/PerspectiveDiff.js +4 -31
- package/lib/src/perspectives/PerspectiveHandle.js +3 -43
- package/lib/src/perspectives/PerspectiveProxy.d.ts +157 -78
- package/lib/src/perspectives/PerspectiveProxy.js +475 -389
- package/lib/src/perspectives/PerspectiveResolver.d.ts +0 -1
- package/lib/src/perspectives/PerspectiveResolver.js +0 -11
- package/lib/src/perspectives/SparqlBindings.d.ts +47 -0
- package/lib/src/perspectives/SparqlBindings.js +65 -0
- package/lib/src/perspectives/WakerSubscriptionManager.d.ts +3 -3
- package/lib/src/perspectives/WakerSubscriptionManager.js +12 -12
- package/lib/src/runtime/RuntimeClient.d.ts +8 -6
- package/lib/src/runtime/RuntimeClient.js +97 -454
- package/lib/src/runtime/RuntimeResolver.d.ts +14 -0
- package/lib/src/runtime/RuntimeResolver.js +84 -0
- package/lib/src/runtime/RuntimeTypes.d.ts +101 -0
- package/lib/src/runtime/RuntimeTypes.js +45 -0
- package/lib/src/schema.gql +14 -1
- package/lib/src/shacl/SHACLFlow.d.ts +1 -1
- package/lib/src/shacl/SHACLFlow.js +9 -9
- package/lib/src/shacl/SHACLShape.d.ts +26 -1
- package/lib/src/shacl/SHACLShape.js +140 -38
- package/lib/src/shacl/SHACLShape.test.js +82 -0
- package/lib/src/typeDefs.js +3 -615
- package/lib/src/utils.d.ts +6 -6
- package/lib/src/utils.js +6 -6
- package/package.json +9 -24
- package/rollup.config.js +0 -7
- package/src/Ad4mClient.test.ts +1192 -1288
- package/src/Ad4mClient.ts +46 -15
- package/src/Literal.test.ts +10 -5
- package/src/Literal.ts +6 -5
- package/src/agent/Agent.ts +0 -99
- package/src/agent/AgentClient.ts +238 -467
- package/src/agent/AgentStatus.ts +0 -12
- package/src/ai/AIClient.ts +96 -296
- package/src/ai/AITypes.ts +66 -0
- package/src/ai/Tasks.ts +0 -52
- package/src/apiClient.ts +287 -0
- package/src/cache/PersistentCache.ts +145 -0
- package/src/cache/cache.test.ts +713 -0
- package/src/expression/Expression.ts +3 -43
- package/src/expression/ExpressionClient.ts +148 -77
- package/src/expression/ExpressionRef.ts +2 -8
- package/src/generated/api/AIModelLoadingStatus.ts +3 -0
- package/src/generated/api/AddLinkExpressionRequest.ts +4 -0
- package/src/generated/api/AddLinkRequest.ts +4 -0
- package/src/generated/api/AddLinksBulkRequest.ts +4 -0
- package/src/generated/api/AddSdnaRequest.ts +3 -0
- package/src/generated/api/ApplyTemplateRequest.ts +3 -0
- package/src/generated/api/AuthInfoInput.ts +4 -0
- package/src/generated/api/CapabilityInput.ts +4 -0
- package/src/generated/api/CommitBatchRequest.ts +3 -0
- package/src/generated/api/ComputeLogEntry.ts +3 -0
- package/src/generated/api/CreateExpressionRequest.ts +3 -0
- package/src/generated/api/CreatePerspectiveRequest.ts +3 -0
- package/src/generated/api/CreateSubjectRequest.ts +3 -0
- package/src/generated/api/EmbedRequest.ts +3 -0
- package/src/generated/api/EntanglementProofInput.ts +3 -0
- package/src/generated/api/ExecuteCommandsRequest.ts +3 -0
- package/src/generated/api/ExportRequest.ts +3 -0
- package/src/generated/api/ExpressionManyRequest.ts +3 -0
- package/src/generated/api/ExpressionProof.ts +3 -0
- package/src/generated/api/ExpressionProofInput.ts +3 -0
- package/src/generated/api/FriendSendMessageRequest.ts +3 -0
- package/src/generated/api/FriendsListRequest.ts +3 -0
- package/src/generated/api/GenerateAgentRequest.ts +3 -0
- package/src/generated/api/GenerateJwtRequest.ts +3 -0
- package/src/generated/api/GetSubjectDataRequest.ts +3 -0
- package/src/generated/api/ImportAgentRequest.ts +3 -0
- package/src/generated/api/ImportRequest.ts +3 -0
- package/src/generated/api/JoinNeighbourhoodRequest.ts +3 -0
- package/src/generated/api/LanguageMetaInput.ts +3 -0
- package/src/generated/api/Link.ts +3 -0
- package/src/generated/api/LinkExpression.ts +6 -0
- package/src/generated/api/LinkExpressionInput.ts +6 -0
- package/src/generated/api/LinkInput.ts +3 -0
- package/src/generated/api/LinkLanguageTemplatesRequest.ts +3 -0
- package/src/generated/api/LinkMutations.ts +5 -0
- package/src/generated/api/LinkStatus.ts +3 -0
- package/src/generated/api/LockAgentRequest.ts +3 -0
- package/src/generated/api/ModelType.ts +3 -0
- package/src/generated/api/NotificationInput.ts +3 -0
- package/src/generated/api/OpenLinkRequest.ts +3 -0
- package/src/generated/api/PermitCapabilityRequest.ts +3 -0
- package/src/generated/api/PerspectiveInput.ts +4 -0
- package/src/generated/api/PromptRequest.ts +3 -0
- package/src/generated/api/PublishLanguageRequest.ts +4 -0
- package/src/generated/api/PublishNeighbourhoodRequest.ts +4 -0
- package/src/generated/api/QueryRequest.ts +6 -0
- package/src/generated/api/RemoveLinkRequest.ts +4 -0
- package/src/generated/api/RemoveLinksBulkRequest.ts +4 -0
- package/src/generated/api/ResourceInput.ts +3 -0
- package/src/generated/api/SetDefaultModelRequest.ts +4 -0
- package/src/generated/api/SetFreeHostingEnabledRequest.ts +3 -0
- package/src/generated/api/SetMultiUserRequest.ts +3 -0
- package/src/generated/api/SetStatusRequest.ts +3 -0
- package/src/generated/api/SignMessageRequest.ts +3 -0
- package/src/generated/api/TrustedAgentsRequest.ts +3 -0
- package/src/generated/api/UnlockAgentRequest.ts +3 -0
- package/src/generated/api/UpdateLinkRequest.ts +5 -0
- package/src/generated/api/UpdatePerspectiveRequest.ts +3 -0
- package/src/generated/api/UserStatistics.ts +3 -0
- package/src/generated/api/VerificationRequestResult.ts +3 -0
- package/src/generated/api/VerifySignatureRequest.ts +3 -0
- package/src/generated/api/WriteSettingsRequest.ts +3 -0
- package/src/generated/api/index.ts +49 -0
- package/src/index.ts +8 -2
- package/src/jestSetup.ts +1 -1
- package/src/language/Icon.ts +0 -4
- package/src/language/Language.ts +51 -248
- package/src/language/LanguageClient.ts +21 -132
- package/src/language/LanguageHandle.ts +0 -14
- package/src/language/LanguageMeta.ts +0 -29
- package/src/language/LanguageRef.ts +0 -7
- package/src/links/Links.ts +0 -37
- package/src/model/Ad4mModel.test.ts +1664 -792
- package/src/model/Ad4mModel.ts +664 -499
- package/src/model/ModelQueryBuilder.ts +362 -183
- package/src/model/decorators.ts +71 -22
- package/src/model/hydration.ts +3 -772
- package/src/model/index.ts +3 -4
- package/src/model/json-schema.ts +2 -2
- package/src/model/query-cache.test.ts +54 -0
- package/src/model/query-cache.ts +79 -0
- package/src/model/query-common.ts +1 -1
- package/src/model/query-sparql.test.ts +376 -0
- package/src/model/query-sparql.ts +504 -0
- package/src/model/query-utils.ts +209 -0
- package/src/model/relation-filtering.test.ts +60 -53
- package/src/model/sdna.ts +1 -1
- package/src/model/shacl-gen.ts +163 -64
- package/src/model/shacl-roundtrip.test.ts +197 -0
- package/src/model/types-typed-query.test.ts +360 -0
- package/src/model/types.ts +256 -5
- package/src/neighbourhood/Neighbourhood.ts +0 -9
- package/src/neighbourhood/NeighbourhoodClient.ts +42 -207
- package/src/neighbourhood/NeighbourhoodProxy.test.ts +34 -36
- package/src/perspectives/LinkQuery.ts +0 -15
- package/src/perspectives/Perspective.ts +1 -12
- package/src/perspectives/PerspectiveClient.test.ts +262 -0
- package/src/perspectives/PerspectiveClient.ts +252 -468
- package/src/perspectives/PerspectiveDiff.ts +0 -8
- package/src/perspectives/PerspectiveHandle.ts +1 -12
- package/src/perspectives/PerspectiveProxy.test.ts +125 -0
- package/src/perspectives/PerspectiveProxy.ts +522 -434
- package/src/perspectives/SparqlBindings.ts +79 -0
- package/src/perspectives/WakerSubscriptionManager.ts +13 -13
- package/src/runtime/RuntimeClient.ts +118 -461
- package/src/runtime/RuntimeTypes.ts +144 -0
- package/src/shacl/SHACLFlow.ts +9 -9
- package/src/shacl/SHACLShape.test.ts +204 -0
- package/src/shacl/SHACLShape.ts +191 -39
- package/src/typeDefs.ts +3 -5
- package/src/utils.ts +6 -6
- package/tsconfig.json +3 -7
- package/lib/src/model/query-surreal.d.ts +0 -44
- package/lib/src/model/query-surreal.js +0 -249
- package/lib/src/model/surreal-utils.js +0 -128
- package/shims/reflect-metadata.ts +0 -0
- package/shims/type-graphql.ts +0 -75
- package/src/PubSub.ts +0 -17
- package/src/agent/AgentResolver.ts +0 -263
- package/src/ai/AIResolver.ts +0 -372
- package/src/buildSchema.ts +0 -43
- package/src/expression/ExpressionResolver.ts +0 -64
- package/src/language/LanguageContext.ts +0 -37
- package/src/language/LanguageResolver.ts +0 -98
- package/src/model/Subject.ts +0 -159
- package/src/model/prolog-facts.ts +0 -145
- package/src/model/query-prolog.ts +0 -148
- package/src/model/query-surreal.ts +0 -280
- package/src/model/surreal-utils.ts +0 -147
- package/src/neighbourhood/NeighbourhoodResolver.ts +0 -100
- package/src/perspectives/PerspectiveResolver.ts +0 -372
- package/src/runtime/RuntimeResolver.ts +0 -691
- package/src/unwrapApolloResult.ts +0 -16
- package/tsconfig-browser.json +0 -82
package/src/model/shacl-gen.ts
CHANGED
|
@@ -8,8 +8,6 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { SHACLShape } from "../shacl/SHACLShape";
|
|
10
10
|
import type { SHACLPropertyShape, ConformanceCondition } from "../shacl/SHACLShape";
|
|
11
|
-
import { escapeSurrealString } from "../utils";
|
|
12
|
-
import { compileWhereClause } from "./surreal-utils";
|
|
13
11
|
import { propertyNameToSetterName } from "./util";
|
|
14
12
|
import type { PropertyMetadataEntry, RelationMetadataEntry, Ad4mModelLike } from "./decorators";
|
|
15
13
|
|
|
@@ -41,9 +39,6 @@ export function buildSHACL(
|
|
|
41
39
|
|
|
42
40
|
// ── Determine namespace from first property or relation ─────────────
|
|
43
41
|
let namespace = "ad4m://";
|
|
44
|
-
const relations = Object.fromEntries(
|
|
45
|
-
Object.entries(allRelationsMeta).filter(([, r]) => r.kind === 'hasMany' || r.kind === 'belongsToMany')
|
|
46
|
-
);
|
|
47
42
|
|
|
48
43
|
// Try properties first
|
|
49
44
|
if (Object.keys(properties).length > 0) {
|
|
@@ -56,8 +51,8 @@ export function buildSHACL(
|
|
|
56
51
|
}
|
|
57
52
|
}
|
|
58
53
|
// Fall back to relations if no properties
|
|
59
|
-
else if (Object.keys(
|
|
60
|
-
const firstRel =
|
|
54
|
+
else if (Object.keys(allRelationsMeta).length > 0) {
|
|
55
|
+
const firstRel = allRelationsMeta[Object.keys(allRelationsMeta)[0]];
|
|
61
56
|
if (firstRel.predicate) {
|
|
62
57
|
const match = firstRel.predicate.match(/^([^:]+:\/\/)/);
|
|
63
58
|
if (match) {
|
|
@@ -128,6 +123,11 @@ export function buildSHACL(
|
|
|
128
123
|
propShape.hasValue = propMeta.initial;
|
|
129
124
|
}
|
|
130
125
|
|
|
126
|
+
// sh:in — allowed values (enum constraint)
|
|
127
|
+
if (propMeta.options && propMeta.options.length > 0) {
|
|
128
|
+
propShape.in = propMeta.options;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
131
|
// AD4M-specific metadata
|
|
132
132
|
if (propMeta.local !== undefined) {
|
|
133
133
|
propShape.local = propMeta.local;
|
|
@@ -141,6 +141,13 @@ export function buildSHACL(
|
|
|
141
141
|
propShape.resolveLanguage = propMeta.resolveLanguage;
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
+
// Explicit getter SPARQL — the executor evaluates this when
|
|
145
|
+
// hydrating the property, in addition to (or instead of)
|
|
146
|
+
// reading raw links via `propMeta.through`.
|
|
147
|
+
if (propMeta.getter) {
|
|
148
|
+
propShape.getter = propMeta.getter;
|
|
149
|
+
}
|
|
150
|
+
|
|
144
151
|
// ── Setter actions ──────────────────────────────────────────────
|
|
145
152
|
if (propMeta.prologSetter) {
|
|
146
153
|
console.warn(
|
|
@@ -163,7 +170,7 @@ export function buildSHACL(
|
|
|
163
170
|
// ── Constructor / Destructor entries ────────────────────────────
|
|
164
171
|
const effectiveInitial = propMeta.initial
|
|
165
172
|
?? (propMeta.required && propMeta.writable && !propMeta.flag && propMeta.through
|
|
166
|
-
? "literal
|
|
173
|
+
? "literal:string:" : undefined);
|
|
167
174
|
|
|
168
175
|
if (effectiveInitial) {
|
|
169
176
|
constructorActions.push({
|
|
@@ -185,83 +192,130 @@ export function buildSHACL(
|
|
|
185
192
|
}
|
|
186
193
|
|
|
187
194
|
// ── Convert relations to SHACL property shapes ─────────────────────
|
|
188
|
-
for (const relName in
|
|
189
|
-
const relMeta =
|
|
190
|
-
|
|
191
|
-
|
|
195
|
+
for (const relName in allRelationsMeta) {
|
|
196
|
+
const relMeta = allRelationsMeta[relName];
|
|
197
|
+
|
|
198
|
+
// Getter-only relations (no `through`) have no real link predicate
|
|
199
|
+
// but still need a SHACL property entry so the executor can find
|
|
200
|
+
// the getter expression. Synthesize a deterministic IRI so the
|
|
201
|
+
// SHACL graph is well-formed; the predicate is never used to match
|
|
202
|
+
// links because the getter is the sole source of values. Use
|
|
203
|
+
// slash separators so the result is a valid IRI (colons in the
|
|
204
|
+
// authority confuse strict SPARQL IRI parsers).
|
|
205
|
+
if (!relMeta.predicate && !relMeta.getter) continue;
|
|
206
|
+
const synthesizedPath = relMeta.predicate
|
|
207
|
+
|| `ad4m://getter/${subjectName}/${relName}`;
|
|
192
208
|
|
|
193
209
|
const relShape: SHACLPropertyShape = {
|
|
194
210
|
name: relName,
|
|
195
|
-
path:
|
|
211
|
+
path: synthesizedPath,
|
|
196
212
|
};
|
|
197
213
|
|
|
198
214
|
// Relations typically contain IRIs
|
|
199
215
|
relShape.nodeKind = 'IRI';
|
|
200
216
|
|
|
217
|
+
// Encode relation kind so the executor can derive direction and
|
|
218
|
+
// scalar-vs-collection rendering without consulting the JS class.
|
|
219
|
+
relShape.relationKind = relMeta.kind;
|
|
220
|
+
|
|
221
|
+
// Scalar relations cap at 1.
|
|
222
|
+
if (relMeta.kind === 'hasOne' || relMeta.kind === 'belongsToOne') {
|
|
223
|
+
relShape.maxCount = 1;
|
|
224
|
+
} else if (relMeta.maxCount !== undefined) {
|
|
225
|
+
relShape.maxCount = relMeta.maxCount;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// Encode opt-out of type filtering (default true; only emit when false).
|
|
229
|
+
if (relMeta.filter === false) {
|
|
230
|
+
relShape.filter = false;
|
|
231
|
+
}
|
|
232
|
+
|
|
201
233
|
// AD4M-specific metadata
|
|
202
234
|
if (relMeta.local !== undefined) {
|
|
203
235
|
relShape.local = relMeta.local;
|
|
204
236
|
}
|
|
205
237
|
|
|
206
|
-
// Adder
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
238
|
+
// Adder / Remover actions — only meaningful for relations backed
|
|
239
|
+
// by a real link predicate. Getter-only relations are read-only.
|
|
240
|
+
if (relMeta.predicate) {
|
|
241
|
+
relShape.adder = [{
|
|
242
|
+
action: "addLink",
|
|
243
|
+
source: "this",
|
|
244
|
+
predicate: relMeta.predicate,
|
|
245
|
+
target: "value",
|
|
246
|
+
...(relMeta.local && { local: true })
|
|
247
|
+
}];
|
|
248
|
+
|
|
249
|
+
relShape.remover = [{
|
|
250
|
+
action: "removeLink",
|
|
251
|
+
source: "this",
|
|
252
|
+
predicate: relMeta.predicate,
|
|
253
|
+
target: "value",
|
|
254
|
+
...(relMeta.local && { local: true })
|
|
255
|
+
}];
|
|
256
|
+
}
|
|
223
257
|
|
|
224
258
|
// ── Build Getter (conformance filter) ───────────────────────────
|
|
225
259
|
// Priority chain:
|
|
226
260
|
// 1. Explicit getter string → use verbatim
|
|
227
|
-
// 2.
|
|
228
|
-
//
|
|
261
|
+
// 2. target + filter !== false → auto-derive conformance getter
|
|
262
|
+
// from the shape. Where-clause filtering is applied as a
|
|
263
|
+
// post-getter pass via `whereFilter` / `wherePredicates`, which
|
|
264
|
+
// use `parse_literal_value` and so transparently handle
|
|
265
|
+
// `literal:json:` envelopes that simple FILTER(STR(?x) = ...)
|
|
266
|
+
// comparisons can't.
|
|
229
267
|
if (relMeta.getter) {
|
|
230
268
|
relShape.getter = relMeta.getter;
|
|
231
|
-
} else if (
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
269
|
+
} else if (
|
|
270
|
+
relMeta.target
|
|
271
|
+
&& relMeta.filter !== false
|
|
272
|
+
&& relMeta.kind !== 'belongsToOne'
|
|
273
|
+
&& relMeta.kind !== 'belongsToMany'
|
|
274
|
+
) {
|
|
275
|
+
// Lazy conformance filter: store deferred reference,
|
|
276
|
+
// resolve on first access via a getter on relShape.
|
|
277
|
+
// Skipped for reverse relations (belongsTo*) because the
|
|
278
|
+
// auto-derived getter assumes forward direction; the executor's
|
|
279
|
+
// `resolve_reverse_relations` already populates these correctly.
|
|
280
|
+
const targetThunk = relMeta.target;
|
|
281
|
+
const predicate = relMeta.predicate;
|
|
282
|
+
let resolved = false;
|
|
283
|
+
let cachedGetter: string | undefined;
|
|
284
|
+
let cachedConditions: ConformanceCondition[] | undefined;
|
|
285
|
+
|
|
286
|
+
const resolveFilter = () => {
|
|
287
|
+
if (resolved) return;
|
|
288
|
+
resolved = true;
|
|
289
|
+
try {
|
|
290
|
+
const TargetClass = targetThunk();
|
|
291
|
+
const filter = conformanceFilterFn(predicate, TargetClass);
|
|
292
|
+
if (filter) {
|
|
293
|
+
cachedGetter = filter.getter;
|
|
294
|
+
cachedConditions = filter.conformanceConditions;
|
|
295
|
+
}
|
|
296
|
+
} catch (e) {
|
|
297
|
+
// Target class may not be available yet
|
|
246
298
|
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
}
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
// Define lazy getters that resolve on first access
|
|
302
|
+
Object.defineProperty(relShape, 'getter', {
|
|
303
|
+
get() { resolveFilter(); return cachedGetter; },
|
|
304
|
+
set(v: string) { resolved = true; cachedGetter = v; },
|
|
305
|
+
enumerable: true,
|
|
306
|
+
configurable: true,
|
|
307
|
+
});
|
|
308
|
+
Object.defineProperty(relShape, 'conformanceConditions', {
|
|
309
|
+
get() { resolveFilter(); return cachedConditions; },
|
|
310
|
+
set(v: ConformanceCondition[]) { resolved = true; cachedConditions = v; },
|
|
311
|
+
enumerable: true,
|
|
312
|
+
configurable: true,
|
|
313
|
+
});
|
|
262
314
|
}
|
|
263
315
|
|
|
264
316
|
// ── sh:class — target shape reference ───────────────────────────
|
|
317
|
+
// Also emit ad4m:targetClassName so the executor can look up the
|
|
318
|
+
// target class shape through its in-memory cache by bare name.
|
|
265
319
|
if (relMeta.target) {
|
|
266
320
|
try {
|
|
267
321
|
const TargetClass = relMeta.target();
|
|
@@ -269,8 +323,53 @@ export function buildSHACL(
|
|
|
269
323
|
if (targetSHACL?.shape?.nodeShapeUri) {
|
|
270
324
|
relShape.class = targetSHACL.shape.nodeShapeUri;
|
|
271
325
|
}
|
|
326
|
+
if (targetSHACL?.name) {
|
|
327
|
+
relShape.targetClassName = targetSHACL.name;
|
|
328
|
+
} else {
|
|
329
|
+
const targetProto = (TargetClass as any).prototype;
|
|
330
|
+
if (targetProto?.className) {
|
|
331
|
+
relShape.targetClassName = targetProto.className;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
272
334
|
} catch (e) {
|
|
273
|
-
// Target class
|
|
335
|
+
// Target class resolution failed (typically a circular
|
|
336
|
+
// decorator dependency). Since the executor no longer
|
|
337
|
+
// receives target metadata over the wire, dropping the
|
|
338
|
+
// reference here would turn a transient build-time issue
|
|
339
|
+
// into a permanent broken-include at query time. Log
|
|
340
|
+
// loudly so the failure is discoverable.
|
|
341
|
+
console.warn(
|
|
342
|
+
`[shacl-gen] Failed to resolve target class for relation `
|
|
343
|
+
+ `"${subjectName}.${relName}": ${e instanceof Error ? e.message : String(e)}`
|
|
344
|
+
);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// ── Where-clause metadata for post-getter filtering ─────────────
|
|
349
|
+
// The executor uses these to apply where conditions against the
|
|
350
|
+
// target class without needing the target's ModelMetadata at query time.
|
|
351
|
+
if (relMeta.where) {
|
|
352
|
+
relShape.whereFilter = relMeta.where;
|
|
353
|
+
try {
|
|
354
|
+
const TargetClass = relMeta.target?.();
|
|
355
|
+
const targetMetadata = TargetClass
|
|
356
|
+
? (TargetClass as any).getModelMetadata?.() ?? null
|
|
357
|
+
: null;
|
|
358
|
+
if (targetMetadata?.properties) {
|
|
359
|
+
const predicates: Record<string, string> = {};
|
|
360
|
+
for (const propName of Object.keys(relMeta.where)) {
|
|
361
|
+
if (['id', 'author', 'timestamp'].includes(propName)) continue;
|
|
362
|
+
const propMeta = targetMetadata.properties[propName];
|
|
363
|
+
if (propMeta?.predicate) {
|
|
364
|
+
predicates[propName] = propMeta.predicate;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
if (Object.keys(predicates).length > 0) {
|
|
368
|
+
relShape.wherePredicates = predicates;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
} catch (e) {
|
|
372
|
+
// Target metadata may not be available yet
|
|
274
373
|
}
|
|
275
374
|
}
|
|
276
375
|
|
|
@@ -278,7 +377,7 @@ export function buildSHACL(
|
|
|
278
377
|
}
|
|
279
378
|
|
|
280
379
|
// Always set constructor and destructor actions on the shape, even
|
|
281
|
-
// when empty. An empty array serialises to `literal
|
|
380
|
+
// when empty. An empty array serialises to `literal:string:[]`
|
|
282
381
|
// which the Rust executor parses as a valid (no-op) command list,
|
|
283
382
|
// avoiding "No SHACL constructor found" errors for models whose
|
|
284
383
|
// properties are all optional and have no @Flag.
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decorator → SHACL writer round-trip tests.
|
|
3
|
+
*
|
|
4
|
+
* Spec R11 gate on the TypeScript side: any field a decorator sets must
|
|
5
|
+
* survive into the SHACL graph produced by `generateSHACL()`. These tests
|
|
6
|
+
* compare against the SHACL link emission (the format the Rust executor
|
|
7
|
+
* stores and reads), not against `getModelMetadata()` — which is the
|
|
8
|
+
* dying shape transport, not the source of truth.
|
|
9
|
+
*/
|
|
10
|
+
import { Ad4mModel } from "./Ad4mModel";
|
|
11
|
+
import {
|
|
12
|
+
Model,
|
|
13
|
+
Property,
|
|
14
|
+
Flag,
|
|
15
|
+
HasMany,
|
|
16
|
+
HasOne,
|
|
17
|
+
BelongsToOne,
|
|
18
|
+
BelongsToMany,
|
|
19
|
+
} from "./decorators";
|
|
20
|
+
|
|
21
|
+
function flatten(
|
|
22
|
+
shape: any,
|
|
23
|
+
): Array<{ source: string; predicate: string; target: string }> {
|
|
24
|
+
return shape.toLinks().map((l: any) => ({
|
|
25
|
+
source: l.source,
|
|
26
|
+
predicate: l.predicate,
|
|
27
|
+
target: l.target,
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function findLinkTarget(
|
|
32
|
+
links: any[],
|
|
33
|
+
source: string,
|
|
34
|
+
predicate: string,
|
|
35
|
+
): string | undefined {
|
|
36
|
+
return links.find((l) => l.source === source && l.predicate === predicate)
|
|
37
|
+
?.target;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
describe("Decorators → SHACL writer round-trip", () => {
|
|
41
|
+
it("emits ad4m:relationKind for every relation kind", () => {
|
|
42
|
+
@Model({ name: "Target" })
|
|
43
|
+
class Target extends Ad4mModel {}
|
|
44
|
+
|
|
45
|
+
@Model({ name: "Holder" })
|
|
46
|
+
class Holder extends Ad4mModel {
|
|
47
|
+
@HasMany({ through: "ns://hm", target: () => Target })
|
|
48
|
+
hmRel: string[] = [];
|
|
49
|
+
|
|
50
|
+
@HasOne({ through: "ns://ho", target: () => Target })
|
|
51
|
+
hoRel: string = "";
|
|
52
|
+
|
|
53
|
+
@BelongsToOne({ through: "ns://bto", target: () => Target })
|
|
54
|
+
btoRel: string = "";
|
|
55
|
+
|
|
56
|
+
@BelongsToMany({ through: "ns://btm", target: () => Target })
|
|
57
|
+
btmRel: string[] = [];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const { shape } = Holder.generateSHACL();
|
|
61
|
+
const links = flatten(shape);
|
|
62
|
+
const propUri = (name: string) => `ns://Holder.${name}`;
|
|
63
|
+
|
|
64
|
+
expect(findLinkTarget(links, propUri("hmRel"), "ad4m://relationKind")).toBe(
|
|
65
|
+
"literal:string:hasMany",
|
|
66
|
+
);
|
|
67
|
+
expect(findLinkTarget(links, propUri("hoRel"), "ad4m://relationKind")).toBe(
|
|
68
|
+
"literal:string:hasOne",
|
|
69
|
+
);
|
|
70
|
+
expect(
|
|
71
|
+
findLinkTarget(links, propUri("btoRel"), "ad4m://relationKind"),
|
|
72
|
+
).toBe("literal:string:belongsToOne");
|
|
73
|
+
expect(
|
|
74
|
+
findLinkTarget(links, propUri("btmRel"), "ad4m://relationKind"),
|
|
75
|
+
).toBe("literal:string:belongsToMany");
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("emits maxCount=1 for scalar relations", () => {
|
|
79
|
+
@Model({ name: "Target2" })
|
|
80
|
+
class Target2 extends Ad4mModel {}
|
|
81
|
+
|
|
82
|
+
@Model({ name: "Holder2" })
|
|
83
|
+
class Holder2 extends Ad4mModel {
|
|
84
|
+
@HasOne({ through: "ns://ho", target: () => Target2 })
|
|
85
|
+
hoRel: string = "";
|
|
86
|
+
|
|
87
|
+
@BelongsToOne({ through: "ns://bto", target: () => Target2 })
|
|
88
|
+
btoRel: string = "";
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const { shape } = Holder2.generateSHACL();
|
|
92
|
+
const links = flatten(shape);
|
|
93
|
+
|
|
94
|
+
expect(findLinkTarget(links, "ns://Holder2.hoRel", "sh://maxCount")).toBe(
|
|
95
|
+
"literal:1^^xsd:integer",
|
|
96
|
+
);
|
|
97
|
+
expect(findLinkTarget(links, "ns://Holder2.btoRel", "sh://maxCount")).toBe(
|
|
98
|
+
"literal:1^^xsd:integer",
|
|
99
|
+
);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("emits ad4m:targetClassName for relations with a target", () => {
|
|
103
|
+
@Model({ name: "Ingredient" })
|
|
104
|
+
class Ingredient extends Ad4mModel {}
|
|
105
|
+
|
|
106
|
+
@Model({ name: "Recipe" })
|
|
107
|
+
class Recipe extends Ad4mModel {
|
|
108
|
+
@HasMany({ through: "ns://ing", target: () => Ingredient })
|
|
109
|
+
ingredients: string[] = [];
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const { shape } = Recipe.generateSHACL();
|
|
113
|
+
const links = flatten(shape);
|
|
114
|
+
|
|
115
|
+
expect(
|
|
116
|
+
findLinkTarget(
|
|
117
|
+
links,
|
|
118
|
+
"ns://Recipe.ingredients",
|
|
119
|
+
"ad4m://targetClassName",
|
|
120
|
+
),
|
|
121
|
+
).toBe("literal:string:Ingredient");
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it("emits sh:hasValue for @Flag properties", () => {
|
|
125
|
+
@Model({ name: "Channel" })
|
|
126
|
+
class Channel extends Ad4mModel {
|
|
127
|
+
@Flag({ through: "ns://type", value: "ns://Channel" })
|
|
128
|
+
type: string = "";
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const { shape } = Channel.generateSHACL();
|
|
132
|
+
const links = flatten(shape);
|
|
133
|
+
|
|
134
|
+
const hasValue = findLinkTarget(
|
|
135
|
+
links,
|
|
136
|
+
"ns://Channel.type",
|
|
137
|
+
"sh://hasValue",
|
|
138
|
+
);
|
|
139
|
+
expect(hasValue).toBeDefined();
|
|
140
|
+
// Writer emits literal:<value> for URI-style flags.
|
|
141
|
+
expect(hasValue).toContain("ns://Channel");
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it("encodes ad4m:filter=false when explicitly disabled", () => {
|
|
145
|
+
@Model({ name: "Tag" })
|
|
146
|
+
class Tag extends Ad4mModel {}
|
|
147
|
+
|
|
148
|
+
@Model({ name: "Doc" })
|
|
149
|
+
class Doc extends Ad4mModel {
|
|
150
|
+
@HasMany({ through: "ns://tag", target: () => Tag, filter: false })
|
|
151
|
+
tags: string[] = [];
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const { shape } = Doc.generateSHACL();
|
|
155
|
+
const links = flatten(shape);
|
|
156
|
+
|
|
157
|
+
expect(findLinkTarget(links, "ns://Doc.tags", "ad4m://filter")).toBe(
|
|
158
|
+
"literal:false",
|
|
159
|
+
);
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
it("does not emit ad4m:filter when defaulted to true", () => {
|
|
163
|
+
@Model({ name: "Tag2" })
|
|
164
|
+
class Tag2 extends Ad4mModel {}
|
|
165
|
+
|
|
166
|
+
@Model({ name: "Doc2" })
|
|
167
|
+
class Doc2 extends Ad4mModel {
|
|
168
|
+
@HasMany({ through: "ns://tag", target: () => Tag2 })
|
|
169
|
+
tags: string[] = [];
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const { shape } = Doc2.generateSHACL();
|
|
173
|
+
const links = flatten(shape);
|
|
174
|
+
|
|
175
|
+
expect(
|
|
176
|
+
findLinkTarget(links, "ns://Doc2.tags", "ad4m://filter"),
|
|
177
|
+
).toBeUndefined();
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it("emits scalar property predicates", () => {
|
|
181
|
+
@Model({ name: "Profile" })
|
|
182
|
+
class Profile extends Ad4mModel {
|
|
183
|
+
@Property({ through: "ns://name", resolveLanguage: "literal" })
|
|
184
|
+
name: string = "";
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const { shape } = Profile.generateSHACL();
|
|
188
|
+
const links = flatten(shape);
|
|
189
|
+
|
|
190
|
+
expect(findLinkTarget(links, "ns://Profile.name", "sh://path")).toBe(
|
|
191
|
+
"ns://name",
|
|
192
|
+
);
|
|
193
|
+
expect(
|
|
194
|
+
findLinkTarget(links, "ns://Profile.name", "ad4m://resolveLanguage"),
|
|
195
|
+
).toBe("literal:string:literal");
|
|
196
|
+
});
|
|
197
|
+
});
|