@coasys/ad4m 0.8.0-fix
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 -0
- package/jest-setup.ts +1 -0
- package/jest.config.js +6 -0
- package/jsdoc.json +28 -0
- package/lib/index.cjs +8165 -0
- package/lib/index.js +8130 -0
- package/lib/shims/reflect-metadata.d.ts +0 -0
- package/lib/shims/reflect-metadata.js +0 -0
- package/lib/shims/type-graphql.d.ts +32 -0
- package/lib/shims/type-graphql.js +70 -0
- package/lib/src/Ad4mClient.d.ts +26 -0
- package/lib/src/Ad4mClient.js +66 -0
- package/lib/src/Address.d.ts +1 -0
- package/lib/src/Address.js +1 -0
- package/lib/src/DID.d.ts +1 -0
- package/lib/src/DID.js +1 -0
- package/lib/src/Exception.d.ts +6 -0
- package/lib/src/Exception.js +7 -0
- package/lib/src/Literal.d.ts +7 -0
- package/lib/src/Literal.js +76 -0
- package/lib/src/PubSub.d.ts +14 -0
- package/lib/src/PubSub.js +14 -0
- package/lib/src/SmartLiteral.d.ts +12 -0
- package/lib/src/SmartLiteral.js +74 -0
- package/lib/src/agent/Agent.d.ts +104 -0
- package/lib/src/agent/Agent.js +337 -0
- package/lib/src/agent/AgentClient.d.ts +57 -0
- package/lib/src/agent/AgentClient.js +431 -0
- package/lib/src/agent/AgentResolver.d.ts +30 -0
- package/lib/src/agent/AgentResolver.js +325 -0
- package/lib/src/agent/AgentStatus.d.ts +8 -0
- package/lib/src/agent/AgentStatus.js +61 -0
- package/lib/src/buildSchema.d.ts +1 -0
- package/lib/src/buildSchema.js +36 -0
- package/lib/src/expression/Expression.d.ts +28 -0
- package/lib/src/expression/Expression.js +143 -0
- package/lib/src/expression/ExpressionClient.d.ts +13 -0
- package/lib/src/expression/ExpressionClient.js +102 -0
- package/lib/src/expression/ExpressionRef.d.ts +9 -0
- package/lib/src/expression/ExpressionRef.js +67 -0
- package/lib/src/expression/ExpressionResolver.d.ts +10 -0
- package/lib/src/expression/ExpressionResolver.js +106 -0
- package/lib/src/index.d.ts +30 -0
- package/lib/src/index.js +30 -0
- package/lib/src/jestSetup.d.ts +1 -0
- package/lib/src/jestSetup.js +1 -0
- package/lib/src/language/Icon.d.ts +4 -0
- package/lib/src/language/Icon.js +24 -0
- package/lib/src/language/Language.d.ts +195 -0
- package/lib/src/language/Language.js +79 -0
- package/lib/src/language/LanguageClient.d.ts +17 -0
- package/lib/src/language/LanguageClient.js +137 -0
- package/lib/src/language/LanguageContext.d.ts +37 -0
- package/lib/src/language/LanguageContext.js +2 -0
- package/lib/src/language/LanguageHandle.d.ts +9 -0
- package/lib/src/language/LanguageHandle.js +41 -0
- package/lib/src/language/LanguageMeta.d.ts +35 -0
- package/lib/src/language/LanguageMeta.js +89 -0
- package/lib/src/language/LanguageRef.d.ts +6 -0
- package/lib/src/language/LanguageRef.js +30 -0
- package/lib/src/language/LanguageResolver.d.ts +19 -0
- package/lib/src/language/LanguageResolver.js +143 -0
- package/lib/src/links/Links.d.ts +39 -0
- package/lib/src/links/Links.js +148 -0
- package/lib/src/links/Links.test.d.ts +1 -0
- package/lib/src/links/Links.test.js +33 -0
- package/lib/src/neighbourhood/Neighbourhood.d.ts +10 -0
- package/lib/src/neighbourhood/Neighbourhood.js +38 -0
- package/lib/src/neighbourhood/NeighbourhoodClient.d.ts +25 -0
- package/lib/src/neighbourhood/NeighbourhoodClient.js +256 -0
- package/lib/src/neighbourhood/NeighbourhoodProxy.d.ts +19 -0
- package/lib/src/neighbourhood/NeighbourhoodProxy.js +54 -0
- package/lib/src/neighbourhood/NeighbourhoodResolver.d.ts +24 -0
- package/lib/src/neighbourhood/NeighbourhoodResolver.js +180 -0
- package/lib/src/perspectives/LinkQuery.d.ts +11 -0
- package/lib/src/perspectives/LinkQuery.js +80 -0
- package/lib/src/perspectives/Perspective.d.ts +38 -0
- package/lib/src/perspectives/Perspective.js +144 -0
- package/lib/src/perspectives/Perspective.test.d.ts +1 -0
- package/lib/src/perspectives/Perspective.test.js +20 -0
- package/lib/src/perspectives/PerspectiveClient.d.ts +54 -0
- package/lib/src/perspectives/PerspectiveClient.js +410 -0
- package/lib/src/perspectives/PerspectiveDiff.d.ts +9 -0
- package/lib/src/perspectives/PerspectiveDiff.js +33 -0
- package/lib/src/perspectives/PerspectiveHandle.d.ts +16 -0
- package/lib/src/perspectives/PerspectiveHandle.js +59 -0
- package/lib/src/perspectives/PerspectiveProxy.d.ts +178 -0
- package/lib/src/perspectives/PerspectiveProxy.js +540 -0
- package/lib/src/perspectives/PerspectiveResolver.d.ts +37 -0
- package/lib/src/perspectives/PerspectiveResolver.js +362 -0
- package/lib/src/runtime/RuntimeClient.d.ts +33 -0
- package/lib/src/runtime/RuntimeClient.js +263 -0
- package/lib/src/runtime/RuntimeResolver.d.ts +47 -0
- package/lib/src/runtime/RuntimeResolver.js +328 -0
- package/lib/src/schema.gql +382 -0
- package/lib/src/subject/SDNADecorators.d.ts +45 -0
- package/lib/src/subject/SDNADecorators.js +250 -0
- package/lib/src/subject/Subject.d.ts +7 -0
- package/lib/src/subject/Subject.js +160 -0
- package/lib/src/subject/SubjectEntity.d.ts +31 -0
- package/lib/src/subject/SubjectEntity.js +250 -0
- package/lib/src/subject/util.d.ts +12 -0
- package/lib/src/subject/util.js +73 -0
- package/lib/src/typeDefs.d.ts +1 -0
- package/lib/src/typeDefs.js +379 -0
- package/lib/src/unwrapApolloResult.d.ts +2 -0
- package/lib/src/unwrapApolloResult.js +12 -0
- package/lib/src/utils.d.ts +2 -0
- package/lib/src/utils.js +21 -0
- package/package.json +61 -0
- package/rollup.config.js +27 -0
- package/shims/reflect-metadata.ts +0 -0
- package/shims/type-graphql.ts +75 -0
- package/src/Ad4mClient.test.ts +1085 -0
- package/src/Ad4mClient.ts +63 -0
- package/src/Address.ts +1 -0
- package/src/DID.ts +1 -0
- package/src/Exception.ts +6 -0
- package/src/Literal.test.ts +31 -0
- package/src/Literal.ts +81 -0
- package/src/PubSub.ts +14 -0
- package/src/SmartLiteral.ts +75 -0
- package/src/agent/Agent.ts +293 -0
- package/src/agent/AgentClient.ts +531 -0
- package/src/agent/AgentResolver.ts +263 -0
- package/src/agent/AgentStatus.ts +44 -0
- package/src/buildSchema.ts +41 -0
- package/src/expression/Expression.ts +99 -0
- package/src/expression/ExpressionClient.ts +99 -0
- package/src/expression/ExpressionRef.ts +63 -0
- package/src/expression/ExpressionResolver.ts +64 -0
- package/src/index.ts +30 -0
- package/src/jestSetup.ts +1 -0
- package/src/language/Icon.ts +11 -0
- package/src/language/Language.ts +266 -0
- package/src/language/LanguageClient.ts +160 -0
- package/src/language/LanguageContext.ts +37 -0
- package/src/language/LanguageHandle.ts +23 -0
- package/src/language/LanguageMeta.ts +70 -0
- package/src/language/LanguageRef.ts +18 -0
- package/src/language/LanguageResolver.ts +98 -0
- package/src/links/Links.test.ts +40 -0
- package/src/links/Links.ts +107 -0
- package/src/neighbourhood/Neighbourhood.ts +22 -0
- package/src/neighbourhood/NeighbourhoodClient.ts +276 -0
- package/src/neighbourhood/NeighbourhoodProxy.ts +58 -0
- package/src/neighbourhood/NeighbourhoodResolver.ts +100 -0
- package/src/perspectives/LinkQuery.ts +66 -0
- package/src/perspectives/Perspective.test.ts +23 -0
- package/src/perspectives/Perspective.ts +118 -0
- package/src/perspectives/PerspectiveClient.ts +444 -0
- package/src/perspectives/PerspectiveDiff.ts +15 -0
- package/src/perspectives/PerspectiveHandle.ts +39 -0
- package/src/perspectives/PerspectiveProxy.ts +611 -0
- package/src/perspectives/PerspectiveResolver.ts +220 -0
- package/src/runtime/RuntimeClient.ts +283 -0
- package/src/runtime/RuntimeResolver.ts +193 -0
- package/src/subject/SDNADecorators.ts +334 -0
- package/src/subject/Subject.ts +153 -0
- package/src/subject/SubjectEntity.ts +292 -0
- package/src/subject/util.ts +85 -0
- package/src/typeDefs.ts +6 -0
- package/src/unwrapApolloResult.ts +14 -0
- package/src/utils.ts +25 -0
- package/tsconfig-browser.json +82 -0
- package/tsconfig.json +80 -0
- package/yarn-error.log +22814 -0
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
import { Arg, Mutation, PubSub, Query, Resolver, Subscription } from "type-graphql";
|
|
14
|
+
import { LinkExpression, LinkExpressionInput, LinkExpressionMutations, LinkExpressionUpdated, LinkInput, LinkMutations } from "../links/Links";
|
|
15
|
+
import { Neighbourhood, NeighbourhoodExpression } from "../neighbourhood/Neighbourhood";
|
|
16
|
+
import { LinkQuery } from "./LinkQuery";
|
|
17
|
+
import { Perspective } from "./Perspective";
|
|
18
|
+
import { PerspectiveHandle, PerspectiveState } from "./PerspectiveHandle";
|
|
19
|
+
import { LINK_ADDED_TOPIC, LINK_REMOVED_TOPIC, LINK_UDATED_TOPIC, PERSPECTIVE_ADDED_TOPIC, PERSPECTIVE_REMOVED_TOPIC, PERSPECTIVE_UPDATED_TOPIC, PERSPECTIVE_SYNC_STATE_CHANGE } from '../PubSub';
|
|
20
|
+
export const testLink = new LinkExpression();
|
|
21
|
+
testLink.author = "did:ad4m:test";
|
|
22
|
+
testLink.timestamp = Date.now();
|
|
23
|
+
testLink.data = {
|
|
24
|
+
source: 'root',
|
|
25
|
+
target: 'neighbourhood://Qm12345'
|
|
26
|
+
};
|
|
27
|
+
testLink.proof = {
|
|
28
|
+
signature: '',
|
|
29
|
+
key: '',
|
|
30
|
+
valid: true
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Resolver classes are used here to define the GraphQL schema
|
|
34
|
+
* (through the type-graphql annotations)
|
|
35
|
+
* and are spawned in the client tests in Ad4mClient.test.ts.
|
|
36
|
+
* For the latter, they return test fixtures.
|
|
37
|
+
*/
|
|
38
|
+
let PerspectiveResolver = class PerspectiveResolver {
|
|
39
|
+
perspectives() {
|
|
40
|
+
const p1 = new PerspectiveHandle();
|
|
41
|
+
p1.name = 'test-perspective-1';
|
|
42
|
+
p1.uuid = '00001';
|
|
43
|
+
const p2 = new PerspectiveHandle();
|
|
44
|
+
p2.name = 'test-perspective-2';
|
|
45
|
+
p2.uuid = '00002';
|
|
46
|
+
p2.sharedUrl = 'neighbourhood://Qm12345';
|
|
47
|
+
const neighbourhood = new NeighbourhoodExpression();
|
|
48
|
+
neighbourhood.data = new Neighbourhood("language://Qm12345", new Perspective());
|
|
49
|
+
neighbourhood.author = "did:ad4m:test";
|
|
50
|
+
neighbourhood.timestamp = Date.now();
|
|
51
|
+
neighbourhood.proof = {
|
|
52
|
+
signature: '',
|
|
53
|
+
key: '',
|
|
54
|
+
valid: true
|
|
55
|
+
};
|
|
56
|
+
p2.neighbourhood = neighbourhood;
|
|
57
|
+
p2.state = PerspectiveState.Synced;
|
|
58
|
+
return [p1, p2];
|
|
59
|
+
}
|
|
60
|
+
perspective(uuid) {
|
|
61
|
+
return new PerspectiveHandle(uuid, 'test-perspective-1');
|
|
62
|
+
}
|
|
63
|
+
perspectiveSnapshot(uuid) {
|
|
64
|
+
return new Perspective([testLink]);
|
|
65
|
+
}
|
|
66
|
+
perspectivePublishSnapshot(uuid) {
|
|
67
|
+
return 'perspective://Qm12345';
|
|
68
|
+
}
|
|
69
|
+
perspectiveQueryLinks(uuid, query) {
|
|
70
|
+
return [testLink];
|
|
71
|
+
}
|
|
72
|
+
perspectiveQueryProlog(uuid, query) {
|
|
73
|
+
return `[{"X": 1}]`;
|
|
74
|
+
}
|
|
75
|
+
perspectiveAdd(name, pubSub) {
|
|
76
|
+
const perspective = new PerspectiveHandle('00006', name);
|
|
77
|
+
pubSub.publish(PERSPECTIVE_ADDED_TOPIC, { perspective });
|
|
78
|
+
return new PerspectiveHandle('00006', name);
|
|
79
|
+
}
|
|
80
|
+
perspectiveUpdate(uuid, name, pubSub) {
|
|
81
|
+
const perspective = new PerspectiveHandle(uuid, name);
|
|
82
|
+
pubSub.publish(PERSPECTIVE_UPDATED_TOPIC, { perspective });
|
|
83
|
+
return new PerspectiveHandle(uuid, name);
|
|
84
|
+
}
|
|
85
|
+
perspectiveRemove(uuid, pubSub) {
|
|
86
|
+
const perspective = new PerspectiveHandle(uuid);
|
|
87
|
+
pubSub.publish(PERSPECTIVE_REMOVED_TOPIC, { perspective });
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
perspectiveAddLink(uuid, link, status, pubSub) {
|
|
91
|
+
const l = new LinkExpression();
|
|
92
|
+
l.author = 'did:ad4m:test';
|
|
93
|
+
l.timestamp = Date.now();
|
|
94
|
+
l.proof = testLink.proof;
|
|
95
|
+
l.data = link;
|
|
96
|
+
l.status = status;
|
|
97
|
+
pubSub.publish(LINK_ADDED_TOPIC, { link: l });
|
|
98
|
+
pubSub.publish(PERSPECTIVE_SYNC_STATE_CHANGE, PerspectiveState.LinkLanguageInstalledButNotSynced);
|
|
99
|
+
return l;
|
|
100
|
+
}
|
|
101
|
+
perspectiveAddLinks(uuid, links, status, pubSub) {
|
|
102
|
+
const l = new LinkExpression();
|
|
103
|
+
l.author = 'did:ad4m:test';
|
|
104
|
+
l.timestamp = Date.now();
|
|
105
|
+
l.proof = testLink.proof;
|
|
106
|
+
l.data = links[0];
|
|
107
|
+
const l2 = new LinkExpression();
|
|
108
|
+
l2.author = 'did:ad4m:test';
|
|
109
|
+
l2.timestamp = Date.now();
|
|
110
|
+
l2.proof = testLink.proof;
|
|
111
|
+
l2.data = links[0];
|
|
112
|
+
pubSub.publish(LINK_ADDED_TOPIC, { link: l });
|
|
113
|
+
pubSub.publish(LINK_ADDED_TOPIC, { link: l2 });
|
|
114
|
+
return [l, l2];
|
|
115
|
+
}
|
|
116
|
+
perspectiveRemoveLinks(uuid, links, pubSub) {
|
|
117
|
+
const l = new LinkExpression();
|
|
118
|
+
l.author = 'did:ad4m:test';
|
|
119
|
+
l.timestamp = Date.now();
|
|
120
|
+
l.proof = testLink.proof;
|
|
121
|
+
l.data = links[0].data;
|
|
122
|
+
const l2 = new LinkExpression();
|
|
123
|
+
l2.author = 'did:ad4m:test';
|
|
124
|
+
l2.timestamp = Date.now();
|
|
125
|
+
l2.proof = testLink.proof;
|
|
126
|
+
l2.data = links[0].data;
|
|
127
|
+
pubSub.publish(LINK_REMOVED_TOPIC, { link: l });
|
|
128
|
+
pubSub.publish(LINK_ADDED_TOPIC, { link: l2 });
|
|
129
|
+
return [l, l2];
|
|
130
|
+
}
|
|
131
|
+
perspectiveLinkMutations(uuid, mutations, status, pubSub) {
|
|
132
|
+
const perspectiveAddLinks = this.perspectiveAddLinks(uuid, mutations.additions, status, pubSub);
|
|
133
|
+
const perspectiveRemoveLinks = this.perspectiveRemoveLinks(uuid, mutations.removals, pubSub);
|
|
134
|
+
return new LinkExpressionMutations(perspectiveAddLinks, perspectiveRemoveLinks);
|
|
135
|
+
}
|
|
136
|
+
perspectiveAddLinkExpression(uuid, link, status, pubSub) {
|
|
137
|
+
pubSub.publish(LINK_ADDED_TOPIC, { link });
|
|
138
|
+
link.status = status;
|
|
139
|
+
return link;
|
|
140
|
+
}
|
|
141
|
+
perspectiveUpdateLink(uuid, oldlink, newlink, pubSub) {
|
|
142
|
+
const l = new LinkExpression();
|
|
143
|
+
l.author = 'did:ad4m:test';
|
|
144
|
+
l.timestamp = Date.now();
|
|
145
|
+
l.proof = testLink.proof;
|
|
146
|
+
l.data = newlink;
|
|
147
|
+
pubSub.publish(LINK_REMOVED_TOPIC, { link: l });
|
|
148
|
+
return l;
|
|
149
|
+
}
|
|
150
|
+
perspectiveRemoveLink(uuid, link, pubSub) {
|
|
151
|
+
pubSub.publish(LINK_REMOVED_TOPIC);
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
perspectiveAdded() {
|
|
155
|
+
const perspective = new PerspectiveHandle('00001', 'New Perspective');
|
|
156
|
+
return perspective;
|
|
157
|
+
}
|
|
158
|
+
perspectiveUpdated() {
|
|
159
|
+
return new PerspectiveHandle('00001', 'New Perspective');
|
|
160
|
+
}
|
|
161
|
+
perspectiveRemoved() {
|
|
162
|
+
return '00006';
|
|
163
|
+
}
|
|
164
|
+
perspectiveLinkAdded(uuid) {
|
|
165
|
+
return testLink;
|
|
166
|
+
}
|
|
167
|
+
perspectiveLinkRemoved(uuid) {
|
|
168
|
+
return testLink;
|
|
169
|
+
}
|
|
170
|
+
perspectiveLinkUpdated(uuid) {
|
|
171
|
+
return { oldLink: testLink, newLink: testLink };
|
|
172
|
+
}
|
|
173
|
+
perspectiveSyncStateChange(uuid) {
|
|
174
|
+
return PerspectiveState.Synced;
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
__decorate([
|
|
178
|
+
Query(returns => [PerspectiveHandle]),
|
|
179
|
+
__metadata("design:type", Function),
|
|
180
|
+
__metadata("design:paramtypes", []),
|
|
181
|
+
__metadata("design:returntype", Array)
|
|
182
|
+
], PerspectiveResolver.prototype, "perspectives", null);
|
|
183
|
+
__decorate([
|
|
184
|
+
Query(returns => PerspectiveHandle, { nullable: true }),
|
|
185
|
+
__param(0, Arg('uuid')),
|
|
186
|
+
__metadata("design:type", Function),
|
|
187
|
+
__metadata("design:paramtypes", [String]),
|
|
188
|
+
__metadata("design:returntype", PerspectiveHandle)
|
|
189
|
+
], PerspectiveResolver.prototype, "perspective", null);
|
|
190
|
+
__decorate([
|
|
191
|
+
Query(returns => Perspective, { nullable: true }),
|
|
192
|
+
__param(0, Arg('uuid')),
|
|
193
|
+
__metadata("design:type", Function),
|
|
194
|
+
__metadata("design:paramtypes", [String]),
|
|
195
|
+
__metadata("design:returntype", Perspective)
|
|
196
|
+
], PerspectiveResolver.prototype, "perspectiveSnapshot", null);
|
|
197
|
+
__decorate([
|
|
198
|
+
Mutation(returns => String, { nullable: true }),
|
|
199
|
+
__param(0, Arg('uuid')),
|
|
200
|
+
__metadata("design:type", Function),
|
|
201
|
+
__metadata("design:paramtypes", [String]),
|
|
202
|
+
__metadata("design:returntype", String)
|
|
203
|
+
], PerspectiveResolver.prototype, "perspectivePublishSnapshot", null);
|
|
204
|
+
__decorate([
|
|
205
|
+
Query(returns => [LinkExpression], { nullable: true }),
|
|
206
|
+
__param(0, Arg('uuid')),
|
|
207
|
+
__param(1, Arg('query')),
|
|
208
|
+
__metadata("design:type", Function),
|
|
209
|
+
__metadata("design:paramtypes", [String, LinkQuery]),
|
|
210
|
+
__metadata("design:returntype", Array)
|
|
211
|
+
], PerspectiveResolver.prototype, "perspectiveQueryLinks", null);
|
|
212
|
+
__decorate([
|
|
213
|
+
Query(returns => String),
|
|
214
|
+
__param(0, Arg('uuid')),
|
|
215
|
+
__param(1, Arg('query')),
|
|
216
|
+
__metadata("design:type", Function),
|
|
217
|
+
__metadata("design:paramtypes", [String, String]),
|
|
218
|
+
__metadata("design:returntype", String)
|
|
219
|
+
], PerspectiveResolver.prototype, "perspectiveQueryProlog", null);
|
|
220
|
+
__decorate([
|
|
221
|
+
Mutation(returns => PerspectiveHandle),
|
|
222
|
+
__param(0, Arg('name')),
|
|
223
|
+
__param(1, PubSub()),
|
|
224
|
+
__metadata("design:type", Function),
|
|
225
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
226
|
+
__metadata("design:returntype", PerspectiveHandle)
|
|
227
|
+
], PerspectiveResolver.prototype, "perspectiveAdd", null);
|
|
228
|
+
__decorate([
|
|
229
|
+
Mutation(returns => PerspectiveHandle, { nullable: true }),
|
|
230
|
+
__param(0, Arg('uuid')),
|
|
231
|
+
__param(1, Arg('name')),
|
|
232
|
+
__param(2, PubSub()),
|
|
233
|
+
__metadata("design:type", Function),
|
|
234
|
+
__metadata("design:paramtypes", [String, String, Object]),
|
|
235
|
+
__metadata("design:returntype", PerspectiveHandle)
|
|
236
|
+
], PerspectiveResolver.prototype, "perspectiveUpdate", null);
|
|
237
|
+
__decorate([
|
|
238
|
+
Mutation(returns => Boolean),
|
|
239
|
+
__param(0, Arg('uuid')),
|
|
240
|
+
__param(1, PubSub()),
|
|
241
|
+
__metadata("design:type", Function),
|
|
242
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
243
|
+
__metadata("design:returntype", Boolean)
|
|
244
|
+
], PerspectiveResolver.prototype, "perspectiveRemove", null);
|
|
245
|
+
__decorate([
|
|
246
|
+
Mutation(returns => LinkExpression),
|
|
247
|
+
__param(0, Arg('uuid')),
|
|
248
|
+
__param(1, Arg('link')),
|
|
249
|
+
__param(2, Arg('status', { nullable: true, defaultValue: 'shared' })),
|
|
250
|
+
__param(3, PubSub()),
|
|
251
|
+
__metadata("design:type", Function),
|
|
252
|
+
__metadata("design:paramtypes", [String, LinkInput, String, Object]),
|
|
253
|
+
__metadata("design:returntype", LinkExpression)
|
|
254
|
+
], PerspectiveResolver.prototype, "perspectiveAddLink", null);
|
|
255
|
+
__decorate([
|
|
256
|
+
Mutation(returns => [LinkExpression]),
|
|
257
|
+
__param(0, Arg('uuid')),
|
|
258
|
+
__param(1, Arg('links', type => [LinkInput])),
|
|
259
|
+
__param(2, Arg('status', { nullable: true })),
|
|
260
|
+
__param(3, PubSub()),
|
|
261
|
+
__metadata("design:type", Function),
|
|
262
|
+
__metadata("design:paramtypes", [String, Array, String, Object]),
|
|
263
|
+
__metadata("design:returntype", Array)
|
|
264
|
+
], PerspectiveResolver.prototype, "perspectiveAddLinks", null);
|
|
265
|
+
__decorate([
|
|
266
|
+
Mutation(returns => [LinkExpression]),
|
|
267
|
+
__param(0, Arg('uuid')),
|
|
268
|
+
__param(1, Arg('links', type => [LinkExpressionInput])),
|
|
269
|
+
__param(2, PubSub()),
|
|
270
|
+
__metadata("design:type", Function),
|
|
271
|
+
__metadata("design:paramtypes", [String, Array, Object]),
|
|
272
|
+
__metadata("design:returntype", Array)
|
|
273
|
+
], PerspectiveResolver.prototype, "perspectiveRemoveLinks", null);
|
|
274
|
+
__decorate([
|
|
275
|
+
Mutation(returns => LinkExpressionMutations),
|
|
276
|
+
__param(0, Arg('uuid')),
|
|
277
|
+
__param(1, Arg('mutations')),
|
|
278
|
+
__param(2, Arg('status', { nullable: true })),
|
|
279
|
+
__param(3, PubSub()),
|
|
280
|
+
__metadata("design:type", Function),
|
|
281
|
+
__metadata("design:paramtypes", [String, LinkMutations, String, Object]),
|
|
282
|
+
__metadata("design:returntype", LinkExpressionMutations)
|
|
283
|
+
], PerspectiveResolver.prototype, "perspectiveLinkMutations", null);
|
|
284
|
+
__decorate([
|
|
285
|
+
Mutation(returns => LinkExpression),
|
|
286
|
+
__param(0, Arg('uuid')),
|
|
287
|
+
__param(1, Arg('link')),
|
|
288
|
+
__param(2, Arg('status', { nullable: true })),
|
|
289
|
+
__param(3, PubSub()),
|
|
290
|
+
__metadata("design:type", Function),
|
|
291
|
+
__metadata("design:paramtypes", [String, LinkExpressionInput, String, Object]),
|
|
292
|
+
__metadata("design:returntype", LinkExpression)
|
|
293
|
+
], PerspectiveResolver.prototype, "perspectiveAddLinkExpression", null);
|
|
294
|
+
__decorate([
|
|
295
|
+
Mutation(returns => LinkExpression),
|
|
296
|
+
__param(0, Arg('uuid')),
|
|
297
|
+
__param(1, Arg('oldLink')),
|
|
298
|
+
__param(2, Arg('newLink')),
|
|
299
|
+
__param(3, PubSub()),
|
|
300
|
+
__metadata("design:type", Function),
|
|
301
|
+
__metadata("design:paramtypes", [String, LinkExpressionInput, LinkInput, Object]),
|
|
302
|
+
__metadata("design:returntype", LinkExpression)
|
|
303
|
+
], PerspectiveResolver.prototype, "perspectiveUpdateLink", null);
|
|
304
|
+
__decorate([
|
|
305
|
+
Mutation(returns => Boolean),
|
|
306
|
+
__param(0, Arg('uuid')),
|
|
307
|
+
__param(1, Arg('link')),
|
|
308
|
+
__param(2, PubSub()),
|
|
309
|
+
__metadata("design:type", Function),
|
|
310
|
+
__metadata("design:paramtypes", [String, LinkExpressionInput, Object]),
|
|
311
|
+
__metadata("design:returntype", Boolean)
|
|
312
|
+
], PerspectiveResolver.prototype, "perspectiveRemoveLink", null);
|
|
313
|
+
__decorate([
|
|
314
|
+
Subscription({ topics: PERSPECTIVE_ADDED_TOPIC, nullable: true }),
|
|
315
|
+
__metadata("design:type", Function),
|
|
316
|
+
__metadata("design:paramtypes", []),
|
|
317
|
+
__metadata("design:returntype", PerspectiveHandle)
|
|
318
|
+
], PerspectiveResolver.prototype, "perspectiveAdded", null);
|
|
319
|
+
__decorate([
|
|
320
|
+
Subscription({ topics: PERSPECTIVE_UPDATED_TOPIC, nullable: true }),
|
|
321
|
+
__metadata("design:type", Function),
|
|
322
|
+
__metadata("design:paramtypes", []),
|
|
323
|
+
__metadata("design:returntype", PerspectiveHandle)
|
|
324
|
+
], PerspectiveResolver.prototype, "perspectiveUpdated", null);
|
|
325
|
+
__decorate([
|
|
326
|
+
Subscription({ topics: PERSPECTIVE_REMOVED_TOPIC, nullable: true }),
|
|
327
|
+
__metadata("design:type", Function),
|
|
328
|
+
__metadata("design:paramtypes", []),
|
|
329
|
+
__metadata("design:returntype", String)
|
|
330
|
+
], PerspectiveResolver.prototype, "perspectiveRemoved", null);
|
|
331
|
+
__decorate([
|
|
332
|
+
Subscription({ topics: LINK_ADDED_TOPIC, nullable: true }),
|
|
333
|
+
__param(0, Arg('uuid')),
|
|
334
|
+
__metadata("design:type", Function),
|
|
335
|
+
__metadata("design:paramtypes", [String]),
|
|
336
|
+
__metadata("design:returntype", LinkExpression)
|
|
337
|
+
], PerspectiveResolver.prototype, "perspectiveLinkAdded", null);
|
|
338
|
+
__decorate([
|
|
339
|
+
Subscription({ topics: LINK_REMOVED_TOPIC, nullable: true }),
|
|
340
|
+
__param(0, Arg('uuid')),
|
|
341
|
+
__metadata("design:type", Function),
|
|
342
|
+
__metadata("design:paramtypes", [String]),
|
|
343
|
+
__metadata("design:returntype", LinkExpression)
|
|
344
|
+
], PerspectiveResolver.prototype, "perspectiveLinkRemoved", null);
|
|
345
|
+
__decorate([
|
|
346
|
+
Subscription({ topics: LINK_UDATED_TOPIC, nullable: true }),
|
|
347
|
+
__param(0, Arg('uuid')),
|
|
348
|
+
__metadata("design:type", Function),
|
|
349
|
+
__metadata("design:paramtypes", [String]),
|
|
350
|
+
__metadata("design:returntype", LinkExpressionUpdated)
|
|
351
|
+
], PerspectiveResolver.prototype, "perspectiveLinkUpdated", null);
|
|
352
|
+
__decorate([
|
|
353
|
+
Subscription({ topics: PERSPECTIVE_SYNC_STATE_CHANGE, nullable: false }),
|
|
354
|
+
__param(0, Arg('uuid')),
|
|
355
|
+
__metadata("design:type", Function),
|
|
356
|
+
__metadata("design:paramtypes", [String]),
|
|
357
|
+
__metadata("design:returntype", String)
|
|
358
|
+
], PerspectiveResolver.prototype, "perspectiveSyncStateChange", null);
|
|
359
|
+
PerspectiveResolver = __decorate([
|
|
360
|
+
Resolver()
|
|
361
|
+
], PerspectiveResolver);
|
|
362
|
+
export default PerspectiveResolver;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ApolloClient } from "@apollo/client/core";
|
|
2
|
+
import { Perspective, PerspectiveExpression } from "../perspectives/Perspective";
|
|
3
|
+
import { RuntimeInfo, ExceptionInfo, SentMessage } from "./RuntimeResolver";
|
|
4
|
+
export type MessageCallback = (message: PerspectiveExpression) => null;
|
|
5
|
+
export type ExceptionCallback = (info: ExceptionInfo) => null;
|
|
6
|
+
export declare class RuntimeClient {
|
|
7
|
+
#private;
|
|
8
|
+
constructor(client: ApolloClient<any>, subscribe?: boolean);
|
|
9
|
+
info(): Promise<RuntimeInfo>;
|
|
10
|
+
quit(): Promise<Boolean>;
|
|
11
|
+
openLink(url: string): Promise<Boolean>;
|
|
12
|
+
addTrustedAgents(agents: string[]): Promise<string[]>;
|
|
13
|
+
deleteTrustedAgents(agents: string[]): Promise<string[]>;
|
|
14
|
+
getTrustedAgents(): Promise<string[]>;
|
|
15
|
+
addKnownLinkLanguageTemplates(addresses: string[]): Promise<string[]>;
|
|
16
|
+
removeKnownLinkLanguageTemplates(addresses: string[]): Promise<string[]>;
|
|
17
|
+
knownLinkLanguageTemplates(): Promise<string[]>;
|
|
18
|
+
addFriends(dids: string[]): Promise<string[]>;
|
|
19
|
+
removeFriends(dids: string[]): Promise<string[]>;
|
|
20
|
+
friends(): Promise<string[]>;
|
|
21
|
+
hcAgentInfos(): Promise<String>;
|
|
22
|
+
hcAddAgentInfos(agentInfos: String): Promise<void>;
|
|
23
|
+
verifyStringSignedByDid(did: string, didSigningKeyId: string, data: string, signedData: string): Promise<boolean>;
|
|
24
|
+
setStatus(perspective: Perspective): Promise<boolean>;
|
|
25
|
+
friendStatus(did: string): Promise<PerspectiveExpression>;
|
|
26
|
+
friendSendMessage(did: string, message: Perspective): Promise<boolean>;
|
|
27
|
+
messageInbox(filter?: string): Promise<PerspectiveExpression[]>;
|
|
28
|
+
messageOutbox(filter?: string): Promise<SentMessage[]>;
|
|
29
|
+
addMessageCallback(cb: MessageCallback): void;
|
|
30
|
+
subscribeMessageReceived(): void;
|
|
31
|
+
addExceptionCallback(cb: ExceptionCallback): void;
|
|
32
|
+
subscribeExceptionOccurred(): void;
|
|
33
|
+
}
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _RuntimeClient_apolloClient, _RuntimeClient_messageReceivedCallbacks, _RuntimeClient_exceptionOccurredCallbacks;
|
|
13
|
+
import { gql } from "@apollo/client/core";
|
|
14
|
+
import unwrapApolloResult from "../unwrapApolloResult";
|
|
15
|
+
const PERSPECTIVE_EXPRESSION_FIELDS = `
|
|
16
|
+
author
|
|
17
|
+
timestamp
|
|
18
|
+
data {
|
|
19
|
+
links {
|
|
20
|
+
author
|
|
21
|
+
timestamp
|
|
22
|
+
data { source, predicate, target }
|
|
23
|
+
proof { valid, invalid, signature, key }
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
proof { valid, invalid, signature, key }
|
|
27
|
+
`;
|
|
28
|
+
export class RuntimeClient {
|
|
29
|
+
constructor(client, subscribe = true) {
|
|
30
|
+
_RuntimeClient_apolloClient.set(this, void 0);
|
|
31
|
+
_RuntimeClient_messageReceivedCallbacks.set(this, void 0);
|
|
32
|
+
_RuntimeClient_exceptionOccurredCallbacks.set(this, void 0);
|
|
33
|
+
__classPrivateFieldSet(this, _RuntimeClient_apolloClient, client, "f");
|
|
34
|
+
__classPrivateFieldSet(this, _RuntimeClient_messageReceivedCallbacks, [], "f");
|
|
35
|
+
__classPrivateFieldSet(this, _RuntimeClient_exceptionOccurredCallbacks, [], "f");
|
|
36
|
+
if (subscribe) {
|
|
37
|
+
this.subscribeMessageReceived();
|
|
38
|
+
this.subscribeExceptionOccurred();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
async info() {
|
|
42
|
+
const { runtimeInfo } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").query({
|
|
43
|
+
query: gql `query runtimeInfo {
|
|
44
|
+
runtimeInfo {
|
|
45
|
+
ad4mExecutorVersion,
|
|
46
|
+
isInitialized,
|
|
47
|
+
isUnlocked
|
|
48
|
+
}
|
|
49
|
+
}`,
|
|
50
|
+
}));
|
|
51
|
+
return runtimeInfo;
|
|
52
|
+
}
|
|
53
|
+
async quit() {
|
|
54
|
+
const result = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
|
|
55
|
+
mutation: gql `mutation runtimeQuit { runtimeQuit }`
|
|
56
|
+
}));
|
|
57
|
+
return result.runtimeQuit;
|
|
58
|
+
}
|
|
59
|
+
async openLink(url) {
|
|
60
|
+
const { runtimeOpenLink } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
|
|
61
|
+
mutation: gql `mutation runtimeOpenLink($url: String!) {
|
|
62
|
+
runtimeOpenLink(url: $url)
|
|
63
|
+
}`,
|
|
64
|
+
variables: { url }
|
|
65
|
+
}));
|
|
66
|
+
return runtimeOpenLink;
|
|
67
|
+
}
|
|
68
|
+
async addTrustedAgents(agents) {
|
|
69
|
+
const { addTrustedAgents } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
|
|
70
|
+
mutation: gql `mutation addTrustedAgents($agents: [String!]!) {
|
|
71
|
+
addTrustedAgents(agents: $agents)
|
|
72
|
+
}`,
|
|
73
|
+
variables: { agents }
|
|
74
|
+
}));
|
|
75
|
+
return addTrustedAgents;
|
|
76
|
+
}
|
|
77
|
+
async deleteTrustedAgents(agents) {
|
|
78
|
+
const { deleteTrustedAgents } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
|
|
79
|
+
mutation: gql `mutation deleteTrustedAgents($agents: [String!]!) {
|
|
80
|
+
deleteTrustedAgents(agents: $agents)
|
|
81
|
+
}`,
|
|
82
|
+
variables: { agents }
|
|
83
|
+
}));
|
|
84
|
+
return deleteTrustedAgents;
|
|
85
|
+
}
|
|
86
|
+
async getTrustedAgents() {
|
|
87
|
+
const { getTrustedAgents } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").query({
|
|
88
|
+
query: gql `query getTrustedAgents {
|
|
89
|
+
getTrustedAgents
|
|
90
|
+
}`,
|
|
91
|
+
}));
|
|
92
|
+
return getTrustedAgents;
|
|
93
|
+
}
|
|
94
|
+
async addKnownLinkLanguageTemplates(addresses) {
|
|
95
|
+
const { runtimeAddKnownLinkLanguageTemplates } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
|
|
96
|
+
mutation: gql `mutation runtimeAddKnownLinkLanguageTemplates($addresses: [String!]!) {
|
|
97
|
+
runtimeAddKnownLinkLanguageTemplates(addresses: $addresses)
|
|
98
|
+
}`,
|
|
99
|
+
variables: { addresses }
|
|
100
|
+
}));
|
|
101
|
+
return runtimeAddKnownLinkLanguageTemplates;
|
|
102
|
+
}
|
|
103
|
+
async removeKnownLinkLanguageTemplates(addresses) {
|
|
104
|
+
const { runtimeRemoveKnownLinkLanguageTemplates } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
|
|
105
|
+
mutation: gql `mutation runtimeRemoveKnownLinkLanguageTemplates($addresses: [String!]!) {
|
|
106
|
+
runtimeRemoveKnownLinkLanguageTemplates(addresses: $addresses)
|
|
107
|
+
}`,
|
|
108
|
+
variables: { addresses }
|
|
109
|
+
}));
|
|
110
|
+
return runtimeRemoveKnownLinkLanguageTemplates;
|
|
111
|
+
}
|
|
112
|
+
async knownLinkLanguageTemplates() {
|
|
113
|
+
const { runtimeKnownLinkLanguageTemplates } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").query({
|
|
114
|
+
query: gql `query runtimeKnownLinkLanguageTemplates {
|
|
115
|
+
runtimeKnownLinkLanguageTemplates
|
|
116
|
+
}`,
|
|
117
|
+
}));
|
|
118
|
+
return runtimeKnownLinkLanguageTemplates;
|
|
119
|
+
}
|
|
120
|
+
async addFriends(dids) {
|
|
121
|
+
const { runtimeAddFriends } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
|
|
122
|
+
mutation: gql `mutation runtimeAddFriends($dids: [String!]!) {
|
|
123
|
+
runtimeAddFriends(dids: $dids)
|
|
124
|
+
}`,
|
|
125
|
+
variables: { dids }
|
|
126
|
+
}));
|
|
127
|
+
return runtimeAddFriends;
|
|
128
|
+
}
|
|
129
|
+
async removeFriends(dids) {
|
|
130
|
+
const { runtimeRemoveFriends } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
|
|
131
|
+
mutation: gql `mutation runtimeRemoveFriends($dids: [String!]!) {
|
|
132
|
+
runtimeRemoveFriends(dids: $dids)
|
|
133
|
+
}`,
|
|
134
|
+
variables: { dids }
|
|
135
|
+
}));
|
|
136
|
+
return runtimeRemoveFriends;
|
|
137
|
+
}
|
|
138
|
+
async friends() {
|
|
139
|
+
const { runtimeFriends } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").query({
|
|
140
|
+
query: gql `query runtimeFriends {
|
|
141
|
+
runtimeFriends
|
|
142
|
+
}`,
|
|
143
|
+
}));
|
|
144
|
+
return runtimeFriends;
|
|
145
|
+
}
|
|
146
|
+
async hcAgentInfos() {
|
|
147
|
+
const { runtimeHcAgentInfos } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").query({
|
|
148
|
+
query: gql `query runtimeHcAgentInfos {
|
|
149
|
+
runtimeHcAgentInfos
|
|
150
|
+
}`,
|
|
151
|
+
}));
|
|
152
|
+
return runtimeHcAgentInfos;
|
|
153
|
+
}
|
|
154
|
+
async hcAddAgentInfos(agentInfos) {
|
|
155
|
+
const { runtimeHcAddAgentInfos } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
|
|
156
|
+
mutation: gql `mutation runtimeHcAddAgentInfos($agentInfos: String!) {
|
|
157
|
+
runtimeHcAddAgentInfos(agentInfos: $agentInfos)
|
|
158
|
+
}`,
|
|
159
|
+
variables: { agentInfos }
|
|
160
|
+
}));
|
|
161
|
+
return runtimeHcAddAgentInfos;
|
|
162
|
+
}
|
|
163
|
+
async verifyStringSignedByDid(did, didSigningKeyId, data, signedData) {
|
|
164
|
+
const { runtimeVerifyStringSignedByDid } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
|
|
165
|
+
mutation: gql `query runtimeVerifyStringSignedByDid($did: String!, $didSigningKeyId: String!, $data: String!, $signedData: String!) {
|
|
166
|
+
runtimeVerifyStringSignedByDid(did: $did, didSigningKeyId: $didSigningKeyId, data: $data, signedData: $signedData)
|
|
167
|
+
}`,
|
|
168
|
+
variables: { did, didSigningKeyId, data, signedData }
|
|
169
|
+
}));
|
|
170
|
+
return runtimeVerifyStringSignedByDid;
|
|
171
|
+
}
|
|
172
|
+
async setStatus(perspective) {
|
|
173
|
+
const { runtimeSetStatus } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
|
|
174
|
+
mutation: gql `mutation runtimeSetStatus($status: PerspectiveInput!) {
|
|
175
|
+
runtimeSetStatus(status: $status)
|
|
176
|
+
}`,
|
|
177
|
+
variables: { status: perspective }
|
|
178
|
+
}));
|
|
179
|
+
return runtimeSetStatus;
|
|
180
|
+
}
|
|
181
|
+
async friendStatus(did) {
|
|
182
|
+
const { runtimeFriendStatus } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").query({
|
|
183
|
+
query: gql `query runtimeFriendStatus($did: String!) {
|
|
184
|
+
runtimeFriendStatus(did: $did) { ${PERSPECTIVE_EXPRESSION_FIELDS} }
|
|
185
|
+
}`,
|
|
186
|
+
variables: { did }
|
|
187
|
+
}));
|
|
188
|
+
return runtimeFriendStatus;
|
|
189
|
+
}
|
|
190
|
+
async friendSendMessage(did, message) {
|
|
191
|
+
const { runtimeFriendSendMessage } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
|
|
192
|
+
mutation: gql `mutation runtimeFriendSendMessage($did: String!, $message: PerspectiveInput!) {
|
|
193
|
+
runtimeFriendSendMessage(did: $did, message: $message)
|
|
194
|
+
}`,
|
|
195
|
+
variables: { did, message }
|
|
196
|
+
}));
|
|
197
|
+
return runtimeFriendSendMessage;
|
|
198
|
+
}
|
|
199
|
+
async messageInbox(filter) {
|
|
200
|
+
const { runtimeMessageInbox } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").query({
|
|
201
|
+
query: gql `query runtimeMessageInbox($filter: String) {
|
|
202
|
+
runtimeMessageInbox(filter: $filter) { ${PERSPECTIVE_EXPRESSION_FIELDS} }
|
|
203
|
+
}`,
|
|
204
|
+
variables: { filter }
|
|
205
|
+
}));
|
|
206
|
+
return runtimeMessageInbox;
|
|
207
|
+
}
|
|
208
|
+
async messageOutbox(filter) {
|
|
209
|
+
const { runtimeMessageOutbox } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").query({
|
|
210
|
+
query: gql `query runtimeMessageOutbox($filter: String) {
|
|
211
|
+
runtimeMessageOutbox(filter: $filter) {
|
|
212
|
+
recipient,
|
|
213
|
+
message {
|
|
214
|
+
${PERSPECTIVE_EXPRESSION_FIELDS}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}`,
|
|
218
|
+
variables: { filter }
|
|
219
|
+
}));
|
|
220
|
+
return runtimeMessageOutbox;
|
|
221
|
+
}
|
|
222
|
+
addMessageCallback(cb) {
|
|
223
|
+
__classPrivateFieldGet(this, _RuntimeClient_messageReceivedCallbacks, "f").push(cb);
|
|
224
|
+
}
|
|
225
|
+
subscribeMessageReceived() {
|
|
226
|
+
__classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").subscribe({
|
|
227
|
+
query: gql ` subscription {
|
|
228
|
+
runtimeMessageReceived { ${PERSPECTIVE_EXPRESSION_FIELDS} }
|
|
229
|
+
}
|
|
230
|
+
`
|
|
231
|
+
}).subscribe({
|
|
232
|
+
next: result => {
|
|
233
|
+
__classPrivateFieldGet(this, _RuntimeClient_messageReceivedCallbacks, "f").forEach(cb => {
|
|
234
|
+
cb(result.data.runtimeMessageReceived);
|
|
235
|
+
});
|
|
236
|
+
},
|
|
237
|
+
error: (e) => console.error(e)
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
addExceptionCallback(cb) {
|
|
241
|
+
__classPrivateFieldGet(this, _RuntimeClient_exceptionOccurredCallbacks, "f").push(cb);
|
|
242
|
+
}
|
|
243
|
+
subscribeExceptionOccurred() {
|
|
244
|
+
__classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").subscribe({
|
|
245
|
+
query: gql ` subscription {
|
|
246
|
+
exceptionOccurred {
|
|
247
|
+
title
|
|
248
|
+
message
|
|
249
|
+
type
|
|
250
|
+
addon
|
|
251
|
+
}
|
|
252
|
+
}`
|
|
253
|
+
}).subscribe({
|
|
254
|
+
next: result => {
|
|
255
|
+
__classPrivateFieldGet(this, _RuntimeClient_exceptionOccurredCallbacks, "f").forEach(cb => {
|
|
256
|
+
cb(result.data.exceptionOccurred);
|
|
257
|
+
});
|
|
258
|
+
},
|
|
259
|
+
error: (e) => console.error(e)
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
_RuntimeClient_apolloClient = new WeakMap(), _RuntimeClient_messageReceivedCallbacks = new WeakMap(), _RuntimeClient_exceptionOccurredCallbacks = new WeakMap();
|