@coasys/ad4m 0.8.0-fix → 0.8.1
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 +229 -229
- package/jest.config.js +5 -5
- package/jsdoc.json +27 -27
- package/lib/index.cjs +4522 -4571
- package/lib/index.js +4522 -4571
- package/lib/shims/type-graphql.d.ts +32 -32
- package/lib/shims/type-graphql.js +70 -70
- package/lib/src/Ad4mClient.d.ts +26 -26
- package/lib/src/Ad4mClient.js +66 -66
- package/lib/src/Address.d.ts +1 -1
- package/lib/src/Address.js +1 -1
- package/lib/src/DID.d.ts +1 -1
- package/lib/src/DID.js +1 -1
- package/lib/src/Exception.d.ts +6 -6
- package/lib/src/Exception.js +7 -7
- package/lib/src/Literal.d.ts +7 -7
- package/lib/src/Literal.js +76 -76
- package/lib/src/PubSub.d.ts +14 -14
- package/lib/src/PubSub.js +14 -14
- package/lib/src/SmartLiteral.d.ts +12 -12
- package/lib/src/SmartLiteral.js +74 -74
- package/lib/src/agent/Agent.d.ts +104 -104
- package/lib/src/agent/Agent.js +337 -337
- package/lib/src/agent/AgentClient.d.ts +57 -57
- package/lib/src/agent/AgentClient.js +431 -431
- package/lib/src/agent/AgentResolver.d.ts +30 -30
- package/lib/src/agent/AgentResolver.js +325 -325
- package/lib/src/agent/AgentStatus.d.ts +8 -8
- package/lib/src/agent/AgentStatus.js +61 -61
- package/lib/src/buildSchema.d.ts +1 -1
- package/lib/src/buildSchema.js +36 -36
- package/lib/src/expression/Expression.d.ts +28 -28
- package/lib/src/expression/Expression.js +143 -143
- package/lib/src/expression/ExpressionClient.d.ts +13 -13
- package/lib/src/expression/ExpressionClient.js +102 -102
- package/lib/src/expression/ExpressionRef.d.ts +9 -9
- package/lib/src/expression/ExpressionRef.js +67 -67
- package/lib/src/expression/ExpressionResolver.d.ts +10 -10
- package/lib/src/expression/ExpressionResolver.js +106 -106
- package/lib/src/index.d.ts +30 -30
- package/lib/src/index.js +30 -30
- package/lib/src/jestSetup.d.ts +1 -1
- package/lib/src/jestSetup.js +1 -1
- package/lib/src/language/Icon.d.ts +4 -4
- package/lib/src/language/Icon.js +24 -24
- package/lib/src/language/Language.d.ts +195 -195
- package/lib/src/language/Language.js +79 -79
- package/lib/src/language/LanguageClient.d.ts +17 -17
- package/lib/src/language/LanguageClient.js +137 -137
- package/lib/src/language/LanguageContext.d.ts +37 -37
- package/lib/src/language/LanguageContext.js +2 -2
- package/lib/src/language/LanguageHandle.d.ts +9 -9
- package/lib/src/language/LanguageHandle.js +41 -41
- package/lib/src/language/LanguageMeta.d.ts +35 -35
- package/lib/src/language/LanguageMeta.js +89 -89
- package/lib/src/language/LanguageRef.d.ts +6 -6
- package/lib/src/language/LanguageRef.js +30 -30
- package/lib/src/language/LanguageResolver.d.ts +19 -19
- package/lib/src/language/LanguageResolver.js +143 -143
- package/lib/src/links/Links.d.ts +39 -39
- package/lib/src/links/Links.js +148 -148
- package/lib/src/links/Links.test.d.ts +1 -1
- package/lib/src/links/Links.test.js +33 -33
- package/lib/src/neighbourhood/Neighbourhood.d.ts +10 -10
- package/lib/src/neighbourhood/Neighbourhood.js +38 -38
- package/lib/src/neighbourhood/NeighbourhoodClient.d.ts +25 -25
- package/lib/src/neighbourhood/NeighbourhoodClient.js +256 -256
- package/lib/src/neighbourhood/NeighbourhoodProxy.d.ts +19 -19
- package/lib/src/neighbourhood/NeighbourhoodProxy.js +54 -54
- package/lib/src/neighbourhood/NeighbourhoodResolver.d.ts +24 -24
- package/lib/src/neighbourhood/NeighbourhoodResolver.js +180 -180
- package/lib/src/perspectives/LinkQuery.d.ts +11 -11
- package/lib/src/perspectives/LinkQuery.js +80 -80
- package/lib/src/perspectives/Perspective.d.ts +38 -38
- package/lib/src/perspectives/Perspective.js +144 -144
- package/lib/src/perspectives/Perspective.test.d.ts +1 -1
- package/lib/src/perspectives/Perspective.test.js +20 -20
- package/lib/src/perspectives/PerspectiveClient.d.ts +55 -54
- package/lib/src/perspectives/PerspectiveClient.js +418 -410
- package/lib/src/perspectives/PerspectiveDiff.d.ts +9 -9
- package/lib/src/perspectives/PerspectiveDiff.js +33 -33
- package/lib/src/perspectives/PerspectiveHandle.d.ts +16 -16
- package/lib/src/perspectives/PerspectiveHandle.js +59 -59
- package/lib/src/perspectives/PerspectiveProxy.d.ts +178 -178
- package/lib/src/perspectives/PerspectiveProxy.js +501 -540
- package/lib/src/perspectives/PerspectiveResolver.d.ts +38 -37
- package/lib/src/perspectives/PerspectiveResolver.js +376 -362
- package/lib/src/runtime/RuntimeClient.d.ts +33 -33
- package/lib/src/runtime/RuntimeClient.js +263 -263
- package/lib/src/runtime/RuntimeResolver.d.ts +47 -47
- package/lib/src/runtime/RuntimeResolver.js +328 -328
- package/lib/src/schema.gql +1 -0
- package/lib/src/subject/SDNADecorators.d.ts +45 -45
- package/lib/src/subject/SDNADecorators.js +250 -250
- package/lib/src/subject/Subject.d.ts +7 -7
- package/lib/src/subject/Subject.js +160 -160
- package/lib/src/subject/SubjectEntity.d.ts +31 -31
- package/lib/src/subject/SubjectEntity.js +250 -250
- package/lib/src/subject/util.d.ts +12 -12
- package/lib/src/subject/util.js +73 -73
- package/lib/src/typeDefs.d.ts +1 -1
- package/lib/src/typeDefs.js +1 -0
- package/lib/src/unwrapApolloResult.d.ts +2 -2
- package/lib/src/unwrapApolloResult.js +14 -12
- package/lib/src/utils.d.ts +2 -2
- package/lib/src/utils.js +21 -21
- package/package.json +61 -61
- package/rollup.config.js +26 -26
- package/shims/type-graphql.ts +75 -75
- package/src/Ad4mClient.test.ts +1089 -1084
- package/src/Ad4mClient.ts +62 -62
- package/src/Address.ts +1 -1
- package/src/Exception.ts +6 -6
- package/src/Literal.test.ts +30 -30
- package/src/Literal.ts +80 -80
- package/src/PubSub.ts +13 -13
- package/src/SmartLiteral.ts +74 -74
- package/src/agent/Agent.ts +293 -293
- package/src/agent/AgentClient.ts +531 -531
- package/src/agent/AgentResolver.ts +263 -263
- package/src/agent/AgentStatus.ts +43 -43
- package/src/buildSchema.ts +41 -41
- package/src/expression/Expression.ts +99 -99
- package/src/expression/ExpressionClient.ts +98 -98
- package/src/expression/ExpressionRef.ts +62 -62
- package/src/expression/ExpressionResolver.ts +63 -63
- package/src/index.ts +30 -30
- package/src/language/Icon.ts +10 -10
- package/src/language/Language.ts +266 -266
- package/src/language/LanguageClient.ts +159 -159
- package/src/language/LanguageContext.ts +37 -37
- package/src/language/LanguageHandle.ts +23 -23
- package/src/language/LanguageMeta.ts +69 -69
- package/src/language/LanguageRef.ts +18 -18
- package/src/language/LanguageResolver.ts +98 -98
- package/src/links/Links.test.ts +39 -39
- package/src/links/Links.ts +107 -107
- package/src/neighbourhood/Neighbourhood.ts +22 -22
- package/src/neighbourhood/NeighbourhoodClient.ts +275 -275
- package/src/neighbourhood/NeighbourhoodProxy.ts +58 -58
- package/src/neighbourhood/NeighbourhoodResolver.ts +99 -99
- package/src/perspectives/LinkQuery.ts +65 -65
- package/src/perspectives/Perspective.test.ts +22 -22
- package/src/perspectives/Perspective.ts +118 -118
- package/src/perspectives/PerspectiveClient.ts +452 -443
- package/src/perspectives/PerspectiveDiff.ts +15 -15
- package/src/perspectives/PerspectiveHandle.ts +39 -39
- package/src/perspectives/PerspectiveProxy.ts +576 -610
- package/src/perspectives/PerspectiveResolver.ts +224 -219
- package/src/runtime/RuntimeClient.ts +282 -282
- package/src/runtime/RuntimeResolver.ts +192 -192
- package/src/subject/SDNADecorators.ts +333 -333
- package/src/subject/Subject.ts +152 -152
- package/src/subject/SubjectEntity.ts +291 -291
- package/src/subject/util.ts +84 -84
- package/src/typeDefs.ts +5 -5
- package/src/unwrapApolloResult.ts +15 -13
- package/src/utils.ts +25 -25
- package/tsconfig-browser.json +82 -82
- package/tsconfig.json +80 -80
- package/yarn-error.log +0 -22814
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
import { DID } from "../DID";
|
|
2
|
-
import { OnlineAgent } from "../language/Language";
|
|
3
|
-
import { Perspective, PerspectiveExpression, PerspectiveUnsignedInput } from "../perspectives/Perspective";
|
|
4
|
-
import { NeighbourhoodClient } from "./NeighbourhoodClient";
|
|
5
|
-
|
|
6
|
-
export class NeighbourhoodProxy {
|
|
7
|
-
#client: NeighbourhoodClient
|
|
8
|
-
#pID: string
|
|
9
|
-
|
|
10
|
-
constructor(client: NeighbourhoodClient, pID: string) {
|
|
11
|
-
this.#client = client
|
|
12
|
-
this.#pID = pID
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
async otherAgents(): Promise<DID[]> {
|
|
16
|
-
return await this.#client.otherAgents(this.#pID)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
async hasTelepresenceAdapter(): Promise<boolean> {
|
|
20
|
-
return await this.#client.hasTelepresenceAdapter(this.#pID)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
async onlineAgents(): Promise<OnlineAgent[]> {
|
|
24
|
-
return await this.#client.onlineAgents(this.#pID)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
async setOnlineStatus(status: Perspective): Promise<boolean> {
|
|
28
|
-
return await this.#client.setOnlineStatus(this.#pID, status)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
async setOnlineStatusU(status: PerspectiveUnsignedInput): Promise<boolean> {
|
|
32
|
-
return await this.#client.setOnlineStatusU(this.#pID, status)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
async sendSignal(remoteAgentDid: string, payload: Perspective): Promise<boolean> {
|
|
36
|
-
return await this.#client.sendSignal(this.#pID, remoteAgentDid, payload)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
async sendSignalU(remoteAgentDid: string, payload: PerspectiveUnsignedInput): Promise<boolean> {
|
|
40
|
-
return await this.#client.sendSignalU(this.#pID, remoteAgentDid, payload)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
async sendBroadcast(payload: Perspective): Promise<boolean> {
|
|
44
|
-
return await this.#client.sendBroadcast(this.#pID, payload)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
async sendBroadcastU(payload: PerspectiveUnsignedInput): Promise<boolean> {
|
|
48
|
-
return await this.#client.sendBroadcastU(this.#pID, payload)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
async addSignalHandler(handler: (payload: PerspectiveExpression) => void): Promise<void> {
|
|
52
|
-
await this.#client.addSignalHandler(this.#pID, handler)
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
removeSignalHandler(handler: (payload: PerspectiveExpression) => void) {
|
|
56
|
-
this.#client.removeSignalHandler(this.#pID, handler)
|
|
57
|
-
}
|
|
58
|
-
}
|
|
1
|
+
import { DID } from "../DID";
|
|
2
|
+
import { OnlineAgent } from "../language/Language";
|
|
3
|
+
import { Perspective, PerspectiveExpression, PerspectiveUnsignedInput } from "../perspectives/Perspective";
|
|
4
|
+
import { NeighbourhoodClient } from "./NeighbourhoodClient";
|
|
5
|
+
|
|
6
|
+
export class NeighbourhoodProxy {
|
|
7
|
+
#client: NeighbourhoodClient
|
|
8
|
+
#pID: string
|
|
9
|
+
|
|
10
|
+
constructor(client: NeighbourhoodClient, pID: string) {
|
|
11
|
+
this.#client = client
|
|
12
|
+
this.#pID = pID
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async otherAgents(): Promise<DID[]> {
|
|
16
|
+
return await this.#client.otherAgents(this.#pID)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async hasTelepresenceAdapter(): Promise<boolean> {
|
|
20
|
+
return await this.#client.hasTelepresenceAdapter(this.#pID)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async onlineAgents(): Promise<OnlineAgent[]> {
|
|
24
|
+
return await this.#client.onlineAgents(this.#pID)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async setOnlineStatus(status: Perspective): Promise<boolean> {
|
|
28
|
+
return await this.#client.setOnlineStatus(this.#pID, status)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async setOnlineStatusU(status: PerspectiveUnsignedInput): Promise<boolean> {
|
|
32
|
+
return await this.#client.setOnlineStatusU(this.#pID, status)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async sendSignal(remoteAgentDid: string, payload: Perspective): Promise<boolean> {
|
|
36
|
+
return await this.#client.sendSignal(this.#pID, remoteAgentDid, payload)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async sendSignalU(remoteAgentDid: string, payload: PerspectiveUnsignedInput): Promise<boolean> {
|
|
40
|
+
return await this.#client.sendSignalU(this.#pID, remoteAgentDid, payload)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async sendBroadcast(payload: Perspective): Promise<boolean> {
|
|
44
|
+
return await this.#client.sendBroadcast(this.#pID, payload)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async sendBroadcastU(payload: PerspectiveUnsignedInput): Promise<boolean> {
|
|
48
|
+
return await this.#client.sendBroadcastU(this.#pID, payload)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async addSignalHandler(handler: (payload: PerspectiveExpression) => void): Promise<void> {
|
|
52
|
+
await this.#client.addSignalHandler(this.#pID, handler)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
removeSignalHandler(handler: (payload: PerspectiveExpression) => void) {
|
|
56
|
+
this.#client.removeSignalHandler(this.#pID, handler)
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -1,100 +1,100 @@
|
|
|
1
|
-
import { Arg, Mutation, Query, Resolver, Subscription, PubSub } from "type-graphql";
|
|
2
|
-
import { PerspectiveHandle, PerspectiveState } from "../perspectives/PerspectiveHandle";
|
|
3
|
-
import { Perspective, PerspectiveExpression, PerspectiveInput, PerspectiveUnsignedInput } from "../perspectives/Perspective";
|
|
4
|
-
import { DID } from "../DID";
|
|
5
|
-
import { TEST_AGENT_DID } from "../agent/AgentResolver";
|
|
6
|
-
import { OnlineAgent } from "../language/Language";
|
|
7
|
-
import { testLink } from "../perspectives/PerspectiveResolver";
|
|
8
|
-
import { NEIGHBOURHOOD_SIGNAL_RECEIVED_TOPIC, PERSPECTIVE_UPDATED_TOPIC } from "../PubSub";
|
|
9
|
-
|
|
10
|
-
const testPerspectiveExpression = new PerspectiveExpression()
|
|
11
|
-
testPerspectiveExpression.author = TEST_AGENT_DID
|
|
12
|
-
testPerspectiveExpression.timestamp = new Date().toISOString()
|
|
13
|
-
testPerspectiveExpression.data = new Perspective([testLink])
|
|
14
|
-
testPerspectiveExpression.proof = {
|
|
15
|
-
signature: '',
|
|
16
|
-
key: '',
|
|
17
|
-
valid: true
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Resolver classes are used here to define the GraphQL schema
|
|
22
|
-
* (through the type-graphql annotations)
|
|
23
|
-
* and are spawned in the client tests in Ad4mClient.test.ts.
|
|
24
|
-
* For the latter, they return test fixtures.
|
|
25
|
-
*/
|
|
26
|
-
@Resolver()
|
|
27
|
-
export default class NeighbourhoodResolver {
|
|
28
|
-
@Mutation(returns => String)
|
|
29
|
-
neighbourhoodPublishFromPerspective(
|
|
30
|
-
@Arg('perspectiveUUID') perspectiveUUID: string,
|
|
31
|
-
@Arg('linkLanguage') linkLanguage: string,
|
|
32
|
-
@Arg('meta') meta: PerspectiveInput
|
|
33
|
-
): string {
|
|
34
|
-
return "neighbourhood://neighbourhoodAddress"
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
@Mutation(returns => PerspectiveHandle)
|
|
38
|
-
neighbourhoodJoinFromUrl(@Arg('url') url: string, @PubSub() pubSub: any): PerspectiveHandle {
|
|
39
|
-
const perspective = new PerspectiveHandle
|
|
40
|
-
perspective.name = "test-perspective"
|
|
41
|
-
perspective.sharedUrl = url
|
|
42
|
-
perspective.uuid = "234234234"
|
|
43
|
-
perspective.state = PerspectiveState.Synced
|
|
44
|
-
pubSub.publish(PERSPECTIVE_UPDATED_TOPIC, { perspective});
|
|
45
|
-
return perspective
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
@Query(returns => [String])
|
|
49
|
-
neighbourhoodOtherAgents(@Arg('perspectiveUUID') perspectiveUUID: string): DID[] {
|
|
50
|
-
return ['did:test:other']
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
@Query()
|
|
54
|
-
neighbourhoodHasTelepresenceAdapter(@Arg('perspectiveUUID') perspectiveUUID: string): boolean {
|
|
55
|
-
return true
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
@Query(returns => [OnlineAgent])
|
|
59
|
-
neighbourhoodOnlineAgents(@Arg('perspectiveUUID') perspectiveUUID: string): OnlineAgent[] {
|
|
60
|
-
const onlineAgent = new OnlineAgent()
|
|
61
|
-
onlineAgent.did = 'did:test:online'
|
|
62
|
-
onlineAgent.status = testPerspectiveExpression
|
|
63
|
-
return [onlineAgent]
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
@Mutation()
|
|
67
|
-
neighbourhoodSetOnlineStatus(@Arg('perspectiveUUID') perspectiveUUID: string, @Arg('status') status: PerspectiveInput): boolean {
|
|
68
|
-
return true
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
@Mutation()
|
|
72
|
-
neighbourhoodSetOnlineStatusU(@Arg('perspectiveUUID') perspectiveUUID: string, @Arg('status') status: PerspectiveUnsignedInput): boolean {
|
|
73
|
-
return true
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
@Mutation()
|
|
77
|
-
neighbourhoodSendSignal(@Arg('perspectiveUUID') perspectiveUUID: string, @Arg('remoteAgentDid') recipient: DID, @Arg('payload') signal: PerspectiveInput): boolean {
|
|
78
|
-
return true
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
@Mutation()
|
|
82
|
-
neighbourhoodSendSignalU(@Arg('perspectiveUUID') perspectiveUUID: string, @Arg('remoteAgentDid') recipient: DID, @Arg('payload') signal: PerspectiveUnsignedInput): boolean {
|
|
83
|
-
return true
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
@Mutation()
|
|
87
|
-
neighbourhoodSendBroadcast(@Arg('perspectiveUUID') perspectiveUUID: string, @Arg('payload') signal: PerspectiveInput): boolean {
|
|
88
|
-
return true
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
@Mutation()
|
|
92
|
-
neighbourhoodSendBroadcastU(@Arg('perspectiveUUID') perspectiveUUID: string, @Arg('payload') signal: PerspectiveUnsignedInput): boolean {
|
|
93
|
-
return true
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
@Subscription({topics: NEIGHBOURHOOD_SIGNAL_RECEIVED_TOPIC, nullable: true})
|
|
97
|
-
neighbourhoodSignal(@Arg('perspectiveUUID') pID: string): PerspectiveExpression {
|
|
98
|
-
return testPerspectiveExpression
|
|
99
|
-
}
|
|
1
|
+
import { Arg, Mutation, Query, Resolver, Subscription, PubSub } from "type-graphql";
|
|
2
|
+
import { PerspectiveHandle, PerspectiveState } from "../perspectives/PerspectiveHandle";
|
|
3
|
+
import { Perspective, PerspectiveExpression, PerspectiveInput, PerspectiveUnsignedInput } from "../perspectives/Perspective";
|
|
4
|
+
import { DID } from "../DID";
|
|
5
|
+
import { TEST_AGENT_DID } from "../agent/AgentResolver";
|
|
6
|
+
import { OnlineAgent } from "../language/Language";
|
|
7
|
+
import { testLink } from "../perspectives/PerspectiveResolver";
|
|
8
|
+
import { NEIGHBOURHOOD_SIGNAL_RECEIVED_TOPIC, PERSPECTIVE_UPDATED_TOPIC } from "../PubSub";
|
|
9
|
+
|
|
10
|
+
const testPerspectiveExpression = new PerspectiveExpression()
|
|
11
|
+
testPerspectiveExpression.author = TEST_AGENT_DID
|
|
12
|
+
testPerspectiveExpression.timestamp = new Date().toISOString()
|
|
13
|
+
testPerspectiveExpression.data = new Perspective([testLink])
|
|
14
|
+
testPerspectiveExpression.proof = {
|
|
15
|
+
signature: '',
|
|
16
|
+
key: '',
|
|
17
|
+
valid: true
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Resolver classes are used here to define the GraphQL schema
|
|
22
|
+
* (through the type-graphql annotations)
|
|
23
|
+
* and are spawned in the client tests in Ad4mClient.test.ts.
|
|
24
|
+
* For the latter, they return test fixtures.
|
|
25
|
+
*/
|
|
26
|
+
@Resolver()
|
|
27
|
+
export default class NeighbourhoodResolver {
|
|
28
|
+
@Mutation(returns => String)
|
|
29
|
+
neighbourhoodPublishFromPerspective(
|
|
30
|
+
@Arg('perspectiveUUID') perspectiveUUID: string,
|
|
31
|
+
@Arg('linkLanguage') linkLanguage: string,
|
|
32
|
+
@Arg('meta') meta: PerspectiveInput
|
|
33
|
+
): string {
|
|
34
|
+
return "neighbourhood://neighbourhoodAddress"
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@Mutation(returns => PerspectiveHandle)
|
|
38
|
+
neighbourhoodJoinFromUrl(@Arg('url') url: string, @PubSub() pubSub: any): PerspectiveHandle {
|
|
39
|
+
const perspective = new PerspectiveHandle
|
|
40
|
+
perspective.name = "test-perspective"
|
|
41
|
+
perspective.sharedUrl = url
|
|
42
|
+
perspective.uuid = "234234234"
|
|
43
|
+
perspective.state = PerspectiveState.Synced
|
|
44
|
+
pubSub.publish(PERSPECTIVE_UPDATED_TOPIC, { perspective});
|
|
45
|
+
return perspective
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@Query(returns => [String])
|
|
49
|
+
neighbourhoodOtherAgents(@Arg('perspectiveUUID') perspectiveUUID: string): DID[] {
|
|
50
|
+
return ['did:test:other']
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@Query()
|
|
54
|
+
neighbourhoodHasTelepresenceAdapter(@Arg('perspectiveUUID') perspectiveUUID: string): boolean {
|
|
55
|
+
return true
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@Query(returns => [OnlineAgent])
|
|
59
|
+
neighbourhoodOnlineAgents(@Arg('perspectiveUUID') perspectiveUUID: string): OnlineAgent[] {
|
|
60
|
+
const onlineAgent = new OnlineAgent()
|
|
61
|
+
onlineAgent.did = 'did:test:online'
|
|
62
|
+
onlineAgent.status = testPerspectiveExpression
|
|
63
|
+
return [onlineAgent]
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@Mutation()
|
|
67
|
+
neighbourhoodSetOnlineStatus(@Arg('perspectiveUUID') perspectiveUUID: string, @Arg('status') status: PerspectiveInput): boolean {
|
|
68
|
+
return true
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@Mutation()
|
|
72
|
+
neighbourhoodSetOnlineStatusU(@Arg('perspectiveUUID') perspectiveUUID: string, @Arg('status') status: PerspectiveUnsignedInput): boolean {
|
|
73
|
+
return true
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
@Mutation()
|
|
77
|
+
neighbourhoodSendSignal(@Arg('perspectiveUUID') perspectiveUUID: string, @Arg('remoteAgentDid') recipient: DID, @Arg('payload') signal: PerspectiveInput): boolean {
|
|
78
|
+
return true
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@Mutation()
|
|
82
|
+
neighbourhoodSendSignalU(@Arg('perspectiveUUID') perspectiveUUID: string, @Arg('remoteAgentDid') recipient: DID, @Arg('payload') signal: PerspectiveUnsignedInput): boolean {
|
|
83
|
+
return true
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
@Mutation()
|
|
87
|
+
neighbourhoodSendBroadcast(@Arg('perspectiveUUID') perspectiveUUID: string, @Arg('payload') signal: PerspectiveInput): boolean {
|
|
88
|
+
return true
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
@Mutation()
|
|
92
|
+
neighbourhoodSendBroadcastU(@Arg('perspectiveUUID') perspectiveUUID: string, @Arg('payload') signal: PerspectiveUnsignedInput): boolean {
|
|
93
|
+
return true
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
@Subscription({topics: NEIGHBOURHOOD_SIGNAL_RECEIVED_TOPIC, nullable: true})
|
|
97
|
+
neighbourhoodSignal(@Arg('perspectiveUUID') pID: string): PerspectiveExpression {
|
|
98
|
+
return testPerspectiveExpression
|
|
99
|
+
}
|
|
100
100
|
}
|
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
import { Field, InputType, ObjectType } from "type-graphql";
|
|
2
|
-
import { Link } from "../links/Links"
|
|
3
|
-
|
|
4
|
-
@ObjectType()
|
|
5
|
-
@InputType()
|
|
6
|
-
export class LinkQuery {
|
|
7
|
-
@Field({nullable: true})
|
|
8
|
-
source?: string;
|
|
9
|
-
|
|
10
|
-
@Field({nullable: true})
|
|
11
|
-
target?: string;
|
|
12
|
-
|
|
13
|
-
@Field({nullable: true})
|
|
14
|
-
predicate?: string;
|
|
15
|
-
|
|
16
|
-
@Field({nullable: true})
|
|
17
|
-
fromDate?: Date;
|
|
18
|
-
|
|
19
|
-
@Field({nullable: true})
|
|
20
|
-
untilDate?: Date;
|
|
21
|
-
|
|
22
|
-
@Field({nullable: true})
|
|
23
|
-
limit?: number;
|
|
24
|
-
|
|
25
|
-
constructor(obj: object) {
|
|
26
|
-
if(obj) {
|
|
27
|
-
// @ts-ignore
|
|
28
|
-
this.source = obj.source
|
|
29
|
-
// @ts-ignore
|
|
30
|
-
this.predicate = obj.predicate
|
|
31
|
-
// @ts-ignore
|
|
32
|
-
this.target = obj.target
|
|
33
|
-
// @ts-ignore
|
|
34
|
-
if(obj.fromDate) {
|
|
35
|
-
// @ts-ignore
|
|
36
|
-
this.fromDate = obj.fromDate;
|
|
37
|
-
};
|
|
38
|
-
// @ts-ignore
|
|
39
|
-
if (obj.untilDate) {
|
|
40
|
-
// @ts-ignore
|
|
41
|
-
this.untilDate = obj.untilDate;
|
|
42
|
-
}
|
|
43
|
-
// @ts-ignore
|
|
44
|
-
if (obj.limit) {
|
|
45
|
-
// @ts-ignore
|
|
46
|
-
this.limit = obj.limit;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
isMatch(l: Link): boolean {
|
|
52
|
-
if(this.source)
|
|
53
|
-
if(this.source !== l.source)
|
|
54
|
-
return false
|
|
55
|
-
|
|
56
|
-
if(this.predicate)
|
|
57
|
-
if(this.predicate !== l.predicate)
|
|
58
|
-
return false
|
|
59
|
-
|
|
60
|
-
if(this.target)
|
|
61
|
-
if(this.target !== l.target)
|
|
62
|
-
return false
|
|
63
|
-
|
|
64
|
-
return true
|
|
65
|
-
}
|
|
1
|
+
import { Field, InputType, ObjectType } from "type-graphql";
|
|
2
|
+
import { Link } from "../links/Links"
|
|
3
|
+
|
|
4
|
+
@ObjectType()
|
|
5
|
+
@InputType()
|
|
6
|
+
export class LinkQuery {
|
|
7
|
+
@Field({nullable: true})
|
|
8
|
+
source?: string;
|
|
9
|
+
|
|
10
|
+
@Field({nullable: true})
|
|
11
|
+
target?: string;
|
|
12
|
+
|
|
13
|
+
@Field({nullable: true})
|
|
14
|
+
predicate?: string;
|
|
15
|
+
|
|
16
|
+
@Field({nullable: true})
|
|
17
|
+
fromDate?: Date;
|
|
18
|
+
|
|
19
|
+
@Field({nullable: true})
|
|
20
|
+
untilDate?: Date;
|
|
21
|
+
|
|
22
|
+
@Field({nullable: true})
|
|
23
|
+
limit?: number;
|
|
24
|
+
|
|
25
|
+
constructor(obj: object) {
|
|
26
|
+
if(obj) {
|
|
27
|
+
// @ts-ignore
|
|
28
|
+
this.source = obj.source
|
|
29
|
+
// @ts-ignore
|
|
30
|
+
this.predicate = obj.predicate
|
|
31
|
+
// @ts-ignore
|
|
32
|
+
this.target = obj.target
|
|
33
|
+
// @ts-ignore
|
|
34
|
+
if(obj.fromDate) {
|
|
35
|
+
// @ts-ignore
|
|
36
|
+
this.fromDate = obj.fromDate;
|
|
37
|
+
};
|
|
38
|
+
// @ts-ignore
|
|
39
|
+
if (obj.untilDate) {
|
|
40
|
+
// @ts-ignore
|
|
41
|
+
this.untilDate = obj.untilDate;
|
|
42
|
+
}
|
|
43
|
+
// @ts-ignore
|
|
44
|
+
if (obj.limit) {
|
|
45
|
+
// @ts-ignore
|
|
46
|
+
this.limit = obj.limit;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
isMatch(l: Link): boolean {
|
|
52
|
+
if(this.source)
|
|
53
|
+
if(this.source !== l.source)
|
|
54
|
+
return false
|
|
55
|
+
|
|
56
|
+
if(this.predicate)
|
|
57
|
+
if(this.predicate !== l.predicate)
|
|
58
|
+
return false
|
|
59
|
+
|
|
60
|
+
if(this.target)
|
|
61
|
+
if(this.target !== l.target)
|
|
62
|
+
return false
|
|
63
|
+
|
|
64
|
+
return true
|
|
65
|
+
}
|
|
66
66
|
}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { Perspective } from "./Perspective"
|
|
2
|
-
import { Link, LinkExpression } from "../links/Links"
|
|
3
|
-
import { LinkQuery } from "./LinkQuery"
|
|
4
|
-
|
|
5
|
-
const link = new LinkExpression()
|
|
6
|
-
link.author = 'did:method:12345'
|
|
7
|
-
link.timestamp = new Date().toString()
|
|
8
|
-
link.data = new Link({source: 'root', target: 'perspective://Qm34589a3ccc0'})
|
|
9
|
-
link.proof = { signature: 'asdfasdf', key: 'asdfasdf' }
|
|
10
|
-
|
|
11
|
-
describe('Perspective', () => {
|
|
12
|
-
it('implements get()', () => {
|
|
13
|
-
let p = new Perspective([link])
|
|
14
|
-
let result = p.get(new LinkQuery({source: 'root'}))
|
|
15
|
-
expect(result).toEqual([link])
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
it('implements getSingleTarget()', () => {
|
|
19
|
-
let p = new Perspective([link])
|
|
20
|
-
let result = p.getSingleTarget(new LinkQuery({source: 'root'}))
|
|
21
|
-
expect(result).toEqual(link.data.target)
|
|
22
|
-
})
|
|
1
|
+
import { Perspective } from "./Perspective"
|
|
2
|
+
import { Link, LinkExpression } from "../links/Links"
|
|
3
|
+
import { LinkQuery } from "./LinkQuery"
|
|
4
|
+
|
|
5
|
+
const link = new LinkExpression()
|
|
6
|
+
link.author = 'did:method:12345'
|
|
7
|
+
link.timestamp = new Date().toString()
|
|
8
|
+
link.data = new Link({source: 'root', target: 'perspective://Qm34589a3ccc0'})
|
|
9
|
+
link.proof = { signature: 'asdfasdf', key: 'asdfasdf' }
|
|
10
|
+
|
|
11
|
+
describe('Perspective', () => {
|
|
12
|
+
it('implements get()', () => {
|
|
13
|
+
let p = new Perspective([link])
|
|
14
|
+
let result = p.get(new LinkQuery({source: 'root'}))
|
|
15
|
+
expect(result).toEqual([link])
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
it('implements getSingleTarget()', () => {
|
|
19
|
+
let p = new Perspective([link])
|
|
20
|
+
let result = p.getSingleTarget(new LinkQuery({source: 'root'}))
|
|
21
|
+
expect(result).toEqual(link.data.target)
|
|
22
|
+
})
|
|
23
23
|
})
|