@coasys/ad4m 0.13.0-test-3 → 0.13.0-test-5
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 +6717 -15519
- package/lib/index.js +4811 -13662
- package/lib/src/Ad4mClient.d.ts +7 -3
- package/lib/src/Ad4mClient.js +39 -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 +76 -44
- package/lib/src/model/Ad4mModel.js +635 -479
- package/lib/src/model/Ad4mModel.test.js +371 -815
- package/lib/src/model/ModelQueryBuilder.d.ts +15 -27
- package/lib/src/model/ModelQueryBuilder.js +163 -224
- package/lib/src/model/decorators.d.ts +22 -0
- package/lib/src/model/decorators.js +7 -0
- package/lib/src/model/hydration.d.ts +3 -93
- package/lib/src/model/hydration.js +3 -970
- 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/query-utils.d.ts +1 -0
- package/lib/src/model/query-utils.js +46 -1
- package/lib/src/model/shacl-gen.js +4 -0
- package/lib/src/model/types.d.ts +51 -43
- 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 +13 -17
- package/lib/src/perspectives/PerspectiveClient.js +179 -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 +106 -71
- package/lib/src/perspectives/PerspectiveProxy.js +289 -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 +6 -18
- package/rollup.config.js +0 -7
- package/src/Ad4mClient.test.ts +1179 -1340
- package/src/Ad4mClient.ts +40 -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 +766 -1173
- package/src/model/Ad4mModel.ts +664 -529
- package/src/model/ModelQueryBuilder.ts +203 -251
- package/src/model/decorators.ts +29 -0
- package/src/model/hydration.ts +3 -1037
- 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/query-utils.ts +47 -2
- package/src/model/shacl-gen.ts +5 -0
- package/src/model/types.ts +55 -44
- 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 +247 -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 +331 -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
package/src/agent/AgentClient.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ApiClient } from "../apiClient";
|
|
2
2
|
import { PerspectiveInput } from "../perspectives/Perspective";
|
|
3
|
-
import unwrapApolloResult from "../unwrapApolloResult";
|
|
4
3
|
import {
|
|
5
4
|
Agent,
|
|
6
5
|
Apps,
|
|
@@ -10,67 +9,20 @@ import {
|
|
|
10
9
|
EntanglementProofInput,
|
|
11
10
|
UserCreationResult,
|
|
12
11
|
} from "./Agent";
|
|
13
|
-
import { HostingUserInfo, PaymentRequestResult, ComputeLogEntry } from "../runtime/
|
|
12
|
+
import { HostingUserInfo, PaymentRequestResult, ComputeLogEntry } from "../runtime/RuntimeTypes";
|
|
14
13
|
import { AgentStatus } from "./AgentStatus";
|
|
15
|
-
import { LinkMutations } from "../links/Links";
|
|
14
|
+
import { LinkMutations, LinkExpression } from "../links/Links";
|
|
16
15
|
import { PerspectiveClient } from "../perspectives/PerspectiveClient";
|
|
17
|
-
import { VerificationRequestResult } from "../runtime/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
data {
|
|
29
|
-
source, predicate, target
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
`;
|
|
34
|
-
|
|
35
|
-
const Apps_FIELDS = `
|
|
36
|
-
requestId
|
|
37
|
-
revoked
|
|
38
|
-
auth {
|
|
39
|
-
appName
|
|
40
|
-
appDesc
|
|
41
|
-
appUrl
|
|
42
|
-
appIconPath
|
|
43
|
-
capabilities {
|
|
44
|
-
with {
|
|
45
|
-
domain
|
|
46
|
-
pointers
|
|
47
|
-
}
|
|
48
|
-
can
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
`;
|
|
52
|
-
|
|
53
|
-
const AGENT_STATUS_FIELDS = `
|
|
54
|
-
isInitialized
|
|
55
|
-
isUnlocked
|
|
56
|
-
did
|
|
57
|
-
didDocument
|
|
58
|
-
error
|
|
59
|
-
`;
|
|
60
|
-
|
|
61
|
-
const ENTANGLEMENT_PROOF_FIELDS = `
|
|
62
|
-
did
|
|
63
|
-
didSigningKeyId
|
|
64
|
-
deviceKeyType
|
|
65
|
-
deviceKey
|
|
66
|
-
deviceKeySignedByDid
|
|
67
|
-
didSignedByDeviceKey
|
|
68
|
-
`;
|
|
69
|
-
|
|
70
|
-
const AGENT_SIGNATURE_FIELDS = `
|
|
71
|
-
signature
|
|
72
|
-
publicKey
|
|
73
|
-
`;
|
|
16
|
+
import { VerificationRequestResult } from "../runtime/RuntimeTypes";
|
|
17
|
+
import type {
|
|
18
|
+
GenerateAgentRequest,
|
|
19
|
+
ImportAgentRequest,
|
|
20
|
+
LockAgentRequest,
|
|
21
|
+
UnlockAgentRequest,
|
|
22
|
+
SignMessageRequest,
|
|
23
|
+
PermitCapabilityRequest,
|
|
24
|
+
GenerateJwtRequest,
|
|
25
|
+
} from "../generated/api";
|
|
74
26
|
|
|
75
27
|
export interface InitializeArgs {
|
|
76
28
|
did: string;
|
|
@@ -79,31 +31,33 @@ export interface InitializeArgs {
|
|
|
79
31
|
passphrase: string;
|
|
80
32
|
}
|
|
81
33
|
|
|
82
|
-
export type AgentUpdatedCallback = (agent: Agent) =>
|
|
83
|
-
export type AgentStatusChangedCallback = (agent: Agent) =>
|
|
84
|
-
export type AgentAppsUpdatedCallback = () =>
|
|
34
|
+
export type AgentUpdatedCallback = (agent: Agent) => void;
|
|
35
|
+
export type AgentStatusChangedCallback = (agent: Agent) => void;
|
|
36
|
+
export type AgentAppsUpdatedCallback = () => void;
|
|
85
37
|
export type HostingUserInfoChangedCallback = (info: HostingUserInfo) => void;
|
|
86
38
|
export type ComputeLogUpdatedCallback = (entry: ComputeLogEntry) => void;
|
|
87
|
-
|
|
88
|
-
* Provides access to all functions regarding the local agent,
|
|
89
|
-
* such as generating, locking, unlocking, importing the DID keystore,
|
|
90
|
-
* as well as updating the publicly shared Agent expression.
|
|
91
|
-
*/
|
|
39
|
+
|
|
92
40
|
export class AgentClient {
|
|
93
|
-
#
|
|
41
|
+
#apiClient: ApiClient;
|
|
42
|
+
#baseUrl: string;
|
|
43
|
+
#token?: string;
|
|
94
44
|
#appsChangedCallback: AgentAppsUpdatedCallback[];
|
|
95
45
|
#updatedCallbacks: AgentUpdatedCallback[];
|
|
96
46
|
#agentStatusChangedCallbacks: AgentStatusChangedCallback[];
|
|
97
47
|
#hostingUserInfoChangedCallbacks: HostingUserInfoChangedCallback[];
|
|
98
48
|
#computeLogUpdatedCallbacks: ComputeLogUpdatedCallback[];
|
|
49
|
+
#unsubscribers: (() => void)[];
|
|
99
50
|
|
|
100
|
-
constructor(
|
|
101
|
-
this.#
|
|
51
|
+
constructor(baseUrl: string, token?: string, subscribe: boolean = true, sharedApiClient?: ApiClient) {
|
|
52
|
+
this.#baseUrl = baseUrl;
|
|
53
|
+
this.#token = token;
|
|
54
|
+
this.#apiClient = sharedApiClient || new ApiClient(baseUrl, token);
|
|
102
55
|
this.#updatedCallbacks = [];
|
|
103
56
|
this.#agentStatusChangedCallbacks = [];
|
|
104
57
|
this.#appsChangedCallback = [];
|
|
105
58
|
this.#hostingUserInfoChangedCallbacks = [];
|
|
106
59
|
this.#computeLogUpdatedCallbacks = [];
|
|
60
|
+
this.#unsubscribers = [];
|
|
107
61
|
|
|
108
62
|
if (subscribe) {
|
|
109
63
|
this.subscribeAgentUpdated();
|
|
@@ -112,155 +66,68 @@ export class AgentClient {
|
|
|
112
66
|
}
|
|
113
67
|
}
|
|
114
68
|
|
|
115
|
-
/**
|
|
116
|
-
* Returns the Agent expression of the local agent as it is shared
|
|
117
|
-
* publicly via the AgentLanguage.
|
|
118
|
-
*
|
|
119
|
-
* I.e. this is the users profile.
|
|
120
|
-
*/
|
|
121
69
|
async me(): Promise<Agent> {
|
|
122
|
-
const
|
|
123
|
-
await this.#apolloClient.query({
|
|
124
|
-
query: gql`query agent { agent { ${AGENT_SUBITEMS} } }`,
|
|
125
|
-
})
|
|
126
|
-
);
|
|
70
|
+
const agent = await this.#apiClient.call<Agent>('agent.get');
|
|
127
71
|
let agentObject = new Agent(agent.did, agent.perspective);
|
|
128
72
|
agentObject.directMessageLanguage = agent.directMessageLanguage;
|
|
129
73
|
return agentObject;
|
|
130
74
|
}
|
|
131
75
|
|
|
132
76
|
async status(): Promise<AgentStatus> {
|
|
133
|
-
const
|
|
134
|
-
await this.#apolloClient.query({
|
|
135
|
-
query: gql`query agentStatus {
|
|
136
|
-
agentStatus {
|
|
137
|
-
${AGENT_STATUS_FIELDS}
|
|
138
|
-
}
|
|
139
|
-
}`,
|
|
140
|
-
})
|
|
141
|
-
);
|
|
77
|
+
const agentStatus = await this.#apiClient.call<AgentStatus>('agent.status');
|
|
142
78
|
return new AgentStatus(agentStatus);
|
|
143
79
|
}
|
|
144
80
|
|
|
145
81
|
async generate(passphrase: string): Promise<AgentStatus> {
|
|
146
|
-
const {
|
|
147
|
-
|
|
148
|
-
mutation: gql`mutation agentGenerate(
|
|
149
|
-
$passphrase: String!
|
|
150
|
-
) {
|
|
151
|
-
agentGenerate(passphrase: $passphrase) {
|
|
152
|
-
${AGENT_STATUS_FIELDS}
|
|
153
|
-
}
|
|
154
|
-
}`,
|
|
155
|
-
variables: { passphrase },
|
|
156
|
-
})
|
|
157
|
-
);
|
|
158
|
-
return new AgentStatus(agentGenerate);
|
|
82
|
+
const result = await this.#apiClient.call<AgentStatus>('agent.generate', { passphrase });
|
|
83
|
+
return new AgentStatus(result);
|
|
159
84
|
}
|
|
160
85
|
|
|
161
86
|
async import(args: InitializeArgs): Promise<AgentStatus> {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
await this.#apolloClient.mutate({
|
|
165
|
-
mutation: gql`mutation agentImport(
|
|
166
|
-
$did: String!,
|
|
167
|
-
$didDocument: String!,
|
|
168
|
-
$keystore: String!,
|
|
169
|
-
$passphrase: String!
|
|
170
|
-
) {
|
|
171
|
-
agentImport(did: $did, didDocument: $didDocument, keystore: $keystore, passphrase: $passphrase) {
|
|
172
|
-
${AGENT_STATUS_FIELDS}
|
|
173
|
-
}
|
|
174
|
-
}`,
|
|
175
|
-
variables: { did, didDocument, keystore, passphrase },
|
|
176
|
-
})
|
|
177
|
-
);
|
|
178
|
-
return new AgentStatus(agentImport);
|
|
87
|
+
const result = await this.#apiClient.call<AgentStatus>('agent.import', { ...args });
|
|
88
|
+
return new AgentStatus(result);
|
|
179
89
|
}
|
|
180
90
|
|
|
181
91
|
async lock(passphrase: string): Promise<AgentStatus> {
|
|
182
|
-
const {
|
|
183
|
-
|
|
184
|
-
mutation: gql`mutation agentLock($passphrase: String!) {
|
|
185
|
-
agentLock(passphrase: $passphrase) {
|
|
186
|
-
${AGENT_STATUS_FIELDS}
|
|
187
|
-
}
|
|
188
|
-
}`,
|
|
189
|
-
variables: { passphrase },
|
|
190
|
-
})
|
|
191
|
-
);
|
|
192
|
-
return new AgentStatus(agentLock);
|
|
92
|
+
const result = await this.#apiClient.call<AgentStatus>('agent.lock', { passphrase });
|
|
93
|
+
return new AgentStatus(result);
|
|
193
94
|
}
|
|
194
95
|
|
|
195
96
|
async unlock(passphrase: string, holochain = true): Promise<AgentStatus> {
|
|
196
|
-
const {
|
|
197
|
-
|
|
198
|
-
mutation: gql`mutation agentUnlock($passphrase: String!, $holochain: Boolean!) {
|
|
199
|
-
agentUnlock(passphrase: $passphrase, holochain: $holochain) {
|
|
200
|
-
${AGENT_STATUS_FIELDS}
|
|
201
|
-
}
|
|
202
|
-
}`,
|
|
203
|
-
variables: { passphrase, holochain },
|
|
204
|
-
})
|
|
205
|
-
);
|
|
206
|
-
return new AgentStatus(agentUnlock);
|
|
97
|
+
const result = await this.#apiClient.call<AgentStatus>('agent.unlock', { passphrase, holochain });
|
|
98
|
+
return new AgentStatus(result);
|
|
207
99
|
}
|
|
208
100
|
|
|
209
101
|
async byDID(did: string): Promise<Agent> {
|
|
210
|
-
|
|
211
|
-
await this.#apolloClient.query({
|
|
212
|
-
query: gql`query agentByDID($did: String!) {
|
|
213
|
-
agentByDID(did: $did) {
|
|
214
|
-
${AGENT_SUBITEMS}
|
|
215
|
-
}
|
|
216
|
-
}`,
|
|
217
|
-
variables: { did },
|
|
218
|
-
})
|
|
219
|
-
);
|
|
220
|
-
return agentByDID as Agent;
|
|
102
|
+
return this.#apiClient.call<Agent>('agent.byDid', { did });
|
|
221
103
|
}
|
|
222
104
|
|
|
223
105
|
async updatePublicPerspective(perspective: PerspectiveInput): Promise<Agent> {
|
|
224
106
|
const cleanedPerspective = JSON.parse(JSON.stringify(perspective));
|
|
225
107
|
delete cleanedPerspective.__typename;
|
|
226
|
-
cleanedPerspective.links.forEach((link) => {
|
|
108
|
+
cleanedPerspective.links.forEach((link: LinkExpression) => {
|
|
227
109
|
delete link.__typename;
|
|
228
110
|
delete link.data.__typename;
|
|
229
111
|
delete link.proof.__typename;
|
|
230
112
|
delete link.status;
|
|
231
113
|
});
|
|
232
114
|
|
|
233
|
-
const {
|
|
234
|
-
await this.#apolloClient.mutate({
|
|
235
|
-
mutation: gql`mutation agentUpdatePublicPerspective($perspective: PerspectiveInput!) {
|
|
236
|
-
agentUpdatePublicPerspective(perspective: $perspective) {
|
|
237
|
-
${AGENT_SUBITEMS}
|
|
238
|
-
}
|
|
239
|
-
}`,
|
|
240
|
-
variables: { perspective: cleanedPerspective },
|
|
241
|
-
})
|
|
242
|
-
);
|
|
243
|
-
const a = agentUpdatePublicPerspective;
|
|
115
|
+
const a = await this.#apiClient.call<Agent>('agent.updateProfile', { publicPerspective: cleanedPerspective });
|
|
244
116
|
const agent = new Agent(a.did, a.perspective);
|
|
245
117
|
agent.directMessageLanguage = a.directMessageLanguage;
|
|
246
118
|
return agent;
|
|
247
119
|
}
|
|
248
120
|
|
|
249
121
|
async mutatePublicPerspective(mutations: LinkMutations): Promise<Agent> {
|
|
250
|
-
const perspectiveClient = new PerspectiveClient(this.#
|
|
251
|
-
const agentClient = new AgentClient(this.#apolloClient);
|
|
122
|
+
const perspectiveClient = new PerspectiveClient(this.#baseUrl, this.#token);
|
|
252
123
|
|
|
253
|
-
|
|
254
|
-
const
|
|
255
|
-
"Agent Perspective Proxy"
|
|
256
|
-
);
|
|
257
|
-
const agentMe = await agentClient.me();
|
|
124
|
+
const proxyPerspective = await perspectiveClient.add("Agent Perspective Proxy");
|
|
125
|
+
const agentMe = await this.me();
|
|
258
126
|
|
|
259
127
|
if (agentMe.perspective) {
|
|
260
128
|
await proxyPerspective.loadSnapshot(agentMe.perspective);
|
|
261
129
|
}
|
|
262
130
|
|
|
263
|
-
//Make the mutations on the proxy perspective
|
|
264
131
|
for (const addition of mutations.additions) {
|
|
265
132
|
await proxyPerspective.add(addition);
|
|
266
133
|
}
|
|
@@ -268,164 +135,72 @@ export class AgentClient {
|
|
|
268
135
|
await proxyPerspective.remove(removal);
|
|
269
136
|
}
|
|
270
137
|
|
|
271
|
-
//Get the snapshot of the proxy perspective
|
|
272
138
|
const snapshot = await proxyPerspective.snapshot();
|
|
273
|
-
//Update the users public perspective
|
|
274
139
|
const agent = await this.updatePublicPerspective(snapshot);
|
|
275
|
-
//Cleanup and return
|
|
276
140
|
await perspectiveClient.remove(proxyPerspective.uuid);
|
|
277
141
|
return agent;
|
|
278
142
|
}
|
|
279
143
|
|
|
280
|
-
async updateDirectMessageLanguage(
|
|
281
|
-
|
|
282
|
-
): Promise<Agent> {
|
|
283
|
-
const { agentUpdateDirectMessageLanguage } = unwrapApolloResult(
|
|
284
|
-
await this.#apolloClient.mutate({
|
|
285
|
-
mutation: gql`mutation agentUpdateDirectMessageLanguage($directMessageLanguage: String!) {
|
|
286
|
-
agentUpdateDirectMessageLanguage(directMessageLanguage: $directMessageLanguage) {
|
|
287
|
-
${AGENT_SUBITEMS}
|
|
288
|
-
}
|
|
289
|
-
}`,
|
|
290
|
-
variables: { directMessageLanguage },
|
|
291
|
-
})
|
|
292
|
-
);
|
|
293
|
-
const a = agentUpdateDirectMessageLanguage;
|
|
144
|
+
async updateDirectMessageLanguage(directMessageLanguage: string): Promise<Agent> {
|
|
145
|
+
const a = await this.#apiClient.call<Agent>('agent.updateProfile', { dmLanguage: directMessageLanguage });
|
|
294
146
|
const agent = new Agent(a.did, a.perspective);
|
|
295
147
|
agent.directMessageLanguage = a.directMessageLanguage;
|
|
296
148
|
return agent;
|
|
297
149
|
}
|
|
298
150
|
|
|
299
|
-
async addEntanglementProofs(
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
agentAddEntanglementProofs(proofs: $proofs) {
|
|
306
|
-
${ENTANGLEMENT_PROOF_FIELDS}
|
|
307
|
-
}
|
|
308
|
-
}`,
|
|
309
|
-
variables: { proofs },
|
|
310
|
-
})
|
|
311
|
-
);
|
|
312
|
-
return agentAddEntanglementProofs;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
async deleteEntanglementProofs(
|
|
316
|
-
proofs: EntanglementProofInput[]
|
|
317
|
-
): Promise<EntanglementProof[]> {
|
|
318
|
-
const { agentDeleteEntanglementProofs } = unwrapApolloResult(
|
|
319
|
-
await this.#apolloClient.mutate({
|
|
320
|
-
mutation: gql`mutation agentDeleteEntanglementProofs($proofs: [EntanglementProofInput!]!) {
|
|
321
|
-
agentDeleteEntanglementProofs(proofs: $proofs) {
|
|
322
|
-
${ENTANGLEMENT_PROOF_FIELDS}
|
|
323
|
-
}
|
|
324
|
-
}`,
|
|
325
|
-
variables: { proofs },
|
|
326
|
-
})
|
|
327
|
-
);
|
|
328
|
-
return agentDeleteEntanglementProofs;
|
|
151
|
+
async addEntanglementProofs(proofs: EntanglementProofInput[]): Promise<EntanglementProof[]> {
|
|
152
|
+
return this.#apiClient.call<EntanglementProof[]>('agent.addEntanglementProofs', { proofs });
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
async deleteEntanglementProofs(proofs: EntanglementProofInput[]): Promise<EntanglementProof[]> {
|
|
156
|
+
return this.#apiClient.call<EntanglementProof[]>('agent.deleteEntanglementProofs', { proofs });
|
|
329
157
|
}
|
|
330
158
|
|
|
331
159
|
async getEntanglementProofs(): Promise<string[]> {
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
}
|
|
338
|
-
}`,
|
|
339
|
-
})
|
|
340
|
-
);
|
|
341
|
-
return agentGetEntanglementProofs;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
async entanglementProofPreFlight(
|
|
345
|
-
deviceKey: string,
|
|
346
|
-
deviceKeyType: string
|
|
347
|
-
): Promise<EntanglementProof> {
|
|
348
|
-
const { agentEntanglementProofPreFlight } = unwrapApolloResult(
|
|
349
|
-
await this.#apolloClient.mutate({
|
|
350
|
-
mutation: gql`mutation agentEntanglementProofPreFlight($deviceKey: String!, $deviceKeyType: String!) {
|
|
351
|
-
agentEntanglementProofPreFlight(deviceKey: $deviceKey, deviceKeyType: $deviceKeyType) {
|
|
352
|
-
${ENTANGLEMENT_PROOF_FIELDS}
|
|
353
|
-
}
|
|
354
|
-
}`,
|
|
355
|
-
variables: { deviceKey, deviceKeyType },
|
|
356
|
-
})
|
|
357
|
-
);
|
|
358
|
-
return agentEntanglementProofPreFlight;
|
|
160
|
+
return this.#apiClient.call<string[]>('agent.getEntanglementProofs');
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
async entanglementProofPreFlight(deviceKey: string, deviceKeyType: string): Promise<EntanglementProof> {
|
|
164
|
+
return this.#apiClient.call<EntanglementProof>('agent.entanglementProofPreflight', { deviceKey, deviceKeyType });
|
|
359
165
|
}
|
|
360
166
|
|
|
361
|
-
addUpdatedListener(listener) {
|
|
167
|
+
addUpdatedListener(listener: AgentUpdatedCallback) {
|
|
362
168
|
this.#updatedCallbacks.push(listener);
|
|
363
169
|
}
|
|
364
170
|
|
|
365
|
-
addAppChangedListener(listener) {
|
|
171
|
+
addAppChangedListener(listener: AgentAppsUpdatedCallback) {
|
|
366
172
|
this.#appsChangedCallback.push(listener);
|
|
367
173
|
}
|
|
368
174
|
|
|
369
175
|
subscribeAgentUpdated() {
|
|
370
|
-
this.#
|
|
371
|
-
.
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
})
|
|
377
|
-
.subscribe({
|
|
378
|
-
next: (result) => {
|
|
379
|
-
const agent = result.data.agentUpdated;
|
|
380
|
-
this.#updatedCallbacks.forEach((cb) => {
|
|
381
|
-
cb(agent);
|
|
382
|
-
});
|
|
383
|
-
},
|
|
384
|
-
error: (e) => console.error(e),
|
|
385
|
-
});
|
|
176
|
+
const unsub = this.#apiClient.subscribe((data) => {
|
|
177
|
+
if (data.type === 'agent-updated') {
|
|
178
|
+
this.#updatedCallbacks.forEach((cb) => cb((data.agent || data) as Agent));
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
this.#unsubscribers.push(unsub);
|
|
386
182
|
}
|
|
387
183
|
|
|
388
184
|
subscribeAppsChanged() {
|
|
389
|
-
this.#
|
|
390
|
-
.
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
.subscribe({
|
|
399
|
-
next: (result) => {
|
|
400
|
-
this.#appsChangedCallback.forEach((cb) => {
|
|
401
|
-
cb();
|
|
402
|
-
});
|
|
403
|
-
},
|
|
404
|
-
error: (e) => console.error(e),
|
|
405
|
-
});
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
addAgentStatusChangedListener(listener) {
|
|
185
|
+
const unsub = this.#apiClient.subscribe((data) => {
|
|
186
|
+
if (data.type === 'apps-changed') {
|
|
187
|
+
this.#appsChangedCallback.forEach((cb) => cb());
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
this.#unsubscribers.push(unsub);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
addAgentStatusChangedListener(listener: AgentStatusChangedCallback) {
|
|
409
194
|
this.#agentStatusChangedCallbacks.push(listener);
|
|
410
195
|
}
|
|
411
196
|
|
|
412
197
|
subscribeAgentStatusChanged() {
|
|
413
|
-
this.#
|
|
414
|
-
.
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
})
|
|
420
|
-
.subscribe({
|
|
421
|
-
next: (result) => {
|
|
422
|
-
const agent = result.data.agentStatusChanged;
|
|
423
|
-
this.#agentStatusChangedCallbacks.forEach((cb) => {
|
|
424
|
-
cb(agent);
|
|
425
|
-
});
|
|
426
|
-
},
|
|
427
|
-
error: (e) => console.error(e),
|
|
428
|
-
});
|
|
198
|
+
const unsub = this.#apiClient.subscribe((data) => {
|
|
199
|
+
if (data.type === 'agent-status-changed') {
|
|
200
|
+
this.#agentStatusChangedCallbacks.forEach((cb) => cb((data.agent || data) as Agent));
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
this.#unsubscribers.push(unsub);
|
|
429
204
|
}
|
|
430
205
|
|
|
431
206
|
addHostingUserInfoChangedListener(listener: HostingUserInfoChangedCallback) {
|
|
@@ -433,24 +208,12 @@ export class AgentClient {
|
|
|
433
208
|
}
|
|
434
209
|
|
|
435
210
|
subscribeHostingUserInfoChanged() {
|
|
436
|
-
this.#
|
|
437
|
-
.
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
hotWalletAddress
|
|
443
|
-
freeAccess
|
|
444
|
-
}
|
|
445
|
-
}`,
|
|
446
|
-
})
|
|
447
|
-
.subscribe({
|
|
448
|
-
next: (result) => {
|
|
449
|
-
const info = result.data.runtimeHostingUserInfoChanged;
|
|
450
|
-
this.#hostingUserInfoChangedCallbacks.forEach((cb) => cb(info));
|
|
451
|
-
},
|
|
452
|
-
error: (e) => console.error(e),
|
|
453
|
-
});
|
|
211
|
+
const unsub = this.#apiClient.subscribe((data) => {
|
|
212
|
+
if (data.type === 'hosting-user-info-changed') {
|
|
213
|
+
this.#hostingUserInfoChangedCallbacks.forEach((cb) => cb((data.info || data) as HostingUserInfo));
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
this.#unsubscribers.push(unsub);
|
|
454
217
|
}
|
|
455
218
|
|
|
456
219
|
addComputeLogUpdatedListener(listener: ComputeLogUpdatedCallback) {
|
|
@@ -458,261 +221,84 @@ export class AgentClient {
|
|
|
458
221
|
}
|
|
459
222
|
|
|
460
223
|
subscribeComputeLogUpdated() {
|
|
461
|
-
this.#
|
|
462
|
-
.
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
timestamp
|
|
468
|
-
operation
|
|
469
|
-
summary
|
|
470
|
-
cost
|
|
471
|
-
creditsAfter
|
|
472
|
-
}
|
|
473
|
-
}`,
|
|
474
|
-
})
|
|
475
|
-
.subscribe({
|
|
476
|
-
next: (result) => {
|
|
477
|
-
const entry = result.data.runtimeComputeLogUpdated;
|
|
478
|
-
this.#computeLogUpdatedCallbacks.forEach((cb) => cb(entry));
|
|
479
|
-
},
|
|
480
|
-
error: (e) => console.error(e),
|
|
481
|
-
});
|
|
224
|
+
const unsub = this.#apiClient.subscribe((data) => {
|
|
225
|
+
if (data.type === 'compute-log-updated') {
|
|
226
|
+
this.#computeLogUpdatedCallbacks.forEach((cb) => cb((data.entry || data) as ComputeLogEntry));
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
this.#unsubscribers.push(unsub);
|
|
482
230
|
}
|
|
483
231
|
|
|
484
232
|
async requestCapability(authInfo: AuthInfoInput): Promise<string> {
|
|
485
|
-
|
|
486
|
-
await this.#apolloClient.mutate({
|
|
487
|
-
mutation: gql`
|
|
488
|
-
mutation agentRequestCapability($authInfo: AuthInfoInput!) {
|
|
489
|
-
agentRequestCapability(authInfo: $authInfo)
|
|
490
|
-
}
|
|
491
|
-
`,
|
|
492
|
-
variables: { authInfo },
|
|
493
|
-
})
|
|
494
|
-
);
|
|
495
|
-
return agentRequestCapability;
|
|
233
|
+
return this.#apiClient.call<string>('agent.requestCapability', { authInfo });
|
|
496
234
|
}
|
|
497
235
|
|
|
498
236
|
async permitCapability(auth: string): Promise<string> {
|
|
499
|
-
|
|
500
|
-
await this.#apolloClient.mutate({
|
|
501
|
-
mutation: gql`
|
|
502
|
-
mutation agentPermitCapability($auth: String!) {
|
|
503
|
-
agentPermitCapability(auth: $auth)
|
|
504
|
-
}
|
|
505
|
-
`,
|
|
506
|
-
variables: { auth },
|
|
507
|
-
})
|
|
508
|
-
);
|
|
509
|
-
return agentPermitCapability;
|
|
237
|
+
return this.#apiClient.call<string>('agent.permitCapability', { auth });
|
|
510
238
|
}
|
|
511
239
|
|
|
512
240
|
async generateJwt(requestId: string, rand: string): Promise<string> {
|
|
513
|
-
|
|
514
|
-
await this.#apolloClient.mutate({
|
|
515
|
-
mutation: gql`
|
|
516
|
-
mutation agentGenerateJwt($requestId: String!, $rand: String!) {
|
|
517
|
-
agentGenerateJwt(requestId: $requestId, rand: $rand)
|
|
518
|
-
}
|
|
519
|
-
`,
|
|
520
|
-
variables: { requestId, rand },
|
|
521
|
-
})
|
|
522
|
-
);
|
|
523
|
-
return agentGenerateJwt;
|
|
241
|
+
return this.#apiClient.call<string>('agent.generateJwt', { requestId, rand });
|
|
524
242
|
}
|
|
525
243
|
|
|
526
244
|
async getApps(): Promise<Apps[]> {
|
|
527
|
-
|
|
528
|
-
await this.#apolloClient.mutate({
|
|
529
|
-
mutation: gql`query agentGetApps {
|
|
530
|
-
agentGetApps {
|
|
531
|
-
${Apps_FIELDS}
|
|
532
|
-
}
|
|
533
|
-
}`,
|
|
534
|
-
})
|
|
535
|
-
);
|
|
536
|
-
return agentGetApps;
|
|
245
|
+
return this.#apiClient.call<Apps[]>('agent.getApps');
|
|
537
246
|
}
|
|
538
247
|
|
|
539
248
|
async removeApp(requestId: string): Promise<Apps[]> {
|
|
540
|
-
|
|
541
|
-
await this.#apolloClient.mutate({
|
|
542
|
-
mutation: gql`mutation agentRemoveApp($requestId: String!) {
|
|
543
|
-
agentRemoveApp(requestId: $requestId) {
|
|
544
|
-
${Apps_FIELDS}
|
|
545
|
-
}
|
|
546
|
-
}`,
|
|
547
|
-
variables: { requestId },
|
|
548
|
-
})
|
|
549
|
-
);
|
|
550
|
-
return agentRemoveApp;
|
|
249
|
+
return this.#apiClient.call<Apps[]>('agent.removeApp', { id: requestId });
|
|
551
250
|
}
|
|
552
251
|
|
|
553
252
|
async revokeToken(requestId: string): Promise<Apps[]> {
|
|
554
|
-
|
|
555
|
-
await this.#apolloClient.mutate({
|
|
556
|
-
mutation: gql`mutation agentRevokeToken($requestId: String!) {
|
|
557
|
-
agentRevokeToken(requestId: $requestId) {
|
|
558
|
-
${Apps_FIELDS}
|
|
559
|
-
}
|
|
560
|
-
}`,
|
|
561
|
-
variables: { requestId },
|
|
562
|
-
})
|
|
563
|
-
);
|
|
564
|
-
return agentRevokeToken;
|
|
253
|
+
return this.#apiClient.call<Apps[]>('agent.revokeToken', { token: requestId });
|
|
565
254
|
}
|
|
566
255
|
|
|
567
256
|
async isLocked(): Promise<boolean> {
|
|
568
|
-
|
|
569
|
-
await this.#apolloClient.mutate({
|
|
570
|
-
mutation: gql`
|
|
571
|
-
query agentIsLocked {
|
|
572
|
-
agentIsLocked
|
|
573
|
-
}
|
|
574
|
-
`,
|
|
575
|
-
})
|
|
576
|
-
);
|
|
577
|
-
return agentIsLocked;
|
|
257
|
+
return this.#apiClient.call<boolean>('agent.isLocked');
|
|
578
258
|
}
|
|
579
259
|
|
|
580
260
|
async signMessage(message: string): Promise<string> {
|
|
581
|
-
|
|
582
|
-
await this.#apolloClient.mutate({
|
|
583
|
-
mutation: gql`mutation agentSignMessage($message: String!) {
|
|
584
|
-
agentSignMessage(message: $message) {
|
|
585
|
-
${AGENT_SIGNATURE_FIELDS}
|
|
586
|
-
}
|
|
587
|
-
}`,
|
|
588
|
-
variables: { message },
|
|
589
|
-
})
|
|
590
|
-
);
|
|
591
|
-
return agentSignMessage;
|
|
261
|
+
return this.#apiClient.call<string>('agent.sign', { message });
|
|
592
262
|
}
|
|
593
263
|
|
|
594
264
|
// Multi-user methods
|
|
595
265
|
async createUser(email: string, password: string, appInfo?: AuthInfoInput): Promise<UserCreationResult> {
|
|
596
|
-
|
|
597
|
-
await this.#apolloClient.mutate({
|
|
598
|
-
mutation: gql`mutation runtimeCreateUser($email: String!, $password: String!, $appInfo: AuthInfoInput) {
|
|
599
|
-
runtimeCreateUser(email: $email, password: $password, appInfo: $appInfo) {
|
|
600
|
-
did
|
|
601
|
-
success
|
|
602
|
-
error
|
|
603
|
-
}
|
|
604
|
-
}`,
|
|
605
|
-
variables: { email, password, appInfo },
|
|
606
|
-
})
|
|
607
|
-
);
|
|
608
|
-
return runtimeCreateUser;
|
|
266
|
+
return this.#apiClient.call<UserCreationResult>('user.create', { email, password, appInfo });
|
|
609
267
|
}
|
|
610
268
|
|
|
611
269
|
async loginUser(email: string, password: string): Promise<string> {
|
|
612
|
-
|
|
613
|
-
await this.#apolloClient.mutate({
|
|
614
|
-
mutation: gql`mutation runtimeLoginUser($email: String!, $password: String!) {
|
|
615
|
-
runtimeLoginUser(email: $email, password: $password)
|
|
616
|
-
}`,
|
|
617
|
-
variables: { email, password },
|
|
618
|
-
})
|
|
619
|
-
);
|
|
620
|
-
return runtimeLoginUser;
|
|
270
|
+
return this.#apiClient.call<string>('user.login', { email, password });
|
|
621
271
|
}
|
|
622
272
|
|
|
623
273
|
async requestLoginVerification(email: string, appInfo?: AuthInfoInput): Promise<VerificationRequestResult> {
|
|
624
|
-
|
|
625
|
-
await this.#apolloClient.mutate({
|
|
626
|
-
mutation: gql`mutation runtimeRequestLoginVerification($email: String!, $appInfo: AuthInfoInput) {
|
|
627
|
-
runtimeRequestLoginVerification(email: $email, appInfo: $appInfo) {
|
|
628
|
-
success
|
|
629
|
-
message
|
|
630
|
-
requiresPassword
|
|
631
|
-
isExistingUser
|
|
632
|
-
}
|
|
633
|
-
}`,
|
|
634
|
-
variables: { email, appInfo },
|
|
635
|
-
})
|
|
636
|
-
);
|
|
637
|
-
return runtimeRequestLoginVerification;
|
|
274
|
+
return this.#apiClient.call<VerificationRequestResult>('user.requestVerification', { email, appInfo });
|
|
638
275
|
}
|
|
639
276
|
|
|
640
277
|
async verifyEmailCode(email: string, code: string, verificationType: string): Promise<string> {
|
|
641
|
-
|
|
642
|
-
await this.#apolloClient.mutate({
|
|
643
|
-
mutation: gql`mutation runtimeVerifyEmailCode($email: String!, $code: String!, $verificationType: String!) {
|
|
644
|
-
runtimeVerifyEmailCode(email: $email, code: $code, verificationType: $verificationType)
|
|
645
|
-
}`,
|
|
646
|
-
variables: { email, code, verificationType },
|
|
647
|
-
})
|
|
648
|
-
);
|
|
649
|
-
return runtimeVerifyEmailCode;
|
|
278
|
+
return this.#apiClient.call<string>('user.verifyEmail', { email, code, verificationType });
|
|
650
279
|
}
|
|
651
280
|
|
|
652
281
|
// Hosting methods
|
|
653
|
-
|
|
654
282
|
async hostingUserInfo(): Promise<HostingUserInfo> {
|
|
655
|
-
const
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
freeAccess
|
|
663
|
-
}
|
|
664
|
-
}`,
|
|
665
|
-
})
|
|
283
|
+
const resp = await this.#apiClient.call<any>('hosting.info');
|
|
284
|
+
const info = resp?.userInfo || resp;
|
|
285
|
+
return new HostingUserInfo(
|
|
286
|
+
info.email || '',
|
|
287
|
+
info.freeAccess ? 'unlimited' : String(info.credits ?? info.remainingCredits ?? '0'),
|
|
288
|
+
info.hotWalletAddress || undefined,
|
|
289
|
+
!!info.freeAccess,
|
|
666
290
|
);
|
|
667
|
-
return runtimeHostingUserInfo;
|
|
668
291
|
}
|
|
669
292
|
|
|
670
293
|
async computeLog(since?: string, limit?: number, userEmail?: string): Promise<ComputeLogEntry[]> {
|
|
671
|
-
|
|
672
|
-
await this.#apolloClient.query({
|
|
673
|
-
query: gql`query runtimeComputeLog($since: String, $limit: Int, $userEmail: String) {
|
|
674
|
-
runtimeComputeLog(since: $since, limit: $limit, userEmail: $userEmail) {
|
|
675
|
-
id
|
|
676
|
-
userEmail
|
|
677
|
-
timestamp
|
|
678
|
-
operation
|
|
679
|
-
summary
|
|
680
|
-
cost
|
|
681
|
-
creditsAfter
|
|
682
|
-
}
|
|
683
|
-
}`,
|
|
684
|
-
variables: { since, limit, userEmail },
|
|
685
|
-
fetchPolicy: 'network-only',
|
|
686
|
-
})
|
|
687
|
-
);
|
|
688
|
-
return runtimeComputeLog;
|
|
294
|
+
return this.#apiClient.call<ComputeLogEntry[]>('runtime.computeLog', { since, limit, userEmail });
|
|
689
295
|
}
|
|
690
296
|
|
|
691
297
|
async setHotWalletAddress(address: string): Promise<boolean> {
|
|
692
|
-
|
|
693
|
-
await this.#apolloClient.mutate({
|
|
694
|
-
mutation: gql`mutation runtimeSetHotWalletAddress($address: String!) {
|
|
695
|
-
runtimeSetHotWalletAddress(address: $address)
|
|
696
|
-
}`,
|
|
697
|
-
variables: { address },
|
|
698
|
-
})
|
|
699
|
-
);
|
|
700
|
-
return runtimeSetHotWalletAddress;
|
|
298
|
+
return this.#apiClient.call<boolean>('hosting.setHotWallet', { address });
|
|
701
299
|
}
|
|
702
300
|
|
|
703
301
|
async requestPayment(amountHOT: string): Promise<PaymentRequestResult> {
|
|
704
|
-
|
|
705
|
-
await this.#apolloClient.mutate({
|
|
706
|
-
mutation: gql`mutation runtimeRequestPayment($amountHOT: String!) {
|
|
707
|
-
runtimeRequestPayment(amountHOT: $amountHOT) {
|
|
708
|
-
success
|
|
709
|
-
message
|
|
710
|
-
}
|
|
711
|
-
}`,
|
|
712
|
-
variables: { amountHOT },
|
|
713
|
-
})
|
|
714
|
-
);
|
|
715
|
-
return runtimeRequestPayment;
|
|
302
|
+
return this.#apiClient.call<PaymentRequestResult>('hosting.requestPayment', { amountHOT });
|
|
716
303
|
}
|
|
717
|
-
|
|
718
304
|
}
|