@coasys/ad4m 0.13.0-test-3 → 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 +2406 -11070
- package/lib/index.js +2209 -10925
- 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 -1
- package/lib/src/index.js +6 -1
- 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 +1 -1
- package/lib/src/language/Language.js +10 -76
- 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 +57 -38
- package/lib/src/model/Ad4mModel.js +594 -460
- package/lib/src/model/Ad4mModel.test.js +371 -815
- package/lib/src/model/ModelQueryBuilder.d.ts +9 -21
- package/lib/src/model/ModelQueryBuilder.js +138 -217
- package/lib/src/model/decorators.d.ts +22 -0
- package/lib/src/model/decorators.js +7 -0
- package/lib/src/model/hydration.d.ts +7 -60
- package/lib/src/model/hydration.js +7 -716
- 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 +4 -67
- package/lib/src/model/query-sparql.js +26 -322
- package/lib/src/model/query-sparql.test.js +35 -218
- package/lib/src/model/shacl-gen.js +4 -0
- package/lib/src/model/types.d.ts +47 -38
- 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 -17
- package/lib/src/perspectives/PerspectiveClient.js +169 -429
- package/lib/src/perspectives/PerspectiveClient.test.js +55 -0
- package/lib/src/perspectives/PerspectiveDiff.js +4 -31
- package/lib/src/perspectives/PerspectiveHandle.js +3 -43
- package/lib/src/perspectives/PerspectiveProxy.d.ts +92 -71
- package/lib/src/perspectives/PerspectiveProxy.js +273 -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 +1179 -1340
- 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 -1
- package/src/jestSetup.ts +1 -1
- package/src/language/Icon.ts +0 -4
- package/src/language/Language.ts +2 -23
- 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 +708 -876
- package/src/model/Ad4mModel.ts +613 -508
- package/src/model/ModelQueryBuilder.ts +178 -244
- package/src/model/decorators.ts +29 -0
- package/src/model/hydration.ts +9 -766
- package/src/model/index.ts +0 -4
- package/src/model/query-sparql.test.ts +34 -242
- package/src/model/query-sparql.ts +27 -337
- package/src/model/shacl-gen.ts +5 -0
- package/src/model/types.ts +51 -39
- 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 +206 -148
- package/src/perspectives/PerspectiveClient.ts +228 -442
- 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 +307 -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/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/LanguageResolver.ts +0 -98
- package/src/model/Subject.ts +0 -159
- package/src/model/hydration-batch.ts +0 -205
- package/src/model/hydration-batching.test.ts +0 -563
- 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-delta.test.ts +0 -207
- package/src/model/subscription-pool.ts +0 -211
- 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
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ApiClient } from "../apiClient"
|
|
2
2
|
import { Address } from "../Address"
|
|
3
3
|
import { DID } from "../DID"
|
|
4
4
|
import { OnlineAgent, TelepresenceSignalCallback } from "../language/Language"
|
|
5
5
|
import { Perspective, PerspectiveUnsignedInput } from "../perspectives/Perspective"
|
|
6
6
|
import { PerspectiveHandle } from "../perspectives/PerspectiveHandle"
|
|
7
|
-
import unwrapApolloResult from "../unwrapApolloResult"
|
|
8
7
|
import { NeighbourhoodProxy } from "./NeighbourhoodProxy"
|
|
8
|
+
import type { JoinNeighbourhoodRequest, PublishNeighbourhoodRequest } from "../generated/api"
|
|
9
9
|
|
|
10
10
|
export class NeighbourhoodClient {
|
|
11
|
-
#
|
|
11
|
+
#apiClient: ApiClient
|
|
12
12
|
#signalHandlers: Map<string, TelepresenceSignalCallback[]> = new Map()
|
|
13
|
+
#signalUnsubscribers: Map<string, () => void> = new Map()
|
|
13
14
|
|
|
14
|
-
constructor(
|
|
15
|
-
this.#
|
|
15
|
+
constructor(baseUrl: string, token?: string, sharedApiClient?: ApiClient) {
|
|
16
|
+
this.#apiClient = sharedApiClient || new ApiClient(baseUrl, token)
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
async publishFromPerspective(
|
|
@@ -20,209 +21,60 @@ export class NeighbourhoodClient {
|
|
|
20
21
|
linkLanguage: Address,
|
|
21
22
|
meta: Perspective
|
|
22
23
|
): Promise<string> {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
$meta: PerspectiveInput!,
|
|
27
|
-
$perspectiveUUID: String!
|
|
28
|
-
) {
|
|
29
|
-
neighbourhoodPublishFromPerspective(
|
|
30
|
-
linkLanguage: $linkLanguage,
|
|
31
|
-
meta: $meta,
|
|
32
|
-
perspectiveUUID: $perspectiveUUID
|
|
33
|
-
)
|
|
34
|
-
}`,
|
|
35
|
-
variables: { perspectiveUUID, linkLanguage, meta: meta}
|
|
36
|
-
}))
|
|
37
|
-
return neighbourhoodPublishFromPerspective
|
|
24
|
+
return this.#apiClient.call<string>('neighbourhood.publish', {
|
|
25
|
+
perspectiveUUID, linkLanguage, meta
|
|
26
|
+
})
|
|
38
27
|
}
|
|
39
28
|
|
|
40
29
|
async joinFromUrl(url: string): Promise<PerspectiveHandle> {
|
|
41
|
-
|
|
42
|
-
mutation: gql`mutation neighbourhoodJoinFromUrl($url: String!) {
|
|
43
|
-
neighbourhoodJoinFromUrl(url: $url) {
|
|
44
|
-
uuid
|
|
45
|
-
name
|
|
46
|
-
sharedUrl
|
|
47
|
-
state
|
|
48
|
-
neighbourhood {
|
|
49
|
-
data {
|
|
50
|
-
linkLanguage
|
|
51
|
-
meta {
|
|
52
|
-
links
|
|
53
|
-
{
|
|
54
|
-
author
|
|
55
|
-
timestamp
|
|
56
|
-
data { source, predicate, target }
|
|
57
|
-
proof { valid, invalid, signature, key }
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
author
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}`,
|
|
65
|
-
variables: { url }
|
|
66
|
-
}))
|
|
67
|
-
return neighbourhoodJoinFromUrl
|
|
30
|
+
return this.#apiClient.call<PerspectiveHandle>('neighbourhood.join', { url })
|
|
68
31
|
}
|
|
69
32
|
|
|
70
33
|
async otherAgents(perspectiveUUID: string): Promise<DID[]> {
|
|
71
|
-
|
|
72
|
-
query: gql`query neighbourhoodOtherAgents($perspectiveUUID: String!) {
|
|
73
|
-
neighbourhoodOtherAgents(perspectiveUUID: $perspectiveUUID)
|
|
74
|
-
}`,
|
|
75
|
-
variables: { perspectiveUUID }
|
|
76
|
-
}))
|
|
77
|
-
return neighbourhoodOtherAgents
|
|
34
|
+
return this.#apiClient.call<DID[]>('neighbourhood.otherAgents', { uuid: perspectiveUUID })
|
|
78
35
|
}
|
|
79
36
|
|
|
80
37
|
async hasTelepresenceAdapter(perspectiveUUID: string): Promise<boolean> {
|
|
81
|
-
|
|
82
|
-
query: gql`query neighbourhoodHasTelepresenceAdapter($perspectiveUUID: String!) {
|
|
83
|
-
neighbourhoodHasTelepresenceAdapter(perspectiveUUID: $perspectiveUUID)
|
|
84
|
-
}`,
|
|
85
|
-
variables: { perspectiveUUID }
|
|
86
|
-
}))
|
|
87
|
-
return neighbourhoodHasTelepresenceAdapter
|
|
38
|
+
return this.#apiClient.call<boolean>('neighbourhood.hasTelepresence', { uuid: perspectiveUUID })
|
|
88
39
|
}
|
|
89
40
|
|
|
90
41
|
async onlineAgents(perspectiveUUID: string): Promise<OnlineAgent[]> {
|
|
91
|
-
|
|
92
|
-
query: gql`query neighbourhoodOnlineAgents($perspectiveUUID: String!) {
|
|
93
|
-
neighbourhoodOnlineAgents(perspectiveUUID: $perspectiveUUID) {
|
|
94
|
-
did
|
|
95
|
-
status {
|
|
96
|
-
author
|
|
97
|
-
timestamp
|
|
98
|
-
data {
|
|
99
|
-
links {
|
|
100
|
-
author
|
|
101
|
-
timestamp
|
|
102
|
-
data { source, predicate, target }
|
|
103
|
-
proof { valid, invalid, signature, key }
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
proof { valid, invalid, signature, key }
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}`,
|
|
110
|
-
variables: { perspectiveUUID }
|
|
111
|
-
}))
|
|
112
|
-
return neighbourhoodOnlineAgents
|
|
42
|
+
return this.#apiClient.call<OnlineAgent[]>('neighbourhood.onlineAgents', { uuid: perspectiveUUID })
|
|
113
43
|
}
|
|
114
44
|
|
|
115
45
|
async setOnlineStatus(perspectiveUUID: string, status: Perspective): Promise<boolean> {
|
|
116
|
-
|
|
117
|
-
mutation: gql`mutation neighbourhoodSetOnlineStatus(
|
|
118
|
-
$perspectiveUUID: String!,
|
|
119
|
-
$status: PerspectiveInput!
|
|
120
|
-
) {
|
|
121
|
-
neighbourhoodSetOnlineStatus(
|
|
122
|
-
perspectiveUUID: $perspectiveUUID,
|
|
123
|
-
status: $status
|
|
124
|
-
)
|
|
125
|
-
}`,
|
|
126
|
-
variables: { perspectiveUUID, status }
|
|
127
|
-
}))
|
|
128
|
-
|
|
129
|
-
return neighbourhoodSetOnlineStatus
|
|
46
|
+
return this.#apiClient.call<boolean>('neighbourhood.setOnlineStatus', { uuid: perspectiveUUID, status })
|
|
130
47
|
}
|
|
131
48
|
|
|
132
49
|
async setOnlineStatusU(perspectiveUUID: string, status: PerspectiveUnsignedInput): Promise<boolean> {
|
|
133
|
-
|
|
134
|
-
mutation: gql`mutation neighbourhoodSetOnlineStatusU(
|
|
135
|
-
$perspectiveUUID: String!,
|
|
136
|
-
$status: PerspectiveUnsignedInput!
|
|
137
|
-
) {
|
|
138
|
-
neighbourhoodSetOnlineStatusU(
|
|
139
|
-
perspectiveUUID: $perspectiveUUID,
|
|
140
|
-
status: $status
|
|
141
|
-
)
|
|
142
|
-
}`,
|
|
143
|
-
variables: { perspectiveUUID, status }
|
|
144
|
-
}))
|
|
145
|
-
|
|
146
|
-
return neighbourhoodSetOnlineStatusU
|
|
50
|
+
return this.#apiClient.call<boolean>('neighbourhood.setOnlineStatus', { uuid: perspectiveUUID, status, signed: false })
|
|
147
51
|
}
|
|
148
52
|
|
|
149
53
|
async sendSignal(perspectiveUUID: string, remoteAgentDid: string, payload: Perspective): Promise<boolean> {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
$remoteAgentDid: String!,
|
|
154
|
-
$payload: PerspectiveInput!
|
|
155
|
-
) {
|
|
156
|
-
neighbourhoodSendSignal(
|
|
157
|
-
perspectiveUUID: $perspectiveUUID,
|
|
158
|
-
remoteAgentDid: $remoteAgentDid,
|
|
159
|
-
payload: $payload
|
|
160
|
-
)
|
|
161
|
-
}`,
|
|
162
|
-
variables: { perspectiveUUID, remoteAgentDid, payload }
|
|
163
|
-
}))
|
|
164
|
-
|
|
165
|
-
return neighbourhoodSendSignal
|
|
54
|
+
return this.#apiClient.call<boolean>('neighbourhood.sendSignal', {
|
|
55
|
+
uuid: perspectiveUUID, remoteAgentDid, payload
|
|
56
|
+
})
|
|
166
57
|
}
|
|
167
58
|
|
|
168
59
|
async sendSignalU(perspectiveUUID: string, remoteAgentDid: string, payload: PerspectiveUnsignedInput): Promise<boolean> {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
$remoteAgentDid: String!,
|
|
173
|
-
$payload: PerspectiveUnsignedInput!
|
|
174
|
-
) {
|
|
175
|
-
neighbourhoodSendSignalU(
|
|
176
|
-
perspectiveUUID: $perspectiveUUID,
|
|
177
|
-
remoteAgentDid: $remoteAgentDid,
|
|
178
|
-
payload: $payload
|
|
179
|
-
)
|
|
180
|
-
}`,
|
|
181
|
-
variables: { perspectiveUUID, remoteAgentDid, payload }
|
|
182
|
-
}))
|
|
183
|
-
|
|
184
|
-
return neighbourhoodSendSignalU
|
|
60
|
+
return this.#apiClient.call<boolean>('neighbourhood.sendSignal', {
|
|
61
|
+
uuid: perspectiveUUID, remoteAgentDid, payload, signed: false
|
|
62
|
+
})
|
|
185
63
|
}
|
|
186
64
|
|
|
187
65
|
async sendBroadcast(perspectiveUUID: string, payload: Perspective, loopback: boolean = false): Promise<boolean> {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
$payload: PerspectiveInput!,
|
|
192
|
-
$loopback: Boolean
|
|
193
|
-
) {
|
|
194
|
-
neighbourhoodSendBroadcast(
|
|
195
|
-
perspectiveUUID: $perspectiveUUID,
|
|
196
|
-
payload: $payload,
|
|
197
|
-
loopback: $loopback
|
|
198
|
-
)
|
|
199
|
-
}`,
|
|
200
|
-
variables: { perspectiveUUID, payload, loopback }
|
|
201
|
-
}))
|
|
202
|
-
|
|
203
|
-
return neighbourhoodSendBroadcast
|
|
66
|
+
return this.#apiClient.call<boolean>('neighbourhood.sendBroadcast', {
|
|
67
|
+
uuid: perspectiveUUID, payload, loopback
|
|
68
|
+
})
|
|
204
69
|
}
|
|
205
70
|
|
|
206
71
|
async sendBroadcastU(perspectiveUUID: string, payload: PerspectiveUnsignedInput, loopback: boolean = false): Promise<boolean> {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
$payload: PerspectiveUnsignedInput!,
|
|
211
|
-
$loopback: Boolean
|
|
212
|
-
) {
|
|
213
|
-
neighbourhoodSendBroadcastU(
|
|
214
|
-
perspectiveUUID: $perspectiveUUID,
|
|
215
|
-
payload: $payload,
|
|
216
|
-
loopback: $loopback
|
|
217
|
-
)
|
|
218
|
-
}`,
|
|
219
|
-
variables: { perspectiveUUID, payload, loopback }
|
|
220
|
-
}))
|
|
221
|
-
|
|
222
|
-
return neighbourhoodSendBroadcastU
|
|
72
|
+
return this.#apiClient.call<boolean>('neighbourhood.sendBroadcast', {
|
|
73
|
+
uuid: perspectiveUUID, payload, loopback, signed: false
|
|
74
|
+
})
|
|
223
75
|
}
|
|
224
76
|
|
|
225
|
-
dispatchSignal(perspectiveUUID:string, signal:
|
|
77
|
+
dispatchSignal(perspectiveUUID: string, signal: unknown) {
|
|
226
78
|
const handlers = this.#signalHandlers.get(perspectiveUUID)
|
|
227
79
|
if (handlers) {
|
|
228
80
|
for (const handler of handlers) {
|
|
@@ -236,38 +88,14 @@ export class NeighbourhoodClient {
|
|
|
236
88
|
}
|
|
237
89
|
|
|
238
90
|
async subscribeToSignals(perspectiveUUID: string): Promise<void> {
|
|
239
|
-
const
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
author
|
|
244
|
-
timestamp
|
|
245
|
-
data {
|
|
246
|
-
links
|
|
247
|
-
{
|
|
248
|
-
author
|
|
249
|
-
timestamp
|
|
250
|
-
data { source, predicate, target }
|
|
251
|
-
proof { valid, invalid, signature, key }
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
proof { valid, invalid, signature, key }
|
|
91
|
+
const unsub = this.#apiClient.subscribe(
|
|
92
|
+
(data) => {
|
|
93
|
+
if (data.type === 'signal') {
|
|
94
|
+
this.dispatchSignal(perspectiveUUID, data.signal)
|
|
255
95
|
}
|
|
256
|
-
}`,
|
|
257
|
-
variables: { perspectiveUUID }
|
|
258
|
-
}).subscribe({
|
|
259
|
-
next: (result: FetchResult<any>) => {
|
|
260
|
-
try {
|
|
261
|
-
const { neighbourhoodSignal } = unwrapApolloResult(result)
|
|
262
|
-
that.dispatchSignal(perspectiveUUID, neighbourhoodSignal)
|
|
263
|
-
} catch(e) {
|
|
264
|
-
console.error("Error in signal subscription:", e)
|
|
265
|
-
}
|
|
266
|
-
},
|
|
267
|
-
error: (err: any) => {
|
|
268
|
-
console.error("Signal subscription error for perspective", perspectiveUUID, err)
|
|
269
96
|
}
|
|
270
|
-
|
|
97
|
+
)
|
|
98
|
+
this.#signalUnsubscribers.set(perspectiveUUID, unsub)
|
|
271
99
|
}
|
|
272
100
|
|
|
273
101
|
async addSignalHandler(perspectiveUUID: string, handler: TelepresenceSignalCallback): Promise<void> {
|
|
@@ -275,7 +103,6 @@ export class NeighbourhoodClient {
|
|
|
275
103
|
if (!handlersForPerspective) {
|
|
276
104
|
handlersForPerspective = []
|
|
277
105
|
this.#signalHandlers.set(perspectiveUUID, handlersForPerspective)
|
|
278
|
-
// Push handler BEFORE subscribing so it's available when signals arrive
|
|
279
106
|
handlersForPerspective.push(handler)
|
|
280
107
|
await this.subscribeToSignals(perspectiveUUID)
|
|
281
108
|
} else {
|
|
@@ -290,6 +117,14 @@ export class NeighbourhoodClient {
|
|
|
290
117
|
if (index > -1) {
|
|
291
118
|
handlersForPerspective.splice(index, 1)
|
|
292
119
|
}
|
|
120
|
+
if (handlersForPerspective.length === 0) {
|
|
121
|
+
this.#signalHandlers.delete(perspectiveUUID)
|
|
122
|
+
const unsub = this.#signalUnsubscribers.get(perspectiveUUID)
|
|
123
|
+
if (unsub) {
|
|
124
|
+
unsub()
|
|
125
|
+
this.#signalUnsubscribers.delete(perspectiveUUID)
|
|
126
|
+
}
|
|
127
|
+
}
|
|
293
128
|
}
|
|
294
129
|
}
|
|
295
130
|
}
|
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
import { NeighbourhoodClient } from "./NeighbourhoodClient";
|
|
2
2
|
import { NeighbourhoodProxy } from "./NeighbourhoodProxy";
|
|
3
3
|
|
|
4
|
+
// Mock ApiClient's subscribe to avoid real WebSocket connections
|
|
5
|
+
jest.mock('../apiClient', () => {
|
|
6
|
+
return {
|
|
7
|
+
ApiClient: jest.fn().mockImplementation(() => ({
|
|
8
|
+
get: jest.fn(),
|
|
9
|
+
post: jest.fn(),
|
|
10
|
+
put: jest.fn(),
|
|
11
|
+
delete: jest.fn(),
|
|
12
|
+
subscribe: jest.fn().mockReturnValue(() => {}),
|
|
13
|
+
}))
|
|
14
|
+
};
|
|
15
|
+
});
|
|
16
|
+
|
|
4
17
|
describe("NeighbourhoodProxy", () => {
|
|
5
18
|
it("should add multiple signal handlers", async () => {
|
|
6
19
|
const neighbourhoodURI = "did://123";
|
|
7
20
|
|
|
8
|
-
const
|
|
9
|
-
subscribe: () => ({
|
|
10
|
-
subscribe: () =>
|
|
11
|
-
new Promise((resolve) => {
|
|
12
|
-
setTimeout(() => {
|
|
13
|
-
resolve({});
|
|
14
|
-
}, 10);
|
|
15
|
-
}),
|
|
16
|
-
}),
|
|
17
|
-
} as any;
|
|
18
|
-
|
|
19
|
-
const neighbourhoodClient = new NeighbourhoodClient(mockApolloClient);
|
|
21
|
+
const neighbourhoodClient = new NeighbourhoodClient("http://localhost:0", "test-token");
|
|
20
22
|
const neighbourhoodProxy = new NeighbourhoodProxy(
|
|
21
23
|
neighbourhoodClient,
|
|
22
24
|
neighbourhoodURI
|
|
@@ -31,7 +33,7 @@ describe("NeighbourhoodProxy", () => {
|
|
|
31
33
|
callbacks++;
|
|
32
34
|
};
|
|
33
35
|
|
|
34
|
-
// Add multiple signal handlers in
|
|
36
|
+
// Add multiple signal handlers in parallel
|
|
35
37
|
const promise = neighbourhoodProxy.addSignalHandler(handler1);
|
|
36
38
|
neighbourhoodProxy.addSignalHandler(handler2);
|
|
37
39
|
await promise;
|
|
@@ -44,23 +46,21 @@ describe("NeighbourhoodProxy", () => {
|
|
|
44
46
|
it("should not add multiple subscriptions when removing and adding another signal handler", async () => {
|
|
45
47
|
const neighbourhoodURI = "did://123";
|
|
46
48
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
subscribe: () => ({
|
|
59
|
-
subscribe,
|
|
49
|
+
// Track subscribe calls via the mock
|
|
50
|
+
let subscribeCallCount = 0;
|
|
51
|
+
const { ApiClient } = jest.requireMock('../apiClient');
|
|
52
|
+
ApiClient.mockImplementation(() => ({
|
|
53
|
+
get: jest.fn(),
|
|
54
|
+
post: jest.fn(),
|
|
55
|
+
put: jest.fn(),
|
|
56
|
+
delete: jest.fn(),
|
|
57
|
+
subscribe: jest.fn().mockImplementation(() => {
|
|
58
|
+
subscribeCallCount++;
|
|
59
|
+
return () => {};
|
|
60
60
|
}),
|
|
61
|
-
}
|
|
61
|
+
}));
|
|
62
62
|
|
|
63
|
-
const neighbourhoodClient = new NeighbourhoodClient(
|
|
63
|
+
const neighbourhoodClient = new NeighbourhoodClient("http://localhost:0", "test-token");
|
|
64
64
|
const neighbourhoodProxy = new NeighbourhoodProxy(
|
|
65
65
|
neighbourhoodClient,
|
|
66
66
|
neighbourhoodURI
|
|
@@ -79,21 +79,19 @@ describe("NeighbourhoodProxy", () => {
|
|
|
79
79
|
// Add signal handler 1
|
|
80
80
|
await neighbourhoodProxy.addSignalHandler(handler1);
|
|
81
81
|
|
|
82
|
-
// Remove signal handler
|
|
82
|
+
// Remove signal handler 1
|
|
83
83
|
neighbourhoodProxy.removeSignalHandler(handler1);
|
|
84
84
|
|
|
85
85
|
// Add signal handler 2
|
|
86
86
|
await neighbourhoodProxy.addSignalHandler(handler2);
|
|
87
87
|
|
|
88
|
-
// Check that
|
|
89
|
-
expect(
|
|
88
|
+
// Check that subscription was re-created (handler1 removed = unsub, handler2 added = new sub)
|
|
89
|
+
expect(subscribeCallCount).toBe(2);
|
|
90
90
|
|
|
91
|
-
//
|
|
92
|
-
|
|
93
|
-
subscription.next({ data: { signal: { neighbourhoodSignal: true } } });
|
|
94
|
-
}
|
|
91
|
+
// Dispatch signal
|
|
92
|
+
neighbourhoodClient.dispatchSignal(neighbourhoodURI, true);
|
|
95
93
|
|
|
96
|
-
// Check that only
|
|
94
|
+
// Check that only handler2 was called (handler1 was removed)
|
|
97
95
|
expect(callbacks1).toBe(0);
|
|
98
96
|
expect(callbacks2).toBe(1);
|
|
99
97
|
});
|
|
@@ -1,25 +1,10 @@
|
|
|
1
|
-
import { Field, InputType, ObjectType } from "type-graphql";
|
|
2
1
|
import { Link } from "../links/Links"
|
|
3
|
-
|
|
4
|
-
@ObjectType()
|
|
5
|
-
@InputType()
|
|
6
2
|
export class LinkQuery {
|
|
7
|
-
@Field({nullable: true})
|
|
8
3
|
source?: string;
|
|
9
|
-
|
|
10
|
-
@Field({nullable: true})
|
|
11
4
|
target?: string;
|
|
12
|
-
|
|
13
|
-
@Field({nullable: true})
|
|
14
5
|
predicate?: string;
|
|
15
|
-
|
|
16
|
-
@Field({nullable: true})
|
|
17
6
|
fromDate?: Date;
|
|
18
|
-
|
|
19
|
-
@Field({nullable: true})
|
|
20
7
|
untilDate?: Date;
|
|
21
|
-
|
|
22
|
-
@Field({nullable: true})
|
|
23
8
|
limit?: number;
|
|
24
9
|
|
|
25
10
|
constructor(obj: object) {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Field, ObjectType, InputType } from "type-graphql";
|
|
2
1
|
import { ExpressionGeneric } from "../expression/Expression";
|
|
3
2
|
import { Link, LinkExpression, LinkExpressionInput, LinkInput } from "../links/Links";
|
|
4
3
|
import { LinkQuery } from "./LinkQuery";
|
|
@@ -13,12 +12,10 @@ import { LinkQuery } from "./LinkQuery";
|
|
|
13
12
|
*
|
|
14
13
|
* The types PerspectiveProxy and PerspectiveHandle are used when dealing
|
|
15
14
|
* with an instantiated mutable perspective as is done through most of
|
|
16
|
-
* the
|
|
15
|
+
* the AD4M API.
|
|
17
16
|
*/
|
|
18
|
-
@ObjectType()
|
|
19
17
|
export class Perspective {
|
|
20
18
|
/** The content of the perspective, a list/graph of links */
|
|
21
|
-
@Field(type => [LinkExpression])
|
|
22
19
|
links: LinkExpression[]
|
|
23
20
|
|
|
24
21
|
constructor(links?: LinkExpression[]) {
|
|
@@ -88,16 +85,10 @@ export class Perspective {
|
|
|
88
85
|
}
|
|
89
86
|
|
|
90
87
|
}
|
|
91
|
-
|
|
92
|
-
@InputType()
|
|
93
88
|
export class PerspectiveInput {
|
|
94
|
-
@Field(type => [LinkExpressionInput])
|
|
95
89
|
links: LinkExpressionInput[]
|
|
96
90
|
}
|
|
97
|
-
|
|
98
|
-
@InputType()
|
|
99
91
|
export class PerspectiveUnsignedInput {
|
|
100
|
-
@Field(type => [LinkInput])
|
|
101
92
|
links: LinkInput[]
|
|
102
93
|
|
|
103
94
|
constructor(links?: LinkInput[]) {
|
|
@@ -113,6 +104,4 @@ export class PerspectiveUnsignedInput {
|
|
|
113
104
|
return obj
|
|
114
105
|
}
|
|
115
106
|
}
|
|
116
|
-
|
|
117
|
-
@ObjectType()
|
|
118
107
|
export class PerspectiveExpression extends ExpressionGeneric(Perspective) {};
|