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