@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,410 +1,418 @@
|
|
|
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 _PerspectiveClient_apolloClient, _PerspectiveClient_perspectiveAddedCallbacks, _PerspectiveClient_perspectiveUpdatedCallbacks, _PerspectiveClient_perspectiveRemovedCallbacks, _PerspectiveClient_perspectiveSyncStateChangeCallbacks, _PerspectiveClient_expressionClient, _PerspectiveClient_neighbourhoodClient;
|
|
13
|
-
import { gql } from "@apollo/client/core";
|
|
14
|
-
import { NeighbourhoodProxy } from "../neighbourhood/NeighbourhoodProxy";
|
|
15
|
-
import unwrapApolloResult from "../unwrapApolloResult";
|
|
16
|
-
import { PerspectiveProxy } from './PerspectiveProxy';
|
|
17
|
-
const LINK_EXPRESSION_FIELDS = `
|
|
18
|
-
author
|
|
19
|
-
timestamp
|
|
20
|
-
status
|
|
21
|
-
data { source, predicate, target }
|
|
22
|
-
proof { valid, invalid, signature, key }
|
|
23
|
-
`;
|
|
24
|
-
const PERSPECTIVE_HANDLE_FIELDS = `
|
|
25
|
-
uuid
|
|
26
|
-
name
|
|
27
|
-
sharedUrl
|
|
28
|
-
state
|
|
29
|
-
neighbourhood {
|
|
30
|
-
data {
|
|
31
|
-
linkLanguage
|
|
32
|
-
meta {
|
|
33
|
-
links
|
|
34
|
-
{
|
|
35
|
-
author
|
|
36
|
-
timestamp
|
|
37
|
-
data { source, predicate, target }
|
|
38
|
-
proof { valid, invalid, signature, key }
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
author
|
|
43
|
-
}
|
|
44
|
-
`;
|
|
45
|
-
export class PerspectiveClient {
|
|
46
|
-
constructor(client, subscribe = true) {
|
|
47
|
-
_PerspectiveClient_apolloClient.set(this, void 0);
|
|
48
|
-
_PerspectiveClient_perspectiveAddedCallbacks.set(this, void 0);
|
|
49
|
-
_PerspectiveClient_perspectiveUpdatedCallbacks.set(this, void 0);
|
|
50
|
-
_PerspectiveClient_perspectiveRemovedCallbacks.set(this, void 0);
|
|
51
|
-
_PerspectiveClient_perspectiveSyncStateChangeCallbacks.set(this, void 0);
|
|
52
|
-
_PerspectiveClient_expressionClient.set(this, void 0);
|
|
53
|
-
_PerspectiveClient_neighbourhoodClient.set(this, void 0);
|
|
54
|
-
__classPrivateFieldSet(this, _PerspectiveClient_apolloClient, client, "f");
|
|
55
|
-
__classPrivateFieldSet(this, _PerspectiveClient_perspectiveAddedCallbacks, [], "f");
|
|
56
|
-
__classPrivateFieldSet(this, _PerspectiveClient_perspectiveUpdatedCallbacks, [], "f");
|
|
57
|
-
__classPrivateFieldSet(this, _PerspectiveClient_perspectiveRemovedCallbacks, [], "f");
|
|
58
|
-
__classPrivateFieldSet(this, _PerspectiveClient_perspectiveSyncStateChangeCallbacks, [], "f");
|
|
59
|
-
if (subscribe) {
|
|
60
|
-
this.subscribePerspectiveAdded();
|
|
61
|
-
this.subscribePerspectiveUpdated();
|
|
62
|
-
this.subscribePerspectiveRemoved();
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
setExpressionClient(client) {
|
|
66
|
-
__classPrivateFieldSet(this, _PerspectiveClient_expressionClient, client, "f");
|
|
67
|
-
}
|
|
68
|
-
setNeighbourhoodClient(client) {
|
|
69
|
-
__classPrivateFieldSet(this, _PerspectiveClient_neighbourhoodClient, client, "f");
|
|
70
|
-
}
|
|
71
|
-
async all() {
|
|
72
|
-
const { perspectives } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").query({
|
|
73
|
-
query: gql `query perspectives {
|
|
74
|
-
perspectives {
|
|
75
|
-
${PERSPECTIVE_HANDLE_FIELDS}
|
|
76
|
-
}
|
|
77
|
-
}`
|
|
78
|
-
}));
|
|
79
|
-
return perspectives.map(handle => new PerspectiveProxy(handle, this));
|
|
80
|
-
}
|
|
81
|
-
async byUUID(uuid) {
|
|
82
|
-
const { perspective } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").query({
|
|
83
|
-
query: gql `query perspective($uuid: String!) {
|
|
84
|
-
perspective(uuid: $uuid) {
|
|
85
|
-
${PERSPECTIVE_HANDLE_FIELDS}
|
|
86
|
-
}
|
|
87
|
-
}`,
|
|
88
|
-
variables: { uuid }
|
|
89
|
-
}));
|
|
90
|
-
if (!perspective)
|
|
91
|
-
return null;
|
|
92
|
-
return new PerspectiveProxy(perspective, this);
|
|
93
|
-
}
|
|
94
|
-
async snapshotByUUID(uuid) {
|
|
95
|
-
const { perspectiveSnapshot } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").query({
|
|
96
|
-
query: gql `query perspectiveSnapshot($uuid: String!) {
|
|
97
|
-
perspectiveSnapshot(uuid: $uuid) {
|
|
98
|
-
links { ${LINK_EXPRESSION_FIELDS} }
|
|
99
|
-
}
|
|
100
|
-
}`,
|
|
101
|
-
variables: { uuid }
|
|
102
|
-
}));
|
|
103
|
-
return perspectiveSnapshot;
|
|
104
|
-
}
|
|
105
|
-
async publishSnapshotByUUID(uuid) {
|
|
106
|
-
const { perspectivePublishSnapshot } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
|
|
107
|
-
mutation: gql `mutation perspectivePublishSnapshot($uuid: String!) {
|
|
108
|
-
perspectivePublishSnapshot(uuid: $uuid)
|
|
109
|
-
}`,
|
|
110
|
-
variables: { uuid }
|
|
111
|
-
}));
|
|
112
|
-
return perspectivePublishSnapshot;
|
|
113
|
-
}
|
|
114
|
-
async queryLinks(uuid, query) {
|
|
115
|
-
const { perspectiveQueryLinks } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").query({
|
|
116
|
-
query: gql `query perspectiveQueryLinks($uuid: String!, $query: LinkQuery!) {
|
|
117
|
-
perspectiveQueryLinks(query: $query, uuid: $uuid) {
|
|
118
|
-
${LINK_EXPRESSION_FIELDS}
|
|
119
|
-
}
|
|
120
|
-
}`,
|
|
121
|
-
variables: { uuid, query }
|
|
122
|
-
}));
|
|
123
|
-
return perspectiveQueryLinks;
|
|
124
|
-
}
|
|
125
|
-
async queryProlog(uuid, query) {
|
|
126
|
-
const { perspectiveQueryProlog } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").query({
|
|
127
|
-
query: gql `query perspectiveQueryProlog($uuid: String!, $query: String!) {
|
|
128
|
-
perspectiveQueryProlog(uuid: $uuid, query: $query)
|
|
129
|
-
}`,
|
|
130
|
-
variables: { uuid, query }
|
|
131
|
-
}));
|
|
132
|
-
return JSON.parse(perspectiveQueryProlog);
|
|
133
|
-
}
|
|
134
|
-
async add(name) {
|
|
135
|
-
const { perspectiveAdd } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
|
|
136
|
-
mutation: gql `mutation perspectiveAdd($name: String!) {
|
|
137
|
-
perspectiveAdd(name: $name) {
|
|
138
|
-
${PERSPECTIVE_HANDLE_FIELDS}
|
|
139
|
-
}
|
|
140
|
-
}`,
|
|
141
|
-
variables: { name }
|
|
142
|
-
}));
|
|
143
|
-
return new PerspectiveProxy(perspectiveAdd, this);
|
|
144
|
-
}
|
|
145
|
-
async update(uuid, name) {
|
|
146
|
-
const { perspectiveUpdate } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
|
|
147
|
-
mutation: gql `mutation perspectiveUpdate($uuid: String!, $name: String!) {
|
|
148
|
-
perspectiveUpdate(uuid: $uuid, name: $name) {
|
|
149
|
-
${PERSPECTIVE_HANDLE_FIELDS}
|
|
150
|
-
}
|
|
151
|
-
}`,
|
|
152
|
-
variables: { uuid, name }
|
|
153
|
-
}));
|
|
154
|
-
return new PerspectiveProxy(perspectiveUpdate, this);
|
|
155
|
-
}
|
|
156
|
-
async remove(uuid) {
|
|
157
|
-
return unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
|
|
158
|
-
mutation: gql `mutation perspectiveRemove($uuid: String!) {
|
|
159
|
-
perspectiveRemove(uuid: $uuid)
|
|
160
|
-
}`,
|
|
161
|
-
variables: { uuid }
|
|
162
|
-
}));
|
|
163
|
-
}
|
|
164
|
-
async addLink(uuid, link, status) {
|
|
165
|
-
const { perspectiveAddLink } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
|
|
166
|
-
mutation: gql `mutation perspectiveAddLink($uuid: String!, $link: LinkInput!, $status: String){
|
|
167
|
-
perspectiveAddLink(link: $link, uuid: $uuid, status: $status) {
|
|
168
|
-
${LINK_EXPRESSION_FIELDS}
|
|
169
|
-
}
|
|
170
|
-
}`,
|
|
171
|
-
variables: { uuid, link, status }
|
|
172
|
-
}));
|
|
173
|
-
return perspectiveAddLink;
|
|
174
|
-
}
|
|
175
|
-
async addLinks(uuid, links, status) {
|
|
176
|
-
const { perspectiveAddLinks } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
|
|
177
|
-
mutation: gql `mutation perspectiveAddLinks($uuid: String!, $links: [LinkInput!]!, $status: String){
|
|
178
|
-
perspectiveAddLinks(links: $links, uuid: $uuid, status: $status) {
|
|
179
|
-
${LINK_EXPRESSION_FIELDS}
|
|
180
|
-
}
|
|
181
|
-
}`,
|
|
182
|
-
variables: { uuid, links, status }
|
|
183
|
-
}));
|
|
184
|
-
return perspectiveAddLinks;
|
|
185
|
-
}
|
|
186
|
-
async removeLinks(uuid, links) {
|
|
187
|
-
const { perspectiveRemoveLinks } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
|
|
188
|
-
mutation: gql `mutation perspectiveRemoveLinks($uuid: String!, $links: [LinkExpressionInput!]!){
|
|
189
|
-
perspectiveRemoveLinks(links: $links, uuid: $uuid) {
|
|
190
|
-
${LINK_EXPRESSION_FIELDS}
|
|
191
|
-
}
|
|
192
|
-
}`,
|
|
193
|
-
variables: { uuid, links }
|
|
194
|
-
}));
|
|
195
|
-
return perspectiveRemoveLinks;
|
|
196
|
-
}
|
|
197
|
-
async linkMutations(uuid, mutations, status) {
|
|
198
|
-
const { perspectiveLinkMutations } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
|
|
199
|
-
mutation: gql `mutation perspectiveLinkMutations($uuid: String!, $mutations: LinkMutations!, $status: String){
|
|
200
|
-
perspectiveLinkMutations(mutations: $mutations, uuid: $uuid, status: $status) {
|
|
201
|
-
additions {
|
|
202
|
-
${LINK_EXPRESSION_FIELDS}
|
|
203
|
-
}
|
|
204
|
-
removals {
|
|
205
|
-
${LINK_EXPRESSION_FIELDS}
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
}`,
|
|
209
|
-
variables: { uuid, mutations, status }
|
|
210
|
-
}));
|
|
211
|
-
return perspectiveLinkMutations;
|
|
212
|
-
}
|
|
213
|
-
async addLinkExpression(uuid, link, status) {
|
|
214
|
-
const { perspectiveAddLinkExpression } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
|
|
215
|
-
mutation: gql `mutation perspectiveAddLinkExpression($uuid: String!, $link: LinkExpressionInput!, $status: String){
|
|
216
|
-
perspectiveAddLinkExpression(link: $link, uuid: $uuid, status: $status) {
|
|
217
|
-
${LINK_EXPRESSION_FIELDS}
|
|
218
|
-
}
|
|
219
|
-
}`,
|
|
220
|
-
variables: { uuid, link }
|
|
221
|
-
}));
|
|
222
|
-
return perspectiveAddLinkExpression;
|
|
223
|
-
}
|
|
224
|
-
async updateLink(uuid, oldLink, newLink) {
|
|
225
|
-
delete oldLink.__typename;
|
|
226
|
-
delete oldLink.data.__typename;
|
|
227
|
-
delete oldLink.proof.__typename;
|
|
228
|
-
const { perspectiveUpdateLink } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
|
|
229
|
-
mutation: gql `mutation perspectiveUpdateLink(
|
|
230
|
-
$uuid: String!,
|
|
231
|
-
$newLink: LinkInput!
|
|
232
|
-
$oldLink: LinkExpressionInput!
|
|
233
|
-
){
|
|
234
|
-
perspectiveUpdateLink(
|
|
235
|
-
newLink: $newLink,
|
|
236
|
-
oldLink: $oldLink,
|
|
237
|
-
uuid: $uuid
|
|
238
|
-
) {
|
|
239
|
-
${LINK_EXPRESSION_FIELDS}
|
|
240
|
-
}
|
|
241
|
-
}`,
|
|
242
|
-
variables: { uuid, oldLink, newLink }
|
|
243
|
-
}));
|
|
244
|
-
if (!perspectiveUpdateLink.status) {
|
|
245
|
-
delete perspectiveUpdateLink.status;
|
|
246
|
-
}
|
|
247
|
-
return perspectiveUpdateLink;
|
|
248
|
-
}
|
|
249
|
-
async removeLink(uuid, link) {
|
|
250
|
-
delete link.__typename;
|
|
251
|
-
delete link.data.__typename;
|
|
252
|
-
delete link.proof.__typename;
|
|
253
|
-
delete link.status;
|
|
254
|
-
return unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
|
|
255
|
-
mutation: gql `mutation perspectiveRemoveLink($link: LinkExpressionInput!, $uuid: String!) {
|
|
256
|
-
perspectiveRemoveLink(link: $link, uuid: $uuid)
|
|
257
|
-
}`,
|
|
258
|
-
variables: { uuid, link }
|
|
259
|
-
}));
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
})
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
}
|
|
410
|
-
|
|
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 _PerspectiveClient_apolloClient, _PerspectiveClient_perspectiveAddedCallbacks, _PerspectiveClient_perspectiveUpdatedCallbacks, _PerspectiveClient_perspectiveRemovedCallbacks, _PerspectiveClient_perspectiveSyncStateChangeCallbacks, _PerspectiveClient_expressionClient, _PerspectiveClient_neighbourhoodClient;
|
|
13
|
+
import { gql } from "@apollo/client/core";
|
|
14
|
+
import { NeighbourhoodProxy } from "../neighbourhood/NeighbourhoodProxy";
|
|
15
|
+
import unwrapApolloResult from "../unwrapApolloResult";
|
|
16
|
+
import { PerspectiveProxy } from './PerspectiveProxy';
|
|
17
|
+
const LINK_EXPRESSION_FIELDS = `
|
|
18
|
+
author
|
|
19
|
+
timestamp
|
|
20
|
+
status
|
|
21
|
+
data { source, predicate, target }
|
|
22
|
+
proof { valid, invalid, signature, key }
|
|
23
|
+
`;
|
|
24
|
+
const PERSPECTIVE_HANDLE_FIELDS = `
|
|
25
|
+
uuid
|
|
26
|
+
name
|
|
27
|
+
sharedUrl
|
|
28
|
+
state
|
|
29
|
+
neighbourhood {
|
|
30
|
+
data {
|
|
31
|
+
linkLanguage
|
|
32
|
+
meta {
|
|
33
|
+
links
|
|
34
|
+
{
|
|
35
|
+
author
|
|
36
|
+
timestamp
|
|
37
|
+
data { source, predicate, target }
|
|
38
|
+
proof { valid, invalid, signature, key }
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
author
|
|
43
|
+
}
|
|
44
|
+
`;
|
|
45
|
+
export class PerspectiveClient {
|
|
46
|
+
constructor(client, subscribe = true) {
|
|
47
|
+
_PerspectiveClient_apolloClient.set(this, void 0);
|
|
48
|
+
_PerspectiveClient_perspectiveAddedCallbacks.set(this, void 0);
|
|
49
|
+
_PerspectiveClient_perspectiveUpdatedCallbacks.set(this, void 0);
|
|
50
|
+
_PerspectiveClient_perspectiveRemovedCallbacks.set(this, void 0);
|
|
51
|
+
_PerspectiveClient_perspectiveSyncStateChangeCallbacks.set(this, void 0);
|
|
52
|
+
_PerspectiveClient_expressionClient.set(this, void 0);
|
|
53
|
+
_PerspectiveClient_neighbourhoodClient.set(this, void 0);
|
|
54
|
+
__classPrivateFieldSet(this, _PerspectiveClient_apolloClient, client, "f");
|
|
55
|
+
__classPrivateFieldSet(this, _PerspectiveClient_perspectiveAddedCallbacks, [], "f");
|
|
56
|
+
__classPrivateFieldSet(this, _PerspectiveClient_perspectiveUpdatedCallbacks, [], "f");
|
|
57
|
+
__classPrivateFieldSet(this, _PerspectiveClient_perspectiveRemovedCallbacks, [], "f");
|
|
58
|
+
__classPrivateFieldSet(this, _PerspectiveClient_perspectiveSyncStateChangeCallbacks, [], "f");
|
|
59
|
+
if (subscribe) {
|
|
60
|
+
this.subscribePerspectiveAdded();
|
|
61
|
+
this.subscribePerspectiveUpdated();
|
|
62
|
+
this.subscribePerspectiveRemoved();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
setExpressionClient(client) {
|
|
66
|
+
__classPrivateFieldSet(this, _PerspectiveClient_expressionClient, client, "f");
|
|
67
|
+
}
|
|
68
|
+
setNeighbourhoodClient(client) {
|
|
69
|
+
__classPrivateFieldSet(this, _PerspectiveClient_neighbourhoodClient, client, "f");
|
|
70
|
+
}
|
|
71
|
+
async all() {
|
|
72
|
+
const { perspectives } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").query({
|
|
73
|
+
query: gql `query perspectives {
|
|
74
|
+
perspectives {
|
|
75
|
+
${PERSPECTIVE_HANDLE_FIELDS}
|
|
76
|
+
}
|
|
77
|
+
}`
|
|
78
|
+
}));
|
|
79
|
+
return perspectives.map(handle => new PerspectiveProxy(handle, this));
|
|
80
|
+
}
|
|
81
|
+
async byUUID(uuid) {
|
|
82
|
+
const { perspective } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").query({
|
|
83
|
+
query: gql `query perspective($uuid: String!) {
|
|
84
|
+
perspective(uuid: $uuid) {
|
|
85
|
+
${PERSPECTIVE_HANDLE_FIELDS}
|
|
86
|
+
}
|
|
87
|
+
}`,
|
|
88
|
+
variables: { uuid }
|
|
89
|
+
}));
|
|
90
|
+
if (!perspective)
|
|
91
|
+
return null;
|
|
92
|
+
return new PerspectiveProxy(perspective, this);
|
|
93
|
+
}
|
|
94
|
+
async snapshotByUUID(uuid) {
|
|
95
|
+
const { perspectiveSnapshot } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").query({
|
|
96
|
+
query: gql `query perspectiveSnapshot($uuid: String!) {
|
|
97
|
+
perspectiveSnapshot(uuid: $uuid) {
|
|
98
|
+
links { ${LINK_EXPRESSION_FIELDS} }
|
|
99
|
+
}
|
|
100
|
+
}`,
|
|
101
|
+
variables: { uuid }
|
|
102
|
+
}));
|
|
103
|
+
return perspectiveSnapshot;
|
|
104
|
+
}
|
|
105
|
+
async publishSnapshotByUUID(uuid) {
|
|
106
|
+
const { perspectivePublishSnapshot } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
|
|
107
|
+
mutation: gql `mutation perspectivePublishSnapshot($uuid: String!) {
|
|
108
|
+
perspectivePublishSnapshot(uuid: $uuid)
|
|
109
|
+
}`,
|
|
110
|
+
variables: { uuid }
|
|
111
|
+
}));
|
|
112
|
+
return perspectivePublishSnapshot;
|
|
113
|
+
}
|
|
114
|
+
async queryLinks(uuid, query) {
|
|
115
|
+
const { perspectiveQueryLinks } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").query({
|
|
116
|
+
query: gql `query perspectiveQueryLinks($uuid: String!, $query: LinkQuery!) {
|
|
117
|
+
perspectiveQueryLinks(query: $query, uuid: $uuid) {
|
|
118
|
+
${LINK_EXPRESSION_FIELDS}
|
|
119
|
+
}
|
|
120
|
+
}`,
|
|
121
|
+
variables: { uuid, query }
|
|
122
|
+
}));
|
|
123
|
+
return perspectiveQueryLinks;
|
|
124
|
+
}
|
|
125
|
+
async queryProlog(uuid, query) {
|
|
126
|
+
const { perspectiveQueryProlog } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").query({
|
|
127
|
+
query: gql `query perspectiveQueryProlog($uuid: String!, $query: String!) {
|
|
128
|
+
perspectiveQueryProlog(uuid: $uuid, query: $query)
|
|
129
|
+
}`,
|
|
130
|
+
variables: { uuid, query }
|
|
131
|
+
}));
|
|
132
|
+
return JSON.parse(perspectiveQueryProlog);
|
|
133
|
+
}
|
|
134
|
+
async add(name) {
|
|
135
|
+
const { perspectiveAdd } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
|
|
136
|
+
mutation: gql `mutation perspectiveAdd($name: String!) {
|
|
137
|
+
perspectiveAdd(name: $name) {
|
|
138
|
+
${PERSPECTIVE_HANDLE_FIELDS}
|
|
139
|
+
}
|
|
140
|
+
}`,
|
|
141
|
+
variables: { name }
|
|
142
|
+
}));
|
|
143
|
+
return new PerspectiveProxy(perspectiveAdd, this);
|
|
144
|
+
}
|
|
145
|
+
async update(uuid, name) {
|
|
146
|
+
const { perspectiveUpdate } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
|
|
147
|
+
mutation: gql `mutation perspectiveUpdate($uuid: String!, $name: String!) {
|
|
148
|
+
perspectiveUpdate(uuid: $uuid, name: $name) {
|
|
149
|
+
${PERSPECTIVE_HANDLE_FIELDS}
|
|
150
|
+
}
|
|
151
|
+
}`,
|
|
152
|
+
variables: { uuid, name }
|
|
153
|
+
}));
|
|
154
|
+
return new PerspectiveProxy(perspectiveUpdate, this);
|
|
155
|
+
}
|
|
156
|
+
async remove(uuid) {
|
|
157
|
+
return unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
|
|
158
|
+
mutation: gql `mutation perspectiveRemove($uuid: String!) {
|
|
159
|
+
perspectiveRemove(uuid: $uuid)
|
|
160
|
+
}`,
|
|
161
|
+
variables: { uuid }
|
|
162
|
+
}));
|
|
163
|
+
}
|
|
164
|
+
async addLink(uuid, link, status) {
|
|
165
|
+
const { perspectiveAddLink } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
|
|
166
|
+
mutation: gql `mutation perspectiveAddLink($uuid: String!, $link: LinkInput!, $status: String){
|
|
167
|
+
perspectiveAddLink(link: $link, uuid: $uuid, status: $status) {
|
|
168
|
+
${LINK_EXPRESSION_FIELDS}
|
|
169
|
+
}
|
|
170
|
+
}`,
|
|
171
|
+
variables: { uuid, link, status }
|
|
172
|
+
}));
|
|
173
|
+
return perspectiveAddLink;
|
|
174
|
+
}
|
|
175
|
+
async addLinks(uuid, links, status) {
|
|
176
|
+
const { perspectiveAddLinks } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
|
|
177
|
+
mutation: gql `mutation perspectiveAddLinks($uuid: String!, $links: [LinkInput!]!, $status: String){
|
|
178
|
+
perspectiveAddLinks(links: $links, uuid: $uuid, status: $status) {
|
|
179
|
+
${LINK_EXPRESSION_FIELDS}
|
|
180
|
+
}
|
|
181
|
+
}`,
|
|
182
|
+
variables: { uuid, links, status }
|
|
183
|
+
}));
|
|
184
|
+
return perspectiveAddLinks;
|
|
185
|
+
}
|
|
186
|
+
async removeLinks(uuid, links) {
|
|
187
|
+
const { perspectiveRemoveLinks } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
|
|
188
|
+
mutation: gql `mutation perspectiveRemoveLinks($uuid: String!, $links: [LinkExpressionInput!]!){
|
|
189
|
+
perspectiveRemoveLinks(links: $links, uuid: $uuid) {
|
|
190
|
+
${LINK_EXPRESSION_FIELDS}
|
|
191
|
+
}
|
|
192
|
+
}`,
|
|
193
|
+
variables: { uuid, links }
|
|
194
|
+
}));
|
|
195
|
+
return perspectiveRemoveLinks;
|
|
196
|
+
}
|
|
197
|
+
async linkMutations(uuid, mutations, status) {
|
|
198
|
+
const { perspectiveLinkMutations } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
|
|
199
|
+
mutation: gql `mutation perspectiveLinkMutations($uuid: String!, $mutations: LinkMutations!, $status: String){
|
|
200
|
+
perspectiveLinkMutations(mutations: $mutations, uuid: $uuid, status: $status) {
|
|
201
|
+
additions {
|
|
202
|
+
${LINK_EXPRESSION_FIELDS}
|
|
203
|
+
}
|
|
204
|
+
removals {
|
|
205
|
+
${LINK_EXPRESSION_FIELDS}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}`,
|
|
209
|
+
variables: { uuid, mutations, status }
|
|
210
|
+
}));
|
|
211
|
+
return perspectiveLinkMutations;
|
|
212
|
+
}
|
|
213
|
+
async addLinkExpression(uuid, link, status) {
|
|
214
|
+
const { perspectiveAddLinkExpression } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
|
|
215
|
+
mutation: gql `mutation perspectiveAddLinkExpression($uuid: String!, $link: LinkExpressionInput!, $status: String){
|
|
216
|
+
perspectiveAddLinkExpression(link: $link, uuid: $uuid, status: $status) {
|
|
217
|
+
${LINK_EXPRESSION_FIELDS}
|
|
218
|
+
}
|
|
219
|
+
}`,
|
|
220
|
+
variables: { uuid, link }
|
|
221
|
+
}));
|
|
222
|
+
return perspectiveAddLinkExpression;
|
|
223
|
+
}
|
|
224
|
+
async updateLink(uuid, oldLink, newLink) {
|
|
225
|
+
delete oldLink.__typename;
|
|
226
|
+
delete oldLink.data.__typename;
|
|
227
|
+
delete oldLink.proof.__typename;
|
|
228
|
+
const { perspectiveUpdateLink } = unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
|
|
229
|
+
mutation: gql `mutation perspectiveUpdateLink(
|
|
230
|
+
$uuid: String!,
|
|
231
|
+
$newLink: LinkInput!
|
|
232
|
+
$oldLink: LinkExpressionInput!
|
|
233
|
+
){
|
|
234
|
+
perspectiveUpdateLink(
|
|
235
|
+
newLink: $newLink,
|
|
236
|
+
oldLink: $oldLink,
|
|
237
|
+
uuid: $uuid
|
|
238
|
+
) {
|
|
239
|
+
${LINK_EXPRESSION_FIELDS}
|
|
240
|
+
}
|
|
241
|
+
}`,
|
|
242
|
+
variables: { uuid, oldLink, newLink }
|
|
243
|
+
}));
|
|
244
|
+
if (!perspectiveUpdateLink.status) {
|
|
245
|
+
delete perspectiveUpdateLink.status;
|
|
246
|
+
}
|
|
247
|
+
return perspectiveUpdateLink;
|
|
248
|
+
}
|
|
249
|
+
async removeLink(uuid, link) {
|
|
250
|
+
delete link.__typename;
|
|
251
|
+
delete link.data.__typename;
|
|
252
|
+
delete link.proof.__typename;
|
|
253
|
+
delete link.status;
|
|
254
|
+
return unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
|
|
255
|
+
mutation: gql `mutation perspectiveRemoveLink($link: LinkExpressionInput!, $uuid: String!) {
|
|
256
|
+
perspectiveRemoveLink(link: $link, uuid: $uuid)
|
|
257
|
+
}`,
|
|
258
|
+
variables: { uuid, link }
|
|
259
|
+
}));
|
|
260
|
+
}
|
|
261
|
+
async addSdna(uuid, name, sdnaCode, sdnaType) {
|
|
262
|
+
return unwrapApolloResult(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({
|
|
263
|
+
mutation: gql `mutation perspectiveAddSdna($uuid: String!, $name: String!, $sdnaCode: String!, $sdnaType: String!) {
|
|
264
|
+
perspectiveAddSdna(uuid: $uuid, name: $name, sdnaCode: $sdnaCode, sdnaType: $sdnaType)
|
|
265
|
+
}`,
|
|
266
|
+
variables: { uuid, name, sdnaCode, sdnaType }
|
|
267
|
+
})).perspectiveAddSdna;
|
|
268
|
+
}
|
|
269
|
+
// ExpressionClient functions, needed for Subjects:
|
|
270
|
+
async getExpression(expressionURI) {
|
|
271
|
+
return await __classPrivateFieldGet(this, _PerspectiveClient_expressionClient, "f").get(expressionURI);
|
|
272
|
+
}
|
|
273
|
+
async createExpression(content, languageAddress) {
|
|
274
|
+
return await __classPrivateFieldGet(this, _PerspectiveClient_expressionClient, "f").create(content, languageAddress);
|
|
275
|
+
}
|
|
276
|
+
// Subscriptions:
|
|
277
|
+
addPerspectiveAddedListener(cb) {
|
|
278
|
+
__classPrivateFieldGet(this, _PerspectiveClient_perspectiveAddedCallbacks, "f").push(cb);
|
|
279
|
+
}
|
|
280
|
+
subscribePerspectiveAdded() {
|
|
281
|
+
__classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").subscribe({
|
|
282
|
+
query: gql ` subscription {
|
|
283
|
+
perspectiveAdded { ${PERSPECTIVE_HANDLE_FIELDS} }
|
|
284
|
+
}
|
|
285
|
+
`
|
|
286
|
+
}).subscribe({
|
|
287
|
+
next: result => {
|
|
288
|
+
__classPrivateFieldGet(this, _PerspectiveClient_perspectiveAddedCallbacks, "f").forEach(cb => {
|
|
289
|
+
cb(result.data.perspectiveAdded);
|
|
290
|
+
});
|
|
291
|
+
},
|
|
292
|
+
error: (e) => console.error(e)
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
addPerspectiveUpdatedListener(cb) {
|
|
296
|
+
__classPrivateFieldGet(this, _PerspectiveClient_perspectiveUpdatedCallbacks, "f").push(cb);
|
|
297
|
+
}
|
|
298
|
+
subscribePerspectiveUpdated() {
|
|
299
|
+
__classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").subscribe({
|
|
300
|
+
query: gql ` subscription {
|
|
301
|
+
perspectiveUpdated { ${PERSPECTIVE_HANDLE_FIELDS} }
|
|
302
|
+
}
|
|
303
|
+
`
|
|
304
|
+
}).subscribe({
|
|
305
|
+
next: result => {
|
|
306
|
+
__classPrivateFieldGet(this, _PerspectiveClient_perspectiveUpdatedCallbacks, "f").forEach(cb => {
|
|
307
|
+
cb(result.data.perspectiveUpdated);
|
|
308
|
+
});
|
|
309
|
+
},
|
|
310
|
+
error: (e) => console.error(e)
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
addPerspectiveSyncedListener(cb) {
|
|
314
|
+
__classPrivateFieldGet(this, _PerspectiveClient_perspectiveSyncStateChangeCallbacks, "f").push(cb);
|
|
315
|
+
}
|
|
316
|
+
async addPerspectiveSyncStateChangeListener(uuid, cb) {
|
|
317
|
+
__classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").subscribe({
|
|
318
|
+
query: gql ` subscription {
|
|
319
|
+
perspectiveSyncStateChange(uuid: "${uuid}")
|
|
320
|
+
}
|
|
321
|
+
`
|
|
322
|
+
}).subscribe({
|
|
323
|
+
next: result => {
|
|
324
|
+
cb.forEach(c => {
|
|
325
|
+
c(result.data.perspectiveSyncStateChange);
|
|
326
|
+
});
|
|
327
|
+
},
|
|
328
|
+
error: (e) => console.error(e)
|
|
329
|
+
});
|
|
330
|
+
await new Promise(resolve => setTimeout(resolve, 500));
|
|
331
|
+
}
|
|
332
|
+
addPerspectiveRemovedListener(cb) {
|
|
333
|
+
__classPrivateFieldGet(this, _PerspectiveClient_perspectiveRemovedCallbacks, "f").push(cb);
|
|
334
|
+
}
|
|
335
|
+
subscribePerspectiveRemoved() {
|
|
336
|
+
__classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").subscribe({
|
|
337
|
+
query: gql ` subscription {
|
|
338
|
+
perspectiveRemoved
|
|
339
|
+
}
|
|
340
|
+
`
|
|
341
|
+
}).subscribe({
|
|
342
|
+
next: result => {
|
|
343
|
+
__classPrivateFieldGet(this, _PerspectiveClient_perspectiveRemovedCallbacks, "f").forEach(cb => {
|
|
344
|
+
cb(result.data.perspectiveRemoved);
|
|
345
|
+
});
|
|
346
|
+
},
|
|
347
|
+
error: (e) => console.error(e)
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
async addPerspectiveLinkAddedListener(uuid, cb) {
|
|
351
|
+
__classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").subscribe({
|
|
352
|
+
query: gql ` subscription {
|
|
353
|
+
perspectiveLinkAdded(uuid: "${uuid}") { ${LINK_EXPRESSION_FIELDS} }
|
|
354
|
+
}
|
|
355
|
+
`
|
|
356
|
+
}).subscribe({
|
|
357
|
+
next: result => {
|
|
358
|
+
cb.forEach(c => {
|
|
359
|
+
c(result.data.perspectiveLinkAdded);
|
|
360
|
+
});
|
|
361
|
+
},
|
|
362
|
+
error: (e) => console.error(e)
|
|
363
|
+
});
|
|
364
|
+
await new Promise(resolve => setTimeout(resolve, 500));
|
|
365
|
+
}
|
|
366
|
+
async addPerspectiveLinkRemovedListener(uuid, cb) {
|
|
367
|
+
__classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").subscribe({
|
|
368
|
+
query: gql ` subscription {
|
|
369
|
+
perspectiveLinkRemoved(uuid: "${uuid}") { ${LINK_EXPRESSION_FIELDS} }
|
|
370
|
+
}
|
|
371
|
+
`
|
|
372
|
+
}).subscribe({
|
|
373
|
+
next: result => {
|
|
374
|
+
cb.forEach(c => {
|
|
375
|
+
if (!result.data.perspectiveLinkRemoved.status) {
|
|
376
|
+
delete result.data.perspectiveLinkRemoved.status;
|
|
377
|
+
}
|
|
378
|
+
c(result.data.perspectiveLinkRemoved);
|
|
379
|
+
});
|
|
380
|
+
},
|
|
381
|
+
error: (e) => console.error(e)
|
|
382
|
+
});
|
|
383
|
+
await new Promise(resolve => setTimeout(resolve, 500));
|
|
384
|
+
}
|
|
385
|
+
async addPerspectiveLinkUpdatedListener(uuid, cb) {
|
|
386
|
+
__classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").subscribe({
|
|
387
|
+
query: gql ` subscription {
|
|
388
|
+
perspectiveLinkUpdated(uuid: "${uuid}") {
|
|
389
|
+
oldLink {
|
|
390
|
+
${LINK_EXPRESSION_FIELDS}
|
|
391
|
+
}
|
|
392
|
+
newLink {
|
|
393
|
+
${LINK_EXPRESSION_FIELDS}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
`
|
|
398
|
+
}).subscribe({
|
|
399
|
+
next: result => {
|
|
400
|
+
cb.forEach(c => {
|
|
401
|
+
if (!result.data.perspectiveLinkUpdated.newLink.status) {
|
|
402
|
+
delete result.data.perspectiveLinkUpdated.newLink.status;
|
|
403
|
+
}
|
|
404
|
+
if (!result.data.perspectiveLinkUpdated.oldLink.status) {
|
|
405
|
+
delete result.data.perspectiveLinkUpdated.oldLink.status;
|
|
406
|
+
}
|
|
407
|
+
c(result.data.perspectiveLinkUpdated);
|
|
408
|
+
});
|
|
409
|
+
},
|
|
410
|
+
error: (e) => console.error(e)
|
|
411
|
+
});
|
|
412
|
+
await new Promise(resolve => setTimeout(resolve, 500));
|
|
413
|
+
}
|
|
414
|
+
getNeighbourhoodProxy(uuid) {
|
|
415
|
+
return new NeighbourhoodProxy(__classPrivateFieldGet(this, _PerspectiveClient_neighbourhoodClient, "f"), uuid);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
_PerspectiveClient_apolloClient = new WeakMap(), _PerspectiveClient_perspectiveAddedCallbacks = new WeakMap(), _PerspectiveClient_perspectiveUpdatedCallbacks = new WeakMap(), _PerspectiveClient_perspectiveRemovedCallbacks = new WeakMap(), _PerspectiveClient_perspectiveSyncStateChangeCallbacks = new WeakMap(), _PerspectiveClient_expressionClient = new WeakMap(), _PerspectiveClient_neighbourhoodClient = new WeakMap();
|