@coasys/ad4m 0.12.1-dev → 0.13.0-postmessage-ws-proxy.0
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 +5097 -11841
- package/lib/index.js +5289 -12104
- 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 +7 -2
- package/lib/src/index.js +7 -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 +150 -62
- package/lib/src/model/Ad4mModel.js +689 -417
- package/lib/src/model/Ad4mModel.test.js +1434 -688
- package/lib/src/model/ModelQueryBuilder.d.ts +59 -38
- package/lib/src/model/ModelQueryBuilder.js +317 -153
- 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 +46 -18
- 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 +60 -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 +189 -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 +156 -78
- package/lib/src/perspectives/PerspectiveProxy.js +474 -389
- package/lib/src/perspectives/PerspectiveResolver.d.ts +0 -1
- package/lib/src/perspectives/PerspectiveResolver.js +0 -11
- 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 +8 -1
- package/lib/src/shacl/SHACLShape.js +57 -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 +6 -18
- 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 +7 -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 +1690 -777
- package/src/model/Ad4mModel.ts +749 -477
- package/src/model/ModelQueryBuilder.ts +356 -171
- 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 +15 -15
- package/src/model/sdna.ts +1 -1
- package/src/model/shacl-gen.ts +47 -17
- package/src/model/types.ts +65 -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 +254 -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/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 +94 -0
- package/src/shacl/SHACLShape.ts +66 -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,194 @@ 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(uuid: string, query: string): Promise<unknown> {
|
|
120
|
+
const result = await this.#apiClient.call<string>('perspective.querySparql', { uuid, engine: 'sparql', query })
|
|
121
|
+
return JSON.parse(result)
|
|
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, shapeJson?: string): Promise<any> {
|
|
180
|
+
const resultJson = await this.#apiClient.call<string>(
|
|
181
|
+
'perspective.modelQuery', { uuid, class_name: className, query_json: queryJson, shape_json: shapeJson }
|
|
182
|
+
)
|
|
183
|
+
return JSON.parse(resultJson)
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
async evaluateGetters(
|
|
187
|
+
uuid: string,
|
|
188
|
+
className: string,
|
|
189
|
+
instanceIds: string[],
|
|
190
|
+
shapeJson: string,
|
|
191
|
+
propertyNames?: string[],
|
|
192
|
+
): Promise<Record<string, Record<string, any>>> {
|
|
193
|
+
const resultJson = await this.#apiClient.call<string>(
|
|
194
|
+
'perspective.evaluateGetters', {
|
|
195
|
+
uuid,
|
|
196
|
+
class_name: className,
|
|
197
|
+
instance_ids: instanceIds,
|
|
198
|
+
shape_json: shapeJson,
|
|
199
|
+
...(propertyNames && { property_names: propertyNames }),
|
|
200
|
+
}
|
|
201
|
+
)
|
|
202
|
+
return JSON.parse(resultJson)
|
|
203
|
+
}
|
|
305
204
|
|
|
306
|
-
|
|
205
|
+
async modelSubscribe(uuid: string, className: string, queryJson: string, shapeJson?: string): Promise<{ subscriptionId: string, result: any }> {
|
|
206
|
+
const response = await this.#apiClient.call<{ subscription_id: string, result: string }>(
|
|
207
|
+
'perspective.modelSubscribe', { uuid, class_name: className, query_json: queryJson, shape_json: shapeJson }
|
|
208
|
+
)
|
|
209
|
+
return {
|
|
210
|
+
subscriptionId: response.subscription_id,
|
|
211
|
+
result: JSON.parse(response.result)
|
|
212
|
+
}
|
|
307
213
|
}
|
|
308
214
|
|
|
309
215
|
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)
|
|
216
|
+
const handle = await this.#apiClient.call<PerspectiveHandle>('perspective.create', { name })
|
|
217
|
+
return new PerspectiveProxy(handle, this)
|
|
319
218
|
}
|
|
320
219
|
|
|
321
220
|
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)
|
|
221
|
+
const handle = await this.#apiClient.call<PerspectiveHandle>('perspective.update', { uuid, name })
|
|
222
|
+
return new PerspectiveProxy(handle, this)
|
|
331
223
|
}
|
|
332
224
|
|
|
333
225
|
async remove(uuid: string): Promise<{perspectiveRemove: boolean}> {
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
perspectiveRemove(uuid: $uuid)
|
|
337
|
-
}`,
|
|
338
|
-
variables: { uuid }
|
|
339
|
-
}))
|
|
226
|
+
const result = await this.#apiClient.call<boolean>('perspective.remove', { uuid })
|
|
227
|
+
return { perspectiveRemove: result }
|
|
340
228
|
}
|
|
341
229
|
|
|
342
230
|
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
|
|
231
|
+
return this.#apiClient.call<LinkExpression>(
|
|
232
|
+
'perspective.addLink', { uuid, link, status, batchId }
|
|
233
|
+
)
|
|
352
234
|
}
|
|
353
235
|
|
|
354
236
|
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
|
|
237
|
+
return this.#apiClient.call<LinkExpression[]>(
|
|
238
|
+
'perspective.addLinks', { uuid, links, status, batchId }
|
|
239
|
+
)
|
|
364
240
|
}
|
|
365
241
|
|
|
366
242
|
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
|
|
243
|
+
return this.#apiClient.call<LinkExpression[]>(
|
|
244
|
+
'perspective.removeLinks', { uuid, links, batchId }
|
|
245
|
+
)
|
|
376
246
|
}
|
|
377
247
|
|
|
378
248
|
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
|
|
249
|
+
return this.#apiClient.call<LinkExpressionMutations>(
|
|
250
|
+
'perspective.linkMutations', { uuid, mutations, status }
|
|
251
|
+
)
|
|
393
252
|
}
|
|
394
253
|
|
|
395
254
|
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
|
|
255
|
+
return this.#apiClient.call<LinkExpression>(
|
|
256
|
+
'perspective.addLinkExpression', { uuid, link, status, batchId }
|
|
257
|
+
)
|
|
405
258
|
}
|
|
406
259
|
|
|
407
260
|
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
|
|
261
|
+
return this.#apiClient.call<LinkExpression>(
|
|
262
|
+
'perspective.updateLink', { uuid, oldLink, newLink, batchId }
|
|
263
|
+
)
|
|
417
264
|
}
|
|
418
265
|
|
|
419
266
|
async removeLink(uuid: string, link: LinkExpressionInput, batchId?: string): Promise<boolean> {
|
|
@@ -421,68 +268,48 @@ export class PerspectiveClient {
|
|
|
421
268
|
delete link.data.__typename
|
|
422
269
|
delete link.proof.__typename
|
|
423
270
|
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
|
-
*/
|
|
271
|
+
return this.#apiClient.call<boolean>(
|
|
272
|
+
'perspective.removeLink', { uuid, link, batchId }
|
|
273
|
+
)
|
|
274
|
+
}
|
|
275
|
+
|
|
443
276
|
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
|
-
|
|
277
|
+
return this.#apiClient.call<boolean>(
|
|
278
|
+
'perspective.addSdna', { uuid, name, sdnaCode: sdnaCode || "", sdnaType, shaclJson }
|
|
279
|
+
)
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
async addSdnaBatch(uuid: string, entries: { name: string; sdnaCode?: string; sdnaType: "subject_class" | "flow" | "custom"; shaclJson?: string }[]): Promise<boolean[]> {
|
|
283
|
+
return this.#apiClient.call<boolean[]>(
|
|
284
|
+
'perspective.addSdna', { uuid, entries: entries.map(e => ({ ...e, sdnaCode: e.sdnaCode || "" })) }
|
|
285
|
+
)
|
|
450
286
|
}
|
|
451
287
|
|
|
452
288
|
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
|
|
289
|
+
return this.#apiClient.call<boolean>(
|
|
290
|
+
'perspective.executeCommands', { uuid, commands, expression, parameters, batchId }
|
|
291
|
+
)
|
|
459
292
|
}
|
|
460
293
|
|
|
461
294
|
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
|
|
295
|
+
return this.#apiClient.call<boolean>(
|
|
296
|
+
'perspective.createSubject', { uuid, subjectClass, expressionAddress, initialValues, batchId }
|
|
297
|
+
)
|
|
468
298
|
}
|
|
469
299
|
|
|
470
300
|
async getSubjectData(uuid: string, subjectClass: string, expressionAddress: string): Promise<string> {
|
|
471
|
-
return
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
}`,
|
|
475
|
-
variables: { uuid, subjectClass, expressionAddress }
|
|
476
|
-
})).perspectiveGetSubjectData
|
|
301
|
+
return this.#apiClient.call<string>(
|
|
302
|
+
'perspective.getSubjectData', { uuid, subjectClass, expressionAddress }
|
|
303
|
+
)
|
|
477
304
|
}
|
|
478
305
|
|
|
479
306
|
// ExpressionClient functions, needed for Subjects:
|
|
480
307
|
async getExpression(expressionURI: string): Promise<ExpressionRendered> {
|
|
481
|
-
return await this.#expressionClient
|
|
308
|
+
return await this.#expressionClient!.get(expressionURI)
|
|
482
309
|
}
|
|
483
310
|
|
|
484
|
-
async createExpression(content:
|
|
485
|
-
return await this.#expressionClient
|
|
311
|
+
async createExpression(content: unknown, languageAddress: string): Promise<string> {
|
|
312
|
+
return await this.#expressionClient!.create(content, languageAddress)
|
|
486
313
|
}
|
|
487
314
|
|
|
488
315
|
// Subscriptions:
|
|
@@ -491,18 +318,12 @@ export class PerspectiveClient {
|
|
|
491
318
|
}
|
|
492
319
|
|
|
493
320
|
subscribePerspectiveAdded() {
|
|
494
|
-
this.#
|
|
495
|
-
|
|
496
|
-
|
|
321
|
+
const unsub = this.#apiClient.subscribe((data) => {
|
|
322
|
+
if (data.type === 'perspective-added') {
|
|
323
|
+
this.#perspectiveAddedCallbacks.forEach(cb => cb(data.perspective as PerspectiveHandle))
|
|
497
324
|
}
|
|
498
|
-
`}).subscribe({
|
|
499
|
-
next: result => {
|
|
500
|
-
this.#perspectiveAddedCallbacks.forEach(cb => {
|
|
501
|
-
cb(result.data.perspectiveAdded)
|
|
502
|
-
})
|
|
503
|
-
},
|
|
504
|
-
error: (e) => console.error(e)
|
|
505
325
|
})
|
|
326
|
+
this.#unsubscribers.push(unsub)
|
|
506
327
|
}
|
|
507
328
|
|
|
508
329
|
addPerspectiveUpdatedListener(cb: PerspectiveHandleCallback) {
|
|
@@ -510,18 +331,12 @@ export class PerspectiveClient {
|
|
|
510
331
|
}
|
|
511
332
|
|
|
512
333
|
subscribePerspectiveUpdated() {
|
|
513
|
-
this.#
|
|
514
|
-
|
|
515
|
-
|
|
334
|
+
const unsub = this.#apiClient.subscribe((data) => {
|
|
335
|
+
if (data.type === 'perspective-updated') {
|
|
336
|
+
this.#perspectiveUpdatedCallbacks.forEach(cb => cb(data.perspective as PerspectiveHandle))
|
|
516
337
|
}
|
|
517
|
-
`}).subscribe({
|
|
518
|
-
next: result => {
|
|
519
|
-
this.#perspectiveUpdatedCallbacks.forEach(cb => {
|
|
520
|
-
cb(result.data.perspectiveUpdated)
|
|
521
|
-
})
|
|
522
|
-
},
|
|
523
|
-
error: (e) => console.error(e)
|
|
524
338
|
})
|
|
339
|
+
this.#unsubscribers.push(unsub)
|
|
525
340
|
}
|
|
526
341
|
|
|
527
342
|
addPerspectiveSyncedListener(cb: SyncStateChangeCallback) {
|
|
@@ -529,19 +344,14 @@ export class PerspectiveClient {
|
|
|
529
344
|
}
|
|
530
345
|
|
|
531
346
|
async addPerspectiveSyncStateChangeListener(uuid: String, cb: SyncStateChangeCallback[]): Promise<void> {
|
|
532
|
-
this.#
|
|
533
|
-
|
|
534
|
-
|
|
347
|
+
const unsub = this.#apiClient.subscribe(
|
|
348
|
+
(data) => {
|
|
349
|
+
if (data.type === 'sync-state-change' && data.uuid === uuid) {
|
|
350
|
+
cb.forEach(c => c(data.state as PerspectiveState))
|
|
351
|
+
}
|
|
535
352
|
}
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
cb.forEach(c => {
|
|
539
|
-
c(result.data.perspectiveSyncStateChange)
|
|
540
|
-
})
|
|
541
|
-
},
|
|
542
|
-
error: (e) => console.error(e)
|
|
543
|
-
})
|
|
544
|
-
|
|
353
|
+
)
|
|
354
|
+
this.#unsubscribers.push(unsub)
|
|
545
355
|
await new Promise<void>(resolve => setTimeout(resolve, 500))
|
|
546
356
|
}
|
|
547
357
|
|
|
@@ -550,115 +360,91 @@ export class PerspectiveClient {
|
|
|
550
360
|
}
|
|
551
361
|
|
|
552
362
|
subscribePerspectiveRemoved() {
|
|
553
|
-
this.#
|
|
554
|
-
|
|
555
|
-
|
|
363
|
+
const unsub = this.#apiClient.subscribe((data) => {
|
|
364
|
+
if (data.type === 'perspective-removed') {
|
|
365
|
+
this.#perspectiveRemovedCallbacks.forEach(cb => cb(data.uuid as string))
|
|
556
366
|
}
|
|
557
|
-
`}).subscribe({
|
|
558
|
-
next: result => {
|
|
559
|
-
this.#perspectiveRemovedCallbacks.forEach(cb => {
|
|
560
|
-
cb(result.data.perspectiveRemoved)
|
|
561
|
-
})
|
|
562
|
-
},
|
|
563
|
-
error: (e) => console.error(e)
|
|
564
367
|
})
|
|
368
|
+
this.#unsubscribers.push(unsub)
|
|
565
369
|
}
|
|
566
370
|
|
|
567
371
|
async addPerspectiveLinkAddedListener(uuid: String, cb: LinkCallback[]): Promise<void> {
|
|
568
|
-
this.#
|
|
569
|
-
|
|
570
|
-
|
|
372
|
+
const unsub = this.#apiClient.subscribe(
|
|
373
|
+
(data) => {
|
|
374
|
+
if (data.type === 'link-added' && data.perspectiveUuid === uuid) {
|
|
375
|
+
cb.forEach(c => c(data.link as LinkExpression))
|
|
376
|
+
}
|
|
571
377
|
}
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
},
|
|
578
|
-
error: (e) => console.error(e)
|
|
579
|
-
})
|
|
580
|
-
|
|
581
|
-
await new Promise<void>(resolve => setTimeout(resolve, 500))
|
|
378
|
+
)
|
|
379
|
+
let existing = this.#linkUnsubscribers.get(uuid as string) || []
|
|
380
|
+
existing.push(unsub)
|
|
381
|
+
this.#linkUnsubscribers.set(uuid as string, existing)
|
|
382
|
+
await this.#apiClient.waitForSubscription()
|
|
582
383
|
}
|
|
583
384
|
|
|
584
385
|
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
|
|
386
|
+
const unsub = this.#apiClient.subscribe(
|
|
387
|
+
(data) => {
|
|
388
|
+
if (data.type === 'link-removed' && data.perspectiveUuid === uuid) {
|
|
389
|
+
const link = data.link as LinkExpression & { status?: unknown }
|
|
390
|
+
if (!link.status) {
|
|
391
|
+
delete link.status
|
|
594
392
|
}
|
|
595
|
-
c(
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
393
|
+
cb.forEach(c => c(link))
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
)
|
|
397
|
+
let existing = this.#linkUnsubscribers.get(uuid as string) || []
|
|
398
|
+
existing.push(unsub)
|
|
399
|
+
this.#linkUnsubscribers.set(uuid as string, existing)
|
|
400
|
+
await this.#apiClient.waitForSubscription()
|
|
602
401
|
}
|
|
603
402
|
|
|
604
403
|
async addPerspectiveLinkUpdatedListener(uuid: String, cb: LinkCallback[]): Promise<void> {
|
|
605
|
-
this.#
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
404
|
+
const unsub = this.#apiClient.subscribe(
|
|
405
|
+
(data) => {
|
|
406
|
+
if (data.type === 'link-updated' && data.perspectiveUuid === uuid) {
|
|
407
|
+
const newLink = data.newLink as LinkExpression & { status?: unknown }
|
|
408
|
+
const oldLink = data.oldLink as LinkExpression & { status?: unknown }
|
|
409
|
+
if (!newLink.status) {
|
|
410
|
+
delete newLink.status
|
|
610
411
|
}
|
|
611
|
-
|
|
612
|
-
|
|
412
|
+
if (!oldLink.status) {
|
|
413
|
+
delete oldLink.status
|
|
613
414
|
}
|
|
415
|
+
cb.forEach(c => c(data as unknown as LinkExpression))
|
|
614
416
|
}
|
|
615
417
|
}
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
418
|
+
)
|
|
419
|
+
let existing = this.#linkUnsubscribers.get(uuid as string) || []
|
|
420
|
+
existing.push(unsub)
|
|
421
|
+
this.#linkUnsubscribers.set(uuid as string, existing)
|
|
422
|
+
await this.#apiClient.waitForSubscription()
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
/** Unsubscribe all link/sync-state listeners registered for the given perspective UUID.
|
|
426
|
+
* Called by PerspectiveProxy.dispose() to prevent subscription leaks. */
|
|
427
|
+
removeAllListeners(uuid: string): void {
|
|
428
|
+
const unsubs = this.#linkUnsubscribers.get(uuid)
|
|
429
|
+
if (unsubs) {
|
|
430
|
+
for (const fn of unsubs) {
|
|
431
|
+
try { fn() } catch {}
|
|
432
|
+
}
|
|
433
|
+
this.#linkUnsubscribers.delete(uuid)
|
|
434
|
+
}
|
|
632
435
|
}
|
|
633
436
|
|
|
634
437
|
getNeighbourhoodProxy(uuid: string): NeighbourhoodProxy {
|
|
635
|
-
return new NeighbourhoodProxy(this.#neighbourhoodClient
|
|
438
|
+
return new NeighbourhoodProxy(this.#neighbourhoodClient!, uuid)
|
|
636
439
|
}
|
|
637
440
|
|
|
638
441
|
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
|
|
442
|
+
return this.#apiClient.call<string>('perspective.createBatch', { uuid })
|
|
646
443
|
}
|
|
647
444
|
|
|
648
445
|
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
|
|
446
|
+
return this.#apiClient.call<LinkExpressionMutations>(
|
|
447
|
+
'perspective.commitBatch', { uuid, batchId }
|
|
448
|
+
)
|
|
663
449
|
}
|
|
664
|
-
}
|
|
450
|
+
}
|