@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
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ApiClient, RpcError } from "../apiClient";
|
|
2
2
|
import { ExpressionRendered } from "../expression/Expression";
|
|
3
3
|
import { ExpressionClient } from "../expression/ExpressionClient";
|
|
4
|
-
import { Link, LinkExpressionInput, LinkExpression,
|
|
4
|
+
import { Link, LinkExpressionInput, LinkExpression, LinkMutations, LinkExpressionMutations } from "../links/Links";
|
|
5
5
|
import { NeighbourhoodClient } from "../neighbourhood/NeighbourhoodClient";
|
|
6
6
|
import { NeighbourhoodProxy } from "../neighbourhood/NeighbourhoodProxy";
|
|
7
|
-
import unwrapApolloResult from "../unwrapApolloResult";
|
|
8
7
|
import { LinkQuery } from "./LinkQuery";
|
|
9
8
|
import { Perspective } from "./Perspective";
|
|
10
9
|
import { PerspectiveHandle, PerspectiveState } from "./PerspectiveHandle";
|
|
@@ -12,44 +11,27 @@ import { LinkStatus, PerspectiveProxy } from './PerspectiveProxy';
|
|
|
12
11
|
import { AIClient } from "../ai/AIClient";
|
|
13
12
|
import { AllInstancesResult } from "../model/types";
|
|
14
13
|
|
|
15
|
-
const LINK_EXPRESSION_FIELDS = `
|
|
16
|
-
author
|
|
17
|
-
timestamp
|
|
18
|
-
status
|
|
19
|
-
data { source, predicate, target }
|
|
20
|
-
proof { valid, invalid, signature, key }
|
|
21
|
-
`
|
|
22
|
-
|
|
23
|
-
const PERSPECTIVE_HANDLE_FIELDS = `
|
|
24
|
-
uuid
|
|
25
|
-
name
|
|
26
|
-
sharedUrl
|
|
27
|
-
state
|
|
28
|
-
owners
|
|
29
|
-
neighbourhood {
|
|
30
|
-
data {
|
|
31
|
-
linkLanguage
|
|
32
|
-
meta {
|
|
33
|
-
links
|
|
34
|
-
{
|
|
35
|
-
author
|
|
36
|
-
timestamp
|
|
37
|
-
data { source, predicate, target }
|
|
38
|
-
proof { valid, invalid, signature, key }
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
author
|
|
43
|
-
}
|
|
44
|
-
`
|
|
45
|
-
|
|
46
14
|
export type PerspectiveHandleCallback = (perspective: PerspectiveHandle) => null
|
|
47
15
|
export type UuidCallback = (uuid: string) => null
|
|
48
16
|
export type LinkCallback = (link: LinkExpression) => null
|
|
49
17
|
export type SyncStateChangeCallback = (state: PerspectiveState) => null
|
|
50
18
|
|
|
19
|
+
function normalizeQueryResult(raw: unknown, errorContext: string): AllInstancesResult {
|
|
20
|
+
let finalResult: unknown = raw
|
|
21
|
+
|
|
22
|
+
if (typeof finalResult === 'string') {
|
|
23
|
+
try {
|
|
24
|
+
finalResult = JSON.parse(finalResult)
|
|
25
|
+
} catch (e) {
|
|
26
|
+
console.error(errorContext, e)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return finalResult as AllInstancesResult
|
|
31
|
+
}
|
|
32
|
+
|
|
51
33
|
export class PerspectiveClient {
|
|
52
|
-
#
|
|
34
|
+
#apiClient: ApiClient
|
|
53
35
|
#perspectiveAddedCallbacks: PerspectiveHandleCallback[]
|
|
54
36
|
#perspectiveUpdatedCallbacks: PerspectiveHandleCallback[]
|
|
55
37
|
#perspectiveRemovedCallbacks: UuidCallback[]
|
|
@@ -57,13 +39,19 @@ export class PerspectiveClient {
|
|
|
57
39
|
#expressionClient?: ExpressionClient
|
|
58
40
|
#neighbourhoodClient?: NeighbourhoodClient
|
|
59
41
|
#aiClient?: AIClient
|
|
42
|
+
#unsubscribers: (() => void)[]
|
|
43
|
+
#linkUnsubscribers: Map<string, (() => void)[]>
|
|
44
|
+
#querySubscriptionUnsubscribers: Map<string, () => void>
|
|
60
45
|
|
|
61
|
-
constructor(
|
|
62
|
-
this.#
|
|
46
|
+
constructor(baseUrl: string, token?: string, subscribe: boolean = true, sharedApiClient?: ApiClient) {
|
|
47
|
+
this.#apiClient = sharedApiClient || new ApiClient(baseUrl, token)
|
|
63
48
|
this.#perspectiveAddedCallbacks = []
|
|
64
49
|
this.#perspectiveUpdatedCallbacks = []
|
|
65
50
|
this.#perspectiveRemovedCallbacks = []
|
|
66
51
|
this.#perspectiveSyncStateChangeCallbacks = []
|
|
52
|
+
this.#unsubscribers = []
|
|
53
|
+
this.#linkUnsubscribers = new Map()
|
|
54
|
+
this.#querySubscriptionUnsubscribers = new Map()
|
|
67
55
|
|
|
68
56
|
if(subscribe) {
|
|
69
57
|
this.subscribePerspectiveAdded()
|
|
@@ -85,335 +73,192 @@ export class PerspectiveClient {
|
|
|
85
73
|
}
|
|
86
74
|
|
|
87
75
|
get aiClient(): AIClient {
|
|
88
|
-
return this.#aiClient
|
|
76
|
+
return this.#aiClient!
|
|
89
77
|
}
|
|
90
78
|
|
|
91
79
|
async all(): Promise<PerspectiveProxy[]> {
|
|
92
|
-
const
|
|
93
|
-
query: gql`query perspectives {
|
|
94
|
-
perspectives {
|
|
95
|
-
${PERSPECTIVE_HANDLE_FIELDS}
|
|
96
|
-
}
|
|
97
|
-
}`
|
|
98
|
-
}))
|
|
80
|
+
const perspectives = await this.#apiClient.call<PerspectiveHandle[]>('perspective.all')
|
|
99
81
|
return perspectives.map(handle => new PerspectiveProxy(handle, this))
|
|
100
82
|
}
|
|
101
83
|
|
|
102
84
|
async byUUID(uuid: string): Promise<PerspectiveProxy|null> {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
if(!perspective) return null
|
|
112
|
-
return new PerspectiveProxy(perspective, this)
|
|
85
|
+
try {
|
|
86
|
+
const perspective = await this.#apiClient.call<PerspectiveHandle>('perspective.get', { uuid })
|
|
87
|
+
if(!perspective) return null
|
|
88
|
+
return new PerspectiveProxy(perspective, this)
|
|
89
|
+
} catch(e) {
|
|
90
|
+
if (e instanceof RpcError && e.status === 404) return null
|
|
91
|
+
throw e
|
|
92
|
+
}
|
|
113
93
|
}
|
|
114
94
|
|
|
115
95
|
async snapshotByUUID(uuid: string): Promise<Perspective|null> {
|
|
116
|
-
|
|
117
|
-
query: gql`query perspectiveSnapshot($uuid: String!) {
|
|
118
|
-
perspectiveSnapshot(uuid: $uuid) {
|
|
119
|
-
links { ${LINK_EXPRESSION_FIELDS} }
|
|
120
|
-
}
|
|
121
|
-
}`,
|
|
122
|
-
variables: { uuid }
|
|
123
|
-
}))
|
|
124
|
-
return perspectiveSnapshot
|
|
96
|
+
return this.#apiClient.call<Perspective|null>('perspective.snapshot', { uuid })
|
|
125
97
|
}
|
|
98
|
+
|
|
126
99
|
async publishSnapshotByUUID(uuid: string): Promise<string|null> {
|
|
127
|
-
|
|
128
|
-
mutation: gql`mutation perspectivePublishSnapshot($uuid: String!) {
|
|
129
|
-
perspectivePublishSnapshot(uuid: $uuid)
|
|
130
|
-
}`,
|
|
131
|
-
variables: { uuid }
|
|
132
|
-
}))
|
|
133
|
-
return perspectivePublishSnapshot
|
|
100
|
+
return this.#apiClient.call<string|null>('perspective.publishSnapshot', { uuid })
|
|
134
101
|
}
|
|
135
102
|
|
|
136
103
|
async queryLinks(uuid: string, query: LinkQuery): Promise<LinkExpression[]> {
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
return perspectiveQueryLinks
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
async queryProlog(uuid: string, query: string): Promise<any> {
|
|
149
|
-
const { perspectiveQueryProlog } = unwrapApolloResult(await this.#apolloClient.query({
|
|
150
|
-
query: gql`query perspectiveQueryProlog($uuid: String!, $query: String!) {
|
|
151
|
-
perspectiveQueryProlog(uuid: $uuid, query: $query)
|
|
152
|
-
}`,
|
|
153
|
-
variables: { uuid, query }
|
|
154
|
-
}))
|
|
155
|
-
|
|
156
|
-
return JSON.parse(perspectiveQueryProlog)
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Executes a read-only SurrealQL query against a perspective's link cache.
|
|
161
|
-
*
|
|
162
|
-
* Security: Only SELECT, RETURN, and other read-only queries are permitted.
|
|
163
|
-
* Mutating operations (DELETE, UPDATE, INSERT, etc.) are blocked.
|
|
164
|
-
*
|
|
165
|
-
* Note: GraphQL field name is "perspectiveQuerySurrealDb" (lowercase "b" in "Db")
|
|
166
|
-
* as generated from Rust method "perspective_query_surreal_db"
|
|
167
|
-
*/
|
|
168
|
-
async querySurrealDB(uuid: string, query: string): Promise<any> {
|
|
169
|
-
const { perspectiveQuerySurrealDb } = unwrapApolloResult(await this.#apolloClient.query({
|
|
170
|
-
query: gql`query perspectiveQuerySurrealDb($uuid: String!, $query: String!) {
|
|
171
|
-
perspectiveQuerySurrealDb(uuid: $uuid, query: $query)
|
|
172
|
-
}`,
|
|
173
|
-
variables: { uuid, query }
|
|
174
|
-
}))
|
|
175
|
-
|
|
176
|
-
return JSON.parse(perspectiveQuerySurrealDb)
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
async subscribeQuery(uuid: string, query: string): Promise<{ subscriptionId: string, result: AllInstancesResult, isInit?: boolean }> {
|
|
180
|
-
const { perspectiveSubscribeQuery } = unwrapApolloResult(await this.#apolloClient.mutate({
|
|
181
|
-
mutation: gql`mutation perspectiveSubscribeQuery($uuid: String!, $query: String!) {
|
|
182
|
-
perspectiveSubscribeQuery(uuid: $uuid, query: $query) {
|
|
183
|
-
subscriptionId
|
|
184
|
-
result
|
|
185
|
-
}
|
|
186
|
-
}`,
|
|
187
|
-
variables: { uuid, query }
|
|
188
|
-
}))
|
|
189
|
-
const { subscriptionId, result } = perspectiveSubscribeQuery
|
|
190
|
-
let finalResult = result;
|
|
191
|
-
let isInit = false;
|
|
192
|
-
if(finalResult.startsWith("#init#")) {
|
|
193
|
-
finalResult = finalResult.substring(6)
|
|
194
|
-
isInit = true;
|
|
195
|
-
}
|
|
196
|
-
try {
|
|
197
|
-
finalResult = JSON.parse(finalResult)
|
|
198
|
-
} catch (e) {
|
|
199
|
-
console.error('Error parsing perspectiveSubscribeQuery result:', e)
|
|
200
|
-
}
|
|
201
|
-
return { subscriptionId, result: finalResult, isInit }
|
|
104
|
+
const params: Record<string, unknown> = { uuid }
|
|
105
|
+
if (query.source) params.source = query.source
|
|
106
|
+
if (query.predicate) params.predicate = query.predicate
|
|
107
|
+
if (query.target) params.target = query.target
|
|
108
|
+
if (query.fromDate) params.fromDate = query.fromDate instanceof Date ? query.fromDate.toISOString() : String(query.fromDate)
|
|
109
|
+
if (query.untilDate) params.untilDate = query.untilDate instanceof Date ? query.untilDate.toISOString() : String(query.untilDate)
|
|
110
|
+
if (query.limit !== undefined) params.limit = query.limit
|
|
111
|
+
return this.#apiClient.call<LinkExpression[]>('perspective.queryLinks', params)
|
|
202
112
|
}
|
|
203
113
|
|
|
204
|
-
async
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
perspectiveSubscribeSurrealQuery(uuid: $uuid, query: $query) {
|
|
208
|
-
subscriptionId
|
|
209
|
-
result
|
|
210
|
-
}
|
|
211
|
-
}`,
|
|
212
|
-
variables: { uuid, query }
|
|
213
|
-
}))
|
|
214
|
-
const { subscriptionId, result } = perspectiveSubscribeSurrealQuery
|
|
215
|
-
let finalResult = result;
|
|
216
|
-
let isInit = false;
|
|
217
|
-
if(finalResult.startsWith("#init#")) {
|
|
218
|
-
finalResult = finalResult.substring(6)
|
|
219
|
-
isInit = true;
|
|
220
|
-
}
|
|
221
|
-
try {
|
|
222
|
-
finalResult = JSON.parse(finalResult)
|
|
223
|
-
} catch (e) {
|
|
224
|
-
console.error('Error parsing perspectiveSubscribeSurrealQuery result:', e)
|
|
225
|
-
}
|
|
226
|
-
return { subscriptionId, result: finalResult, isInit }
|
|
114
|
+
async queryProlog(uuid: string, query: string): Promise<unknown> {
|
|
115
|
+
const result = await this.#apiClient.call<string>('perspective.queryProlog', { uuid, query })
|
|
116
|
+
return JSON.parse(result)
|
|
227
117
|
}
|
|
228
118
|
|
|
229
|
-
async
|
|
230
|
-
const
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
}`,
|
|
234
|
-
variables: { uuid, subscriptionId }
|
|
235
|
-
}))
|
|
119
|
+
async querySparql<T = any>(uuid: string, query: string): Promise<T> {
|
|
120
|
+
const result = await this.#apiClient.call<string>('perspective.querySparql', { uuid, engine: 'sparql', query })
|
|
121
|
+
return JSON.parse(result) as T
|
|
122
|
+
}
|
|
236
123
|
|
|
237
|
-
|
|
124
|
+
async subscribeQuery(uuid: string, query: string): Promise<{ subscriptionId: string, result: AllInstancesResult }> {
|
|
125
|
+
const response = await this.#apiClient.call<{ subscriptionId: string, result: unknown }>(
|
|
126
|
+
'perspective.subscribeQuery', { uuid, query }
|
|
127
|
+
)
|
|
128
|
+
const { subscriptionId, result } = response
|
|
129
|
+
const parsed = normalizeQueryResult(result, 'Error parsing subscribeQuery result:')
|
|
130
|
+
return { subscriptionId, result: parsed }
|
|
238
131
|
}
|
|
239
132
|
|
|
240
|
-
async
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
variables: { uuid, subscriptionId }
|
|
246
|
-
}))
|
|
133
|
+
async perspectiveKeepAliveQuery(uuid: string, subscriptionId: string): Promise<boolean> {
|
|
134
|
+
return this.#apiClient.call<boolean>(
|
|
135
|
+
'perspective.keepAliveQuery', { uuid, subscriptionId }
|
|
136
|
+
)
|
|
137
|
+
}
|
|
247
138
|
|
|
248
|
-
|
|
139
|
+
async perspectiveDisposeQuerySubscription(uuid: string, subscriptionId: string): Promise<boolean> {
|
|
140
|
+
return this.#apiClient.call<boolean>(
|
|
141
|
+
'perspective.disposeQuery', { uuid, subscriptionId }
|
|
142
|
+
)
|
|
249
143
|
}
|
|
250
144
|
|
|
251
145
|
subscribeToQueryUpdates(subscriptionId: string, onData: (result: AllInstancesResult) => void): () => void {
|
|
252
|
-
const
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
subscriptionId
|
|
260
|
-
}
|
|
261
|
-
}).subscribe({
|
|
262
|
-
next: (result) => {
|
|
263
|
-
if (result.data && result.data.perspectiveQuerySubscription) {
|
|
264
|
-
let finalResult = result.data.perspectiveQuerySubscription;
|
|
265
|
-
let isInit = false;
|
|
266
|
-
if(finalResult.startsWith("#init#")) {
|
|
267
|
-
finalResult = finalResult.substring(6)
|
|
268
|
-
isInit = true;
|
|
269
|
-
}
|
|
270
|
-
try {
|
|
271
|
-
finalResult = JSON.parse(finalResult)
|
|
272
|
-
if(isInit && typeof finalResult === 'object') {
|
|
273
|
-
finalResult.isInit = true;
|
|
274
|
-
}
|
|
275
|
-
} catch (e) {
|
|
276
|
-
console.error('Error parsing perspectiveQuerySubscription:', e)
|
|
277
|
-
}
|
|
278
|
-
onData(finalResult);
|
|
279
|
-
}
|
|
280
|
-
},
|
|
281
|
-
error: (e) => console.error('Error in query subscription:', e)
|
|
282
|
-
});
|
|
146
|
+
const unsub = this.#apiClient.subscribe(
|
|
147
|
+
(data) => {
|
|
148
|
+
const event = data as Record<string, unknown>
|
|
149
|
+
if (event.type !== 'query-subscription-update') return
|
|
150
|
+
|
|
151
|
+
const eventSubscriptionId = event.subscriptionId || event.subscription_id
|
|
152
|
+
if (eventSubscriptionId !== subscriptionId) return
|
|
283
153
|
|
|
284
|
-
|
|
154
|
+
const parsed = normalizeQueryResult(event.result, 'Error parsing query subscription:')
|
|
155
|
+
onData(parsed)
|
|
156
|
+
}
|
|
157
|
+
)
|
|
158
|
+
this.#querySubscriptionUnsubscribers.set(subscriptionId, unsub)
|
|
159
|
+
return unsub
|
|
285
160
|
}
|
|
286
161
|
|
|
287
162
|
async keepAliveQuery(uuid: string, subscriptionId: string): Promise<boolean> {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
}`,
|
|
292
|
-
variables: { uuid, subscriptionId }
|
|
293
|
-
}))
|
|
294
|
-
|
|
295
|
-
return perspectiveKeepAliveQuery
|
|
163
|
+
return this.#apiClient.call<boolean>(
|
|
164
|
+
'perspective.keepAliveQuery', { uuid, subscriptionId }
|
|
165
|
+
)
|
|
296
166
|
}
|
|
297
167
|
|
|
298
168
|
async disposeQuerySubscription(uuid: string, subscriptionId: string): Promise<boolean> {
|
|
299
|
-
const
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
169
|
+
const unsub = this.#querySubscriptionUnsubscribers.get(subscriptionId)
|
|
170
|
+
if (unsub) {
|
|
171
|
+
unsub()
|
|
172
|
+
this.#querySubscriptionUnsubscribers.delete(subscriptionId)
|
|
173
|
+
}
|
|
174
|
+
return this.#apiClient.call<boolean>(
|
|
175
|
+
'perspective.disposeQuery', { uuid, subscriptionId }
|
|
176
|
+
)
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
async modelQuery(uuid: string, className: string, queryJson: string): Promise<any> {
|
|
180
|
+
const resultJson = await this.#apiClient.call<string>(
|
|
181
|
+
'perspective.modelQuery', { uuid, class_name: className, query_json: queryJson }
|
|
182
|
+
)
|
|
183
|
+
return JSON.parse(resultJson)
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
async evaluateGetters(
|
|
187
|
+
uuid: string,
|
|
188
|
+
className: string,
|
|
189
|
+
instanceIds: string[],
|
|
190
|
+
propertyNames?: string[],
|
|
191
|
+
): Promise<Record<string, Record<string, any>>> {
|
|
192
|
+
const resultJson = await this.#apiClient.call<string>(
|
|
193
|
+
'perspective.evaluateGetters', {
|
|
194
|
+
uuid,
|
|
195
|
+
class_name: className,
|
|
196
|
+
instance_ids: instanceIds,
|
|
197
|
+
...(propertyNames && { property_names: propertyNames }),
|
|
198
|
+
}
|
|
199
|
+
)
|
|
200
|
+
return JSON.parse(resultJson)
|
|
201
|
+
}
|
|
305
202
|
|
|
306
|
-
|
|
203
|
+
async modelSubscribe(uuid: string, className: string, queryJson: string): Promise<{ subscriptionId: string, result: any }> {
|
|
204
|
+
const response = await this.#apiClient.call<{ subscription_id: string, result: string }>(
|
|
205
|
+
'perspective.modelSubscribe', { uuid, class_name: className, query_json: queryJson }
|
|
206
|
+
)
|
|
207
|
+
return {
|
|
208
|
+
subscriptionId: response.subscription_id,
|
|
209
|
+
result: JSON.parse(response.result)
|
|
210
|
+
}
|
|
307
211
|
}
|
|
308
212
|
|
|
309
213
|
async add(name: string): Promise<PerspectiveProxy> {
|
|
310
|
-
const
|
|
311
|
-
|
|
312
|
-
perspectiveAdd(name: $name) {
|
|
313
|
-
${PERSPECTIVE_HANDLE_FIELDS}
|
|
314
|
-
}
|
|
315
|
-
}`,
|
|
316
|
-
variables: { name }
|
|
317
|
-
}))
|
|
318
|
-
return new PerspectiveProxy(perspectiveAdd, this)
|
|
214
|
+
const handle = await this.#apiClient.call<PerspectiveHandle>('perspective.create', { name })
|
|
215
|
+
return new PerspectiveProxy(handle, this)
|
|
319
216
|
}
|
|
320
217
|
|
|
321
218
|
async update(uuid: string, name: string): Promise<PerspectiveProxy> {
|
|
322
|
-
const
|
|
323
|
-
|
|
324
|
-
perspectiveUpdate(uuid: $uuid, name: $name) {
|
|
325
|
-
${PERSPECTIVE_HANDLE_FIELDS}
|
|
326
|
-
}
|
|
327
|
-
}`,
|
|
328
|
-
variables: { uuid, name }
|
|
329
|
-
}))
|
|
330
|
-
return new PerspectiveProxy(perspectiveUpdate, this)
|
|
219
|
+
const handle = await this.#apiClient.call<PerspectiveHandle>('perspective.update', { uuid, name })
|
|
220
|
+
return new PerspectiveProxy(handle, this)
|
|
331
221
|
}
|
|
332
222
|
|
|
333
223
|
async remove(uuid: string): Promise<{perspectiveRemove: boolean}> {
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
perspectiveRemove(uuid: $uuid)
|
|
337
|
-
}`,
|
|
338
|
-
variables: { uuid }
|
|
339
|
-
}))
|
|
224
|
+
const result = await this.#apiClient.call<boolean>('perspective.remove', { uuid })
|
|
225
|
+
return { perspectiveRemove: result }
|
|
340
226
|
}
|
|
341
227
|
|
|
342
228
|
async addLink(uuid: string, link: Link, status: LinkStatus = 'shared', batchId?: string): Promise<LinkExpression> {
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
${LINK_EXPRESSION_FIELDS}
|
|
347
|
-
}
|
|
348
|
-
}`,
|
|
349
|
-
variables: { uuid, link, status, batchId }
|
|
350
|
-
}))
|
|
351
|
-
return perspectiveAddLink
|
|
229
|
+
return this.#apiClient.call<LinkExpression>(
|
|
230
|
+
'perspective.addLink', { uuid, link, status, batchId }
|
|
231
|
+
)
|
|
352
232
|
}
|
|
353
233
|
|
|
354
234
|
async addLinks(uuid: string, links: Link[], status: LinkStatus = 'shared', batchId?: string): Promise<LinkExpression[]> {
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
${LINK_EXPRESSION_FIELDS}
|
|
359
|
-
}
|
|
360
|
-
}`,
|
|
361
|
-
variables: { uuid, links, status, batchId }
|
|
362
|
-
}))
|
|
363
|
-
return perspectiveAddLinks
|
|
235
|
+
return this.#apiClient.call<LinkExpression[]>(
|
|
236
|
+
'perspective.addLinks', { uuid, links, status, batchId }
|
|
237
|
+
)
|
|
364
238
|
}
|
|
365
239
|
|
|
366
240
|
async removeLinks(uuid: string, links: LinkExpressionInput[], batchId?: string): Promise<LinkExpression[]> {
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
${LINK_EXPRESSION_FIELDS}
|
|
371
|
-
}
|
|
372
|
-
}`,
|
|
373
|
-
variables: { uuid, links, batchId }
|
|
374
|
-
}))
|
|
375
|
-
return perspectiveRemoveLinks
|
|
241
|
+
return this.#apiClient.call<LinkExpression[]>(
|
|
242
|
+
'perspective.removeLinks', { uuid, links, batchId }
|
|
243
|
+
)
|
|
376
244
|
}
|
|
377
245
|
|
|
378
246
|
async linkMutations(uuid: string, mutations: LinkMutations, status?: LinkStatus): Promise<LinkExpressionMutations> {
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
additions {
|
|
383
|
-
${LINK_EXPRESSION_FIELDS}
|
|
384
|
-
}
|
|
385
|
-
removals {
|
|
386
|
-
${LINK_EXPRESSION_FIELDS}
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
}`,
|
|
390
|
-
variables: { uuid, mutations, status }
|
|
391
|
-
}))
|
|
392
|
-
return perspectiveLinkMutations
|
|
247
|
+
return this.#apiClient.call<LinkExpressionMutations>(
|
|
248
|
+
'perspective.linkMutations', { uuid, mutations, status }
|
|
249
|
+
)
|
|
393
250
|
}
|
|
394
251
|
|
|
395
252
|
async addLinkExpression(uuid: string, link: LinkExpression, status: LinkStatus = 'shared', batchId?: string): Promise<LinkExpression> {
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
${LINK_EXPRESSION_FIELDS}
|
|
400
|
-
}
|
|
401
|
-
}`,
|
|
402
|
-
variables: { uuid, link, status, batchId }
|
|
403
|
-
}))
|
|
404
|
-
return perspectiveAddLinkExpression
|
|
253
|
+
return this.#apiClient.call<LinkExpression>(
|
|
254
|
+
'perspective.addLinkExpression', { uuid, link, status, batchId }
|
|
255
|
+
)
|
|
405
256
|
}
|
|
406
257
|
|
|
407
258
|
async updateLink(uuid: string, oldLink: LinkExpressionInput, newLink: Link, batchId?: string): Promise<LinkExpression> {
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
${LINK_EXPRESSION_FIELDS}
|
|
412
|
-
}
|
|
413
|
-
}`,
|
|
414
|
-
variables: { uuid, oldLink, newLink, batchId }
|
|
415
|
-
}))
|
|
416
|
-
return perspectiveUpdateLink
|
|
259
|
+
return this.#apiClient.call<LinkExpression>(
|
|
260
|
+
'perspective.updateLink', { uuid, oldLink, newLink, batchId }
|
|
261
|
+
)
|
|
417
262
|
}
|
|
418
263
|
|
|
419
264
|
async removeLink(uuid: string, link: LinkExpressionInput, batchId?: string): Promise<boolean> {
|
|
@@ -421,68 +266,48 @@ export class PerspectiveClient {
|
|
|
421
266
|
delete link.data.__typename
|
|
422
267
|
delete link.proof.__typename
|
|
423
268
|
delete link.status
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
}))
|
|
430
|
-
return perspectiveRemoveLink
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
/**
|
|
434
|
-
* Adds Social DNA code to a perspective.
|
|
435
|
-
*
|
|
436
|
-
* Preferred usage: pass shaclJson (from SHACLShape.toJSON()) as the primary schema definition.
|
|
437
|
-
* The sdnaCode parameter is kept for backward compatibility but SHACL is the source of truth
|
|
438
|
-
* for all SDNA operations. Prolog engines remain available for complex queries.
|
|
439
|
-
*
|
|
440
|
-
* @param sdnaCode - Legacy Prolog code (pass empty string when using shaclJson)
|
|
441
|
-
* @param shaclJson - SHACL JSON string from SHACLShape.toJSON() (recommended)
|
|
442
|
-
*/
|
|
269
|
+
return this.#apiClient.call<boolean>(
|
|
270
|
+
'perspective.removeLink', { uuid, link, batchId }
|
|
271
|
+
)
|
|
272
|
+
}
|
|
273
|
+
|
|
443
274
|
async addSdna(uuid: string, name: string, sdnaCode: string | undefined, sdnaType: "subject_class" | "flow" | "custom", shaclJson?: string): Promise<boolean> {
|
|
444
|
-
return
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
275
|
+
return this.#apiClient.call<boolean>(
|
|
276
|
+
'perspective.addSdna', { uuid, name, sdnaCode: sdnaCode || "", sdnaType, shaclJson }
|
|
277
|
+
)
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
async addSdnaBatch(uuid: string, entries: { name: string; sdnaCode?: string; sdnaType: "subject_class" | "flow" | "custom"; shaclJson?: string }[]): Promise<boolean[]> {
|
|
281
|
+
return this.#apiClient.call<boolean[]>(
|
|
282
|
+
'perspective.addSdna', { uuid, entries: entries.map(e => ({ ...e, sdnaCode: e.sdnaCode || "" })) }
|
|
283
|
+
)
|
|
450
284
|
}
|
|
451
285
|
|
|
452
286
|
async executeCommands(uuid: string, commands: string, expression: string, parameters: string, batchId?: string): Promise<boolean> {
|
|
453
|
-
return
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
}`,
|
|
457
|
-
variables: { uuid, commands, expression, parameters, batchId }
|
|
458
|
-
})).perspectiveExecuteCommands
|
|
287
|
+
return this.#apiClient.call<boolean>(
|
|
288
|
+
'perspective.executeCommands', { uuid, commands, expression, parameters, batchId }
|
|
289
|
+
)
|
|
459
290
|
}
|
|
460
291
|
|
|
461
292
|
async createSubject(uuid: string, subjectClass: string, expressionAddress: string, initialValues?: string, batchId?: string): Promise<boolean> {
|
|
462
|
-
return
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
}`,
|
|
466
|
-
variables: { uuid, subjectClass, expressionAddress, initialValues, batchId }
|
|
467
|
-
})).perspectiveCreateSubject
|
|
293
|
+
return this.#apiClient.call<boolean>(
|
|
294
|
+
'perspective.createSubject', { uuid, subjectClass, expressionAddress, initialValues, batchId }
|
|
295
|
+
)
|
|
468
296
|
}
|
|
469
297
|
|
|
470
298
|
async getSubjectData(uuid: string, subjectClass: string, expressionAddress: string): Promise<string> {
|
|
471
|
-
return
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
}`,
|
|
475
|
-
variables: { uuid, subjectClass, expressionAddress }
|
|
476
|
-
})).perspectiveGetSubjectData
|
|
299
|
+
return this.#apiClient.call<string>(
|
|
300
|
+
'perspective.getSubjectData', { uuid, subjectClass, expressionAddress }
|
|
301
|
+
)
|
|
477
302
|
}
|
|
478
303
|
|
|
479
304
|
// ExpressionClient functions, needed for Subjects:
|
|
480
305
|
async getExpression(expressionURI: string): Promise<ExpressionRendered> {
|
|
481
|
-
return await this.#expressionClient
|
|
306
|
+
return await this.#expressionClient!.get(expressionURI)
|
|
482
307
|
}
|
|
483
308
|
|
|
484
|
-
async createExpression(content:
|
|
485
|
-
return await this.#expressionClient
|
|
309
|
+
async createExpression(content: unknown, languageAddress: string): Promise<string> {
|
|
310
|
+
return await this.#expressionClient!.create(content, languageAddress)
|
|
486
311
|
}
|
|
487
312
|
|
|
488
313
|
// Subscriptions:
|
|
@@ -491,18 +316,12 @@ export class PerspectiveClient {
|
|
|
491
316
|
}
|
|
492
317
|
|
|
493
318
|
subscribePerspectiveAdded() {
|
|
494
|
-
this.#
|
|
495
|
-
|
|
496
|
-
|
|
319
|
+
const unsub = this.#apiClient.subscribe((data) => {
|
|
320
|
+
if (data.type === 'perspective-added') {
|
|
321
|
+
this.#perspectiveAddedCallbacks.forEach(cb => cb(data.perspective as PerspectiveHandle))
|
|
497
322
|
}
|
|
498
|
-
`}).subscribe({
|
|
499
|
-
next: result => {
|
|
500
|
-
this.#perspectiveAddedCallbacks.forEach(cb => {
|
|
501
|
-
cb(result.data.perspectiveAdded)
|
|
502
|
-
})
|
|
503
|
-
},
|
|
504
|
-
error: (e) => console.error(e)
|
|
505
323
|
})
|
|
324
|
+
this.#unsubscribers.push(unsub)
|
|
506
325
|
}
|
|
507
326
|
|
|
508
327
|
addPerspectiveUpdatedListener(cb: PerspectiveHandleCallback) {
|
|
@@ -510,18 +329,12 @@ export class PerspectiveClient {
|
|
|
510
329
|
}
|
|
511
330
|
|
|
512
331
|
subscribePerspectiveUpdated() {
|
|
513
|
-
this.#
|
|
514
|
-
|
|
515
|
-
|
|
332
|
+
const unsub = this.#apiClient.subscribe((data) => {
|
|
333
|
+
if (data.type === 'perspective-updated') {
|
|
334
|
+
this.#perspectiveUpdatedCallbacks.forEach(cb => cb(data.perspective as PerspectiveHandle))
|
|
516
335
|
}
|
|
517
|
-
`}).subscribe({
|
|
518
|
-
next: result => {
|
|
519
|
-
this.#perspectiveUpdatedCallbacks.forEach(cb => {
|
|
520
|
-
cb(result.data.perspectiveUpdated)
|
|
521
|
-
})
|
|
522
|
-
},
|
|
523
|
-
error: (e) => console.error(e)
|
|
524
336
|
})
|
|
337
|
+
this.#unsubscribers.push(unsub)
|
|
525
338
|
}
|
|
526
339
|
|
|
527
340
|
addPerspectiveSyncedListener(cb: SyncStateChangeCallback) {
|
|
@@ -529,19 +342,14 @@ export class PerspectiveClient {
|
|
|
529
342
|
}
|
|
530
343
|
|
|
531
344
|
async addPerspectiveSyncStateChangeListener(uuid: String, cb: SyncStateChangeCallback[]): Promise<void> {
|
|
532
|
-
this.#
|
|
533
|
-
|
|
534
|
-
|
|
345
|
+
const unsub = this.#apiClient.subscribe(
|
|
346
|
+
(data) => {
|
|
347
|
+
if (data.type === 'sync-state-change' && data.uuid === uuid) {
|
|
348
|
+
cb.forEach(c => c(data.state as PerspectiveState))
|
|
349
|
+
}
|
|
535
350
|
}
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
cb.forEach(c => {
|
|
539
|
-
c(result.data.perspectiveSyncStateChange)
|
|
540
|
-
})
|
|
541
|
-
},
|
|
542
|
-
error: (e) => console.error(e)
|
|
543
|
-
})
|
|
544
|
-
|
|
351
|
+
)
|
|
352
|
+
this.#unsubscribers.push(unsub)
|
|
545
353
|
await new Promise<void>(resolve => setTimeout(resolve, 500))
|
|
546
354
|
}
|
|
547
355
|
|
|
@@ -550,115 +358,91 @@ export class PerspectiveClient {
|
|
|
550
358
|
}
|
|
551
359
|
|
|
552
360
|
subscribePerspectiveRemoved() {
|
|
553
|
-
this.#
|
|
554
|
-
|
|
555
|
-
|
|
361
|
+
const unsub = this.#apiClient.subscribe((data) => {
|
|
362
|
+
if (data.type === 'perspective-removed') {
|
|
363
|
+
this.#perspectiveRemovedCallbacks.forEach(cb => cb(data.uuid as string))
|
|
556
364
|
}
|
|
557
|
-
`}).subscribe({
|
|
558
|
-
next: result => {
|
|
559
|
-
this.#perspectiveRemovedCallbacks.forEach(cb => {
|
|
560
|
-
cb(result.data.perspectiveRemoved)
|
|
561
|
-
})
|
|
562
|
-
},
|
|
563
|
-
error: (e) => console.error(e)
|
|
564
365
|
})
|
|
366
|
+
this.#unsubscribers.push(unsub)
|
|
565
367
|
}
|
|
566
368
|
|
|
567
369
|
async addPerspectiveLinkAddedListener(uuid: String, cb: LinkCallback[]): Promise<void> {
|
|
568
|
-
this.#
|
|
569
|
-
|
|
570
|
-
|
|
370
|
+
const unsub = this.#apiClient.subscribe(
|
|
371
|
+
(data) => {
|
|
372
|
+
if (data.type === 'link-added' && data.perspectiveUuid === uuid) {
|
|
373
|
+
cb.forEach(c => c(data.link as LinkExpression))
|
|
374
|
+
}
|
|
571
375
|
}
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
},
|
|
578
|
-
error: (e) => console.error(e)
|
|
579
|
-
})
|
|
580
|
-
|
|
581
|
-
await new Promise<void>(resolve => setTimeout(resolve, 500))
|
|
376
|
+
)
|
|
377
|
+
let existing = this.#linkUnsubscribers.get(uuid as string) || []
|
|
378
|
+
existing.push(unsub)
|
|
379
|
+
this.#linkUnsubscribers.set(uuid as string, existing)
|
|
380
|
+
await this.#apiClient.waitForSubscription()
|
|
582
381
|
}
|
|
583
382
|
|
|
584
383
|
async addPerspectiveLinkRemovedListener(uuid: String, cb: LinkCallback[]): Promise<void> {
|
|
585
|
-
this.#
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
cb.forEach(c => {
|
|
592
|
-
if (!result.data.perspectiveLinkRemoved.status) {
|
|
593
|
-
delete result.data.perspectiveLinkRemoved.status
|
|
384
|
+
const unsub = this.#apiClient.subscribe(
|
|
385
|
+
(data) => {
|
|
386
|
+
if (data.type === 'link-removed' && data.perspectiveUuid === uuid) {
|
|
387
|
+
const link = data.link as LinkExpression & { status?: unknown }
|
|
388
|
+
if (!link.status) {
|
|
389
|
+
delete link.status
|
|
594
390
|
}
|
|
595
|
-
c(
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
391
|
+
cb.forEach(c => c(link))
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
)
|
|
395
|
+
let existing = this.#linkUnsubscribers.get(uuid as string) || []
|
|
396
|
+
existing.push(unsub)
|
|
397
|
+
this.#linkUnsubscribers.set(uuid as string, existing)
|
|
398
|
+
await this.#apiClient.waitForSubscription()
|
|
602
399
|
}
|
|
603
400
|
|
|
604
401
|
async addPerspectiveLinkUpdatedListener(uuid: String, cb: LinkCallback[]): Promise<void> {
|
|
605
|
-
this.#
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
402
|
+
const unsub = this.#apiClient.subscribe(
|
|
403
|
+
(data) => {
|
|
404
|
+
if (data.type === 'link-updated' && data.perspectiveUuid === uuid) {
|
|
405
|
+
const newLink = data.newLink as LinkExpression & { status?: unknown }
|
|
406
|
+
const oldLink = data.oldLink as LinkExpression & { status?: unknown }
|
|
407
|
+
if (!newLink.status) {
|
|
408
|
+
delete newLink.status
|
|
610
409
|
}
|
|
611
|
-
|
|
612
|
-
|
|
410
|
+
if (!oldLink.status) {
|
|
411
|
+
delete oldLink.status
|
|
613
412
|
}
|
|
413
|
+
cb.forEach(c => c(data as unknown as LinkExpression))
|
|
614
414
|
}
|
|
615
415
|
}
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
416
|
+
)
|
|
417
|
+
let existing = this.#linkUnsubscribers.get(uuid as string) || []
|
|
418
|
+
existing.push(unsub)
|
|
419
|
+
this.#linkUnsubscribers.set(uuid as string, existing)
|
|
420
|
+
await this.#apiClient.waitForSubscription()
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/** Unsubscribe all link/sync-state listeners registered for the given perspective UUID.
|
|
424
|
+
* Called by PerspectiveProxy.dispose() to prevent subscription leaks. */
|
|
425
|
+
removeAllListeners(uuid: string): void {
|
|
426
|
+
const unsubs = this.#linkUnsubscribers.get(uuid)
|
|
427
|
+
if (unsubs) {
|
|
428
|
+
for (const fn of unsubs) {
|
|
429
|
+
try { fn() } catch {}
|
|
430
|
+
}
|
|
431
|
+
this.#linkUnsubscribers.delete(uuid)
|
|
432
|
+
}
|
|
632
433
|
}
|
|
633
434
|
|
|
634
435
|
getNeighbourhoodProxy(uuid: string): NeighbourhoodProxy {
|
|
635
|
-
return new NeighbourhoodProxy(this.#neighbourhoodClient
|
|
436
|
+
return new NeighbourhoodProxy(this.#neighbourhoodClient!, uuid)
|
|
636
437
|
}
|
|
637
438
|
|
|
638
439
|
async createBatch(uuid: string): Promise<string> {
|
|
639
|
-
|
|
640
|
-
mutation: gql`mutation perspectiveCreateBatch($uuid: String!) {
|
|
641
|
-
perspectiveCreateBatch(uuid: $uuid)
|
|
642
|
-
}`,
|
|
643
|
-
variables: { uuid }
|
|
644
|
-
}))
|
|
645
|
-
return perspectiveCreateBatch
|
|
440
|
+
return this.#apiClient.call<string>('perspective.createBatch', { uuid })
|
|
646
441
|
}
|
|
647
442
|
|
|
648
443
|
async commitBatch(uuid: string, batchId: string): Promise<LinkExpressionMutations> {
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
additions {
|
|
653
|
-
${LINK_EXPRESSION_FIELDS}
|
|
654
|
-
}
|
|
655
|
-
removals {
|
|
656
|
-
${LINK_EXPRESSION_FIELDS}
|
|
657
|
-
}
|
|
658
|
-
}
|
|
659
|
-
}`,
|
|
660
|
-
variables: { uuid, batchId }
|
|
661
|
-
}))
|
|
662
|
-
return perspectiveCommitBatch
|
|
444
|
+
return this.#apiClient.call<LinkExpressionMutations>(
|
|
445
|
+
'perspective.commitBatch', { uuid, batchId }
|
|
446
|
+
)
|
|
663
447
|
}
|
|
664
|
-
}
|
|
448
|
+
}
|