@coasys/ad4m 0.12.0-rc1-dev.2 → 0.12.0-rc1-dev.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/jest.config.js +10 -3
- package/lib/index.cjs +6893 -5884
- package/lib/index.js +6889 -5872
- package/lib/src/Ad4mClient.d.ts +9 -16
- package/lib/src/Ad4mClient.js +46 -25
- package/lib/src/Literal.d.ts +1 -2
- package/lib/src/Literal.js +38 -35
- package/lib/src/SmartLiteral.d.ts +1 -2
- package/lib/src/SmartLiteral.js +30 -15
- package/lib/src/agent/AgentClient.d.ts +1 -4
- package/lib/src/agent/AgentClient.js +79 -99
- package/lib/src/ai/AIClient.d.ts +1 -2
- package/lib/src/ai/AIClient.js +224 -220
- package/lib/src/expression/ExpressionClient.d.ts +1 -1
- package/lib/src/expression/ExpressionClient.js +73 -86
- package/lib/src/index.d.ts +1 -1
- package/lib/src/index.js +1 -1
- package/lib/src/language/LanguageClient.d.ts +1 -1
- package/lib/src/language/LanguageClient.js +52 -52
- package/lib/src/model/Ad4mModel.d.ts +1351 -144
- package/lib/src/model/Ad4mModel.js +3760 -228
- package/lib/src/model/Ad4mModel.test.js +522 -979
- package/lib/src/model/Subject.d.ts +3 -3
- package/lib/src/model/Subject.js +25 -25
- package/lib/src/model/decorators.d.ts +444 -100
- package/lib/src/model/decorators.js +686 -321
- package/lib/src/model/util.d.ts +6 -6
- package/lib/src/model/util.js +24 -24
- package/lib/src/neighbourhood/NeighbourhoodClient.d.ts +1 -5
- package/lib/src/neighbourhood/NeighbourhoodClient.js +179 -242
- package/lib/src/neighbourhood/NeighbourhoodProxy.d.ts +1 -2
- package/lib/src/neighbourhood/NeighbourhoodProxy.js +28 -13
- package/lib/src/neighbourhood/NeighbourhoodProxy.test.js +5 -1
- package/lib/src/perspectives/PerspectiveClient.d.ts +9 -9
- package/lib/src/perspectives/PerspectiveClient.js +240 -316
- package/lib/src/perspectives/PerspectiveProxy.d.ts +99 -61
- package/lib/src/perspectives/PerspectiveProxy.js +485 -832
- package/lib/src/runtime/RuntimeClient.d.ts +1 -5
- package/lib/src/runtime/RuntimeClient.js +238 -412
- package/lib/src/shacl/SHACLFlow.test.js +105 -164
- package/lib/src/shacl/SHACLShape.d.ts +12 -17
- package/lib/src/shacl/SHACLShape.js +115 -128
- package/lib/src/shacl/SHACLShape.test.js +176 -244
- package/lib/src/shims/reflect-metadata.d.ts +0 -0
- package/lib/src/shims/type-graphql.d.ts +32 -0
- package/lib/src/src/Ad4mClient.d.ts +28 -0
- package/lib/src/src/Address.d.ts +1 -0
- package/lib/src/src/DID.d.ts +1 -0
- package/lib/src/src/Exception.d.ts +7 -0
- package/lib/src/src/Literal.d.ts +7 -0
- package/lib/src/src/PubSub.d.ts +17 -0
- package/lib/src/src/SmartLiteral.d.ts +12 -0
- package/lib/src/src/agent/Agent.d.ts +110 -0
- package/lib/src/src/agent/AgentClient.d.ts +62 -0
- package/lib/src/src/agent/AgentResolver.d.ts +30 -0
- package/lib/src/src/agent/AgentStatus.d.ts +8 -0
- package/lib/src/src/ai/AIClient.d.ts +32 -0
- package/lib/src/src/ai/AIResolver.d.ts +75 -0
- package/lib/src/src/ai/Tasks.d.ts +37 -0
- package/lib/src/src/buildSchema.d.ts +1 -0
- package/lib/src/src/expression/Expression.d.ts +28 -0
- package/lib/src/src/expression/ExpressionClient.d.ts +13 -0
- package/lib/src/src/expression/ExpressionRef.d.ts +9 -0
- package/lib/src/src/expression/ExpressionResolver.d.ts +10 -0
- package/lib/src/src/index.d.ts +35 -0
- package/lib/src/src/jestSetup.d.ts +1 -0
- package/lib/src/src/language/Icon.d.ts +4 -0
- package/lib/src/src/language/Language.d.ts +206 -0
- package/lib/src/src/language/LanguageClient.d.ts +17 -0
- package/lib/src/src/language/LanguageContext.d.ts +37 -0
- package/lib/src/src/language/LanguageHandle.d.ts +9 -0
- package/lib/src/src/language/LanguageMeta.d.ts +35 -0
- package/lib/src/src/language/LanguageRef.d.ts +6 -0
- package/lib/src/src/language/LanguageResolver.d.ts +19 -0
- package/lib/src/src/links/Links.d.ts +39 -0
- package/lib/src/src/links/Links.test.d.ts +1 -0
- package/lib/src/src/model/Ad4mModel.d.ts +1438 -0
- package/lib/src/src/model/Ad4mModel.test.d.ts +1 -0
- package/lib/src/src/model/Subject.d.ts +25 -0
- package/lib/src/src/model/decorators.d.ts +545 -0
- package/lib/src/src/model/util.d.ts +12 -0
- package/lib/src/src/neighbourhood/Neighbourhood.d.ts +10 -0
- package/lib/src/src/neighbourhood/NeighbourhoodClient.d.ts +25 -0
- package/lib/src/src/neighbourhood/NeighbourhoodProxy.d.ts +19 -0
- package/lib/src/src/neighbourhood/NeighbourhoodProxy.test.d.ts +1 -0
- package/lib/src/src/neighbourhood/NeighbourhoodResolver.d.ts +24 -0
- package/lib/src/src/perspectives/LinkQuery.d.ts +11 -0
- package/lib/src/src/perspectives/Perspective.d.ts +38 -0
- package/lib/src/src/perspectives/Perspective.test.d.ts +1 -0
- package/lib/src/src/perspectives/PerspectiveClient.d.ts +97 -0
- package/lib/src/src/perspectives/PerspectiveDiff.d.ts +9 -0
- package/lib/src/src/perspectives/PerspectiveHandle.d.ts +18 -0
- package/lib/src/src/perspectives/PerspectiveProxy.d.ts +865 -0
- package/lib/src/src/perspectives/PerspectiveResolver.d.ts +57 -0
- package/lib/src/src/runtime/RuntimeClient.d.ts +56 -0
- package/lib/src/src/runtime/RuntimeResolver.d.ts +132 -0
- package/lib/src/src/shacl/SHACLFlow.d.ts +171 -0
- package/lib/src/src/shacl/SHACLFlow.test.d.ts +1 -0
- package/lib/src/src/shacl/SHACLShape.d.ts +117 -0
- package/lib/src/src/shacl/SHACLShape.test.d.ts +1 -0
- package/lib/src/src/typeDefs.d.ts +1 -0
- package/lib/src/src/unwrapApolloResult.d.ts +2 -0
- package/lib/src/src/utils.d.ts +25 -0
- package/lib/src/utils.d.ts +0 -8
- package/lib/src/utils.js +7 -21
- package/package.json +15 -14
- package/src/Ad4mClient.test.ts +1315 -1564
- package/src/Ad4mClient.ts +54 -55
- package/src/Literal.test.ts +26 -45
- package/src/Literal.ts +66 -82
- package/src/SmartLiteral.ts +58 -74
- package/src/agent/AgentClient.ts +99 -144
- package/src/ai/AIClient.ts +359 -409
- package/src/expression/ExpressionClient.ts +96 -142
- package/src/index.ts +1 -1
- package/src/language/LanguageClient.ts +113 -137
- package/src/model/Ad4mModel.test.ts +616 -1114
- package/src/model/Ad4mModel.ts +4386 -451
- package/src/model/Subject.ts +159 -0
- package/src/model/decorators.ts +1168 -667
- package/src/model/util.ts +54 -53
- package/src/neighbourhood/NeighbourhoodClient.ts +266 -392
- package/src/neighbourhood/NeighbourhoodProxy.test.ts +7 -3
- package/src/neighbourhood/NeighbourhoodProxy.ts +40 -58
- package/src/perspectives/PerspectiveClient.ts +540 -779
- package/src/perspectives/PerspectiveProxy.ts +2067 -2860
- package/src/runtime/RuntimeClient.ts +476 -775
- package/src/shacl/SHACLFlow.test.ts +129 -196
- package/src/shacl/SHACLShape.test.ts +190 -284
- package/src/shacl/SHACLShape.ts +200 -224
- package/src/utils.ts +17 -31
- package/tsconfig.json +10 -9
- package/src/model/IMPROVEMENTS.md +0 -482
- package/src/model/PREDICATE_COLLISION_FIX.md +0 -651
- package/src/model/README.md +0 -317
- package/src/model/SHACL_MUTATION_DECOUPLING.md +0 -356
- package/src/model/SUBSCRIPTION_STRATEGY.md +0 -317
- package/src/model/TC39_STAGE_3_DECORATORS.md +0 -609
- package/src/model/mutation.ts +0 -461
- package/src/model/parentUtils.ts +0 -91
- package/src/model/prolog/generatePrologFacts.ts +0 -176
- package/src/model/prolog/index.ts +0 -1
- package/src/model/query/ModelQueryBuilder.ts +0 -173
- package/src/model/query/fetchInstance.ts +0 -181
- package/src/model/query/hydration.ts +0 -273
- package/src/model/query/operations.ts +0 -510
- package/src/model/query/snapshot.ts +0 -126
- package/src/model/query/surrealCompiler.ts +0 -376
- package/src/model/schema/fromJSONSchema.ts +0 -411
- package/src/model/schema/metadata.ts +0 -148
- package/src/model/subscription.ts +0 -307
- package/src/model/transaction.ts +0 -60
- package/src/model/types.ts +0 -207
|
@@ -1,24 +1,16 @@
|
|
|
1
1
|
import { ApolloClient, gql } from "@apollo/client/core";
|
|
2
2
|
import { ExpressionRendered } from "../expression/Expression";
|
|
3
3
|
import { ExpressionClient } from "../expression/ExpressionClient";
|
|
4
|
-
import {
|
|
5
|
-
Link,
|
|
6
|
-
LinkExpressionInput,
|
|
7
|
-
LinkExpression,
|
|
8
|
-
LinkInput,
|
|
9
|
-
LinkMutations,
|
|
10
|
-
LinkExpressionMutations,
|
|
11
|
-
} from "../links/Links";
|
|
4
|
+
import { Link, LinkExpressionInput, LinkExpression, LinkInput, LinkMutations, LinkExpressionMutations } from "../links/Links";
|
|
12
5
|
import { NeighbourhoodClient } from "../neighbourhood/NeighbourhoodClient";
|
|
13
6
|
import { NeighbourhoodProxy } from "../neighbourhood/NeighbourhoodProxy";
|
|
14
7
|
import unwrapApolloResult from "../unwrapApolloResult";
|
|
15
8
|
import { LinkQuery } from "./LinkQuery";
|
|
16
9
|
import { Perspective } from "./Perspective";
|
|
17
10
|
import { PerspectiveHandle, PerspectiveState } from "./PerspectiveHandle";
|
|
18
|
-
import { LinkStatus, PerspectiveProxy } from
|
|
11
|
+
import { LinkStatus, PerspectiveProxy } from './PerspectiveProxy';
|
|
19
12
|
import { AIClient } from "../ai/AIClient";
|
|
20
13
|
import { AllInstancesResult } from "../model/Ad4mModel";
|
|
21
|
-
import { isSocketCloseError } from "../utils";
|
|
22
14
|
|
|
23
15
|
const LINK_EXPRESSION_FIELDS = `
|
|
24
16
|
author
|
|
@@ -26,7 +18,7 @@ timestamp
|
|
|
26
18
|
status
|
|
27
19
|
data { source, predicate, target }
|
|
28
20
|
proof { valid, invalid, signature, key }
|
|
29
|
-
|
|
21
|
+
`
|
|
30
22
|
|
|
31
23
|
const PERSPECTIVE_HANDLE_FIELDS = `
|
|
32
24
|
uuid
|
|
@@ -49,393 +41,343 @@ neighbourhood {
|
|
|
49
41
|
}
|
|
50
42
|
author
|
|
51
43
|
}
|
|
52
|
-
|
|
44
|
+
`
|
|
53
45
|
|
|
54
|
-
export type PerspectiveHandleCallback = (
|
|
55
|
-
|
|
56
|
-
) => null
|
|
57
|
-
export type
|
|
58
|
-
export type LinkCallback = (link: LinkExpression) => null;
|
|
59
|
-
export type SyncStateChangeCallback = (state: PerspectiveState) => null;
|
|
46
|
+
export type PerspectiveHandleCallback = (perspective: PerspectiveHandle) => null
|
|
47
|
+
export type UuidCallback = (uuid: string) => null
|
|
48
|
+
export type LinkCallback = (link: LinkExpression) => null
|
|
49
|
+
export type SyncStateChangeCallback = (state: PerspectiveState) => null
|
|
60
50
|
|
|
61
51
|
export class PerspectiveClient {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
query: gql`query perspectives {
|
|
52
|
+
#apolloClient: ApolloClient<any>
|
|
53
|
+
#perspectiveAddedCallbacks: PerspectiveHandleCallback[]
|
|
54
|
+
#perspectiveUpdatedCallbacks: PerspectiveHandleCallback[]
|
|
55
|
+
#perspectiveRemovedCallbacks: UuidCallback[]
|
|
56
|
+
#perspectiveSyncStateChangeCallbacks: SyncStateChangeCallback[]
|
|
57
|
+
#expressionClient?: ExpressionClient
|
|
58
|
+
#neighbourhoodClient?: NeighbourhoodClient
|
|
59
|
+
#aiClient?: AIClient
|
|
60
|
+
|
|
61
|
+
constructor(client: ApolloClient<any>, subscribe: boolean = true) {
|
|
62
|
+
this.#apolloClient = client
|
|
63
|
+
this.#perspectiveAddedCallbacks = []
|
|
64
|
+
this.#perspectiveUpdatedCallbacks = []
|
|
65
|
+
this.#perspectiveRemovedCallbacks = []
|
|
66
|
+
this.#perspectiveSyncStateChangeCallbacks = []
|
|
67
|
+
|
|
68
|
+
if(subscribe) {
|
|
69
|
+
this.subscribePerspectiveAdded()
|
|
70
|
+
this.subscribePerspectiveUpdated()
|
|
71
|
+
this.subscribePerspectiveRemoved()
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
setExpressionClient(client: ExpressionClient) {
|
|
76
|
+
this.#expressionClient = client
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
setNeighbourhoodClient(client: NeighbourhoodClient) {
|
|
80
|
+
this.#neighbourhoodClient = client
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
setAIClient(client: AIClient) {
|
|
84
|
+
this.#aiClient = client
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
get aiClient(): AIClient {
|
|
88
|
+
return this.#aiClient
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
async all(): Promise<PerspectiveProxy[]> {
|
|
92
|
+
const { perspectives } = unwrapApolloResult(await this.#apolloClient.query({
|
|
93
|
+
query: gql`query perspectives {
|
|
105
94
|
perspectives {
|
|
106
95
|
${PERSPECTIVE_HANDLE_FIELDS}
|
|
107
96
|
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
await this._apolloClient.query({
|
|
117
|
-
query: gql`query perspective($uuid: String!) {
|
|
97
|
+
}`
|
|
98
|
+
}))
|
|
99
|
+
return perspectives.map(handle => new PerspectiveProxy(handle, this))
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
async byUUID(uuid: string): Promise<PerspectiveProxy|null> {
|
|
103
|
+
const { perspective } = unwrapApolloResult(await this.#apolloClient.query({
|
|
104
|
+
query: gql`query perspective($uuid: String!) {
|
|
118
105
|
perspective(uuid: $uuid) {
|
|
119
106
|
${PERSPECTIVE_HANDLE_FIELDS}
|
|
120
107
|
}
|
|
121
108
|
}`,
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
await this._apolloClient.query({
|
|
132
|
-
query: gql`query perspectiveSnapshot($uuid: String!) {
|
|
109
|
+
variables: { uuid }
|
|
110
|
+
}))
|
|
111
|
+
if(!perspective) return null
|
|
112
|
+
return new PerspectiveProxy(perspective, this)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
async snapshotByUUID(uuid: string): Promise<Perspective|null> {
|
|
116
|
+
const { perspectiveSnapshot } = unwrapApolloResult(await this.#apolloClient.query({
|
|
117
|
+
query: gql`query perspectiveSnapshot($uuid: String!) {
|
|
133
118
|
perspectiveSnapshot(uuid: $uuid) {
|
|
134
119
|
links { ${LINK_EXPRESSION_FIELDS} }
|
|
135
120
|
}
|
|
136
121
|
}`,
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
async queryLinks(uuid: string, query: LinkQuery): Promise<LinkExpression[]> {
|
|
157
|
-
const { perspectiveQueryLinks } = unwrapApolloResult(
|
|
158
|
-
await this._apolloClient.query({
|
|
159
|
-
query: gql`query perspectiveQueryLinks($uuid: String!, $query: LinkQuery!) {
|
|
122
|
+
variables: { uuid }
|
|
123
|
+
}))
|
|
124
|
+
return perspectiveSnapshot
|
|
125
|
+
}
|
|
126
|
+
async publishSnapshotByUUID(uuid: string): Promise<string|null> {
|
|
127
|
+
const { perspectivePublishSnapshot } = unwrapApolloResult(await this.#apolloClient.mutate({
|
|
128
|
+
mutation: gql`mutation perspectivePublishSnapshot($uuid: String!) {
|
|
129
|
+
perspectivePublishSnapshot(uuid: $uuid)
|
|
130
|
+
}`,
|
|
131
|
+
variables: { uuid }
|
|
132
|
+
}))
|
|
133
|
+
return perspectivePublishSnapshot
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
async queryLinks(uuid: string, query: LinkQuery): Promise<LinkExpression[]> {
|
|
137
|
+
const { perspectiveQueryLinks } = unwrapApolloResult(await this.#apolloClient.query({
|
|
138
|
+
query: gql`query perspectiveQueryLinks($uuid: String!, $query: LinkQuery!) {
|
|
160
139
|
perspectiveQueryLinks(query: $query, uuid: $uuid) {
|
|
161
140
|
${LINK_EXPRESSION_FIELDS}
|
|
162
141
|
}
|
|
163
142
|
}`,
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
143
|
+
variables: { uuid, query }
|
|
144
|
+
}))
|
|
145
|
+
return perspectiveQueryLinks
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
async queryProlog(uuid: string, query: string): Promise<any> {
|
|
149
|
+
const { perspectiveQueryProlog } = unwrapApolloResult(await this.#apolloClient.query({
|
|
150
|
+
query: gql`query perspectiveQueryProlog($uuid: String!, $query: String!) {
|
|
151
|
+
perspectiveQueryProlog(uuid: $uuid, query: $query)
|
|
152
|
+
}`,
|
|
153
|
+
variables: { uuid, query }
|
|
154
|
+
}))
|
|
155
|
+
|
|
156
|
+
return JSON.parse(perspectiveQueryProlog)
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Executes a read-only SurrealQL query against a perspective's link cache.
|
|
161
|
+
*
|
|
162
|
+
* Security: Only SELECT, RETURN, and other read-only queries are permitted.
|
|
163
|
+
* Mutating operations (DELETE, UPDATE, INSERT, etc.) are blocked.
|
|
164
|
+
*
|
|
165
|
+
* Note: GraphQL field name is "perspectiveQuerySurrealDb" (lowercase "b" in "Db")
|
|
166
|
+
* as generated from Rust method "perspective_query_surreal_db"
|
|
167
|
+
*/
|
|
168
|
+
async querySurrealDB(uuid: string, query: string): Promise<any> {
|
|
169
|
+
const { perspectiveQuerySurrealDb } = unwrapApolloResult(await this.#apolloClient.query({
|
|
170
|
+
query: gql`query perspectiveQuerySurrealDb($uuid: String!, $query: String!) {
|
|
171
|
+
perspectiveQuerySurrealDb(uuid: $uuid, query: $query)
|
|
172
|
+
}`,
|
|
173
|
+
variables: { uuid, query }
|
|
174
|
+
}))
|
|
175
|
+
|
|
176
|
+
return JSON.parse(perspectiveQuerySurrealDb)
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
async subscribeQuery(uuid: string, query: string): Promise<{ subscriptionId: string, result: AllInstancesResult, isInit?: boolean }> {
|
|
180
|
+
const { perspectiveSubscribeQuery } = unwrapApolloResult(await this.#apolloClient.mutate({
|
|
181
|
+
mutation: gql`mutation perspectiveSubscribeQuery($uuid: String!, $query: String!) {
|
|
182
|
+
perspectiveSubscribeQuery(uuid: $uuid, query: $query) {
|
|
183
|
+
subscriptionId
|
|
184
|
+
result
|
|
185
|
+
}
|
|
186
|
+
}`,
|
|
187
|
+
variables: { uuid, query }
|
|
188
|
+
}))
|
|
189
|
+
const { subscriptionId, result } = perspectiveSubscribeQuery
|
|
190
|
+
let finalResult = result;
|
|
191
|
+
let isInit = false;
|
|
192
|
+
if(finalResult.startsWith("#init#")) {
|
|
193
|
+
finalResult = finalResult.substring(6)
|
|
194
|
+
isInit = true;
|
|
195
|
+
}
|
|
196
|
+
try {
|
|
197
|
+
finalResult = JSON.parse(finalResult)
|
|
198
|
+
} catch (e) {
|
|
199
|
+
console.error('Error parsing perspectiveSubscribeQuery result:', e)
|
|
200
|
+
}
|
|
201
|
+
return { subscriptionId, result: finalResult, isInit }
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
async perspectiveSubscribeSurrealQuery(uuid: string, query: string): Promise<{ subscriptionId: string, result: AllInstancesResult, isInit?: boolean }> {
|
|
205
|
+
const { perspectiveSubscribeSurrealQuery } = unwrapApolloResult(await this.#apolloClient.mutate({
|
|
206
|
+
mutation: gql`mutation perspectiveSubscribeSurrealQuery($uuid: String!, $query: String!) {
|
|
207
|
+
perspectiveSubscribeSurrealQuery(uuid: $uuid, query: $query) {
|
|
208
|
+
subscriptionId
|
|
209
|
+
result
|
|
210
|
+
}
|
|
211
|
+
}`,
|
|
212
|
+
variables: { uuid, query }
|
|
213
|
+
}))
|
|
214
|
+
const { subscriptionId, result } = perspectiveSubscribeSurrealQuery
|
|
215
|
+
let finalResult = result;
|
|
216
|
+
let isInit = false;
|
|
217
|
+
if(finalResult.startsWith("#init#")) {
|
|
218
|
+
finalResult = finalResult.substring(6)
|
|
219
|
+
isInit = true;
|
|
220
|
+
}
|
|
221
|
+
try {
|
|
222
|
+
finalResult = JSON.parse(finalResult)
|
|
223
|
+
} catch (e) {
|
|
224
|
+
console.error('Error parsing perspectiveSubscribeSurrealQuery result:', e)
|
|
225
|
+
}
|
|
226
|
+
return { subscriptionId, result: finalResult, isInit }
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
async perspectiveKeepAliveSurrealQuery(uuid: string, subscriptionId: string): Promise<boolean> {
|
|
230
|
+
const { perspectiveKeepAliveSurrealQuery } = unwrapApolloResult(await this.#apolloClient.mutate({
|
|
231
|
+
mutation: gql`mutation perspectiveKeepAliveSurrealQuery($uuid: String!, $subscriptionId: String!) {
|
|
232
|
+
perspectiveKeepAliveSurrealQuery(uuid: $uuid, subscriptionId: $subscriptionId)
|
|
233
|
+
}`,
|
|
234
|
+
variables: { uuid, subscriptionId }
|
|
235
|
+
}))
|
|
236
|
+
|
|
237
|
+
return perspectiveKeepAliveSurrealQuery
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
async perspectiveDisposeSurrealQuerySubscription(uuid: string, subscriptionId: string): Promise<boolean> {
|
|
241
|
+
const { perspectiveDisposeSurrealQuerySubscription } = unwrapApolloResult(await this.#apolloClient.mutate({
|
|
242
|
+
mutation: gql`mutation perspectiveDisposeSurrealQuerySubscription($uuid: String!, $subscriptionId: String!) {
|
|
243
|
+
perspectiveDisposeSurrealQuerySubscription(uuid: $uuid, subscriptionId: $subscriptionId)
|
|
244
|
+
}`,
|
|
245
|
+
variables: { uuid, subscriptionId }
|
|
246
|
+
}))
|
|
247
|
+
|
|
248
|
+
return perspectiveDisposeSurrealQuerySubscription
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
subscribeToQueryUpdates(subscriptionId: string, onData: (result: AllInstancesResult) => void): () => void {
|
|
252
|
+
const subscription = this.#apolloClient.subscribe({
|
|
253
|
+
query: gql`
|
|
254
|
+
subscription perspectiveQuerySubscription($subscriptionId: String!) {
|
|
255
|
+
perspectiveQuerySubscription(subscriptionId: $subscriptionId)
|
|
256
|
+
}
|
|
257
|
+
`,
|
|
258
|
+
variables: {
|
|
259
|
+
subscriptionId
|
|
276
260
|
}
|
|
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
|
-
return perspectiveDisposeQuerySubscription;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
async add(name: string): Promise<PerspectiveProxy> {
|
|
335
|
-
const { perspectiveAdd } = unwrapApolloResult(
|
|
336
|
-
await this._apolloClient.mutate({
|
|
337
|
-
mutation: gql`mutation perspectiveAdd($name: String!) {
|
|
261
|
+
}).subscribe({
|
|
262
|
+
next: (result) => {
|
|
263
|
+
if (result.data && result.data.perspectiveQuerySubscription) {
|
|
264
|
+
let finalResult = result.data.perspectiveQuerySubscription;
|
|
265
|
+
let isInit = false;
|
|
266
|
+
if(finalResult.startsWith("#init#")) {
|
|
267
|
+
finalResult = finalResult.substring(6)
|
|
268
|
+
isInit = true;
|
|
269
|
+
}
|
|
270
|
+
try {
|
|
271
|
+
finalResult = JSON.parse(finalResult)
|
|
272
|
+
if(isInit && typeof finalResult === 'object') {
|
|
273
|
+
finalResult.isInit = true;
|
|
274
|
+
}
|
|
275
|
+
} catch (e) {
|
|
276
|
+
console.error('Error parsing perspectiveQuerySubscription:', e)
|
|
277
|
+
}
|
|
278
|
+
onData(finalResult);
|
|
279
|
+
}
|
|
280
|
+
},
|
|
281
|
+
error: (e) => console.error('Error in query subscription:', e)
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
return () => subscription.unsubscribe();
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
async keepAliveQuery(uuid: string, subscriptionId: string): Promise<boolean> {
|
|
288
|
+
const { perspectiveKeepAliveQuery } = unwrapApolloResult(await this.#apolloClient.mutate({
|
|
289
|
+
mutation: gql`mutation perspectiveKeepAliveQuery($uuid: String!, $subscriptionId: String!) {
|
|
290
|
+
perspectiveKeepAliveQuery(uuid: $uuid, subscriptionId: $subscriptionId)
|
|
291
|
+
}`,
|
|
292
|
+
variables: { uuid, subscriptionId }
|
|
293
|
+
}))
|
|
294
|
+
|
|
295
|
+
return perspectiveKeepAliveQuery
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
async disposeQuerySubscription(uuid: string, subscriptionId: string): Promise<boolean> {
|
|
299
|
+
const { perspectiveDisposeQuerySubscription } = unwrapApolloResult(await this.#apolloClient.mutate({
|
|
300
|
+
mutation: gql`mutation perspectiveDisposeQuerySubscription($uuid: String!, $subscriptionId: String!) {
|
|
301
|
+
perspectiveDisposeQuerySubscription(uuid: $uuid, subscriptionId: $subscriptionId)
|
|
302
|
+
}`,
|
|
303
|
+
variables: { uuid, subscriptionId }
|
|
304
|
+
}))
|
|
305
|
+
|
|
306
|
+
return perspectiveDisposeQuerySubscription
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
async add(name: string): Promise<PerspectiveProxy> {
|
|
310
|
+
const { perspectiveAdd } = unwrapApolloResult(await this.#apolloClient.mutate({
|
|
311
|
+
mutation: gql`mutation perspectiveAdd($name: String!) {
|
|
338
312
|
perspectiveAdd(name: $name) {
|
|
339
313
|
${PERSPECTIVE_HANDLE_FIELDS}
|
|
340
314
|
}
|
|
341
315
|
}`,
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
await this._apolloClient.mutate({
|
|
351
|
-
mutation: gql`mutation perspectiveUpdate($uuid: String!, $name: String!) {
|
|
316
|
+
variables: { name }
|
|
317
|
+
}))
|
|
318
|
+
return new PerspectiveProxy(perspectiveAdd, this)
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
async update(uuid: string, name: string): Promise<PerspectiveProxy> {
|
|
322
|
+
const { perspectiveUpdate } = unwrapApolloResult(await this.#apolloClient.mutate({
|
|
323
|
+
mutation: gql`mutation perspectiveUpdate($uuid: String!, $name: String!) {
|
|
352
324
|
perspectiveUpdate(uuid: $uuid, name: $name) {
|
|
353
325
|
${PERSPECTIVE_HANDLE_FIELDS}
|
|
354
326
|
}
|
|
355
327
|
}`,
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
async addLink(
|
|
376
|
-
uuid: string,
|
|
377
|
-
link: Link,
|
|
378
|
-
status: LinkStatus = "shared",
|
|
379
|
-
batchId?: string,
|
|
380
|
-
): Promise<LinkExpression> {
|
|
381
|
-
const { perspectiveAddLink } = unwrapApolloResult(
|
|
382
|
-
await this._apolloClient.mutate({
|
|
383
|
-
mutation: gql`mutation perspectiveAddLink($uuid: String!, $link: LinkInput!, $status: String!, $batchId: String) {
|
|
328
|
+
variables: { uuid, name }
|
|
329
|
+
}))
|
|
330
|
+
return new PerspectiveProxy(perspectiveUpdate, this)
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
async remove(uuid: string): Promise<{perspectiveRemove: boolean}> {
|
|
334
|
+
return unwrapApolloResult(await this.#apolloClient.mutate({
|
|
335
|
+
mutation: gql`mutation perspectiveRemove($uuid: String!) {
|
|
336
|
+
perspectiveRemove(uuid: $uuid)
|
|
337
|
+
}`,
|
|
338
|
+
variables: { uuid }
|
|
339
|
+
}))
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
async addLink(uuid: string, link: Link, status: LinkStatus = 'shared', batchId?: string): Promise<LinkExpression> {
|
|
343
|
+
const { perspectiveAddLink } = unwrapApolloResult(await this.#apolloClient.mutate({
|
|
344
|
+
mutation: gql`mutation perspectiveAddLink($uuid: String!, $link: LinkInput!, $status: String!, $batchId: String) {
|
|
384
345
|
perspectiveAddLink(uuid: $uuid, link: $link, status: $status, batchId: $batchId) {
|
|
385
346
|
${LINK_EXPRESSION_FIELDS}
|
|
386
347
|
}
|
|
387
348
|
}`,
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
links: Link[],
|
|
397
|
-
status: LinkStatus = "shared",
|
|
398
|
-
batchId?: string,
|
|
399
|
-
): Promise<LinkExpression[]> {
|
|
400
|
-
const { perspectiveAddLinks } = unwrapApolloResult(
|
|
401
|
-
await this._apolloClient.mutate({
|
|
402
|
-
mutation: gql`mutation perspectiveAddLinks($uuid: String!, $links: [LinkInput!]!, $status: String!, $batchId: String) {
|
|
349
|
+
variables: { uuid, link, status, batchId }
|
|
350
|
+
}))
|
|
351
|
+
return perspectiveAddLink
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
async addLinks(uuid: string, links: Link[], status: LinkStatus = 'shared', batchId?: string): Promise<LinkExpression[]> {
|
|
355
|
+
const { perspectiveAddLinks } = unwrapApolloResult(await this.#apolloClient.mutate({
|
|
356
|
+
mutation: gql`mutation perspectiveAddLinks($uuid: String!, $links: [LinkInput!]!, $status: String!, $batchId: String) {
|
|
403
357
|
perspectiveAddLinks(uuid: $uuid, links: $links, status: $status, batchId: $batchId) {
|
|
404
358
|
${LINK_EXPRESSION_FIELDS}
|
|
405
359
|
}
|
|
406
360
|
}`,
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
links: LinkExpressionInput[],
|
|
416
|
-
batchId?: string,
|
|
417
|
-
): Promise<LinkExpression[]> {
|
|
418
|
-
const { perspectiveRemoveLinks } = unwrapApolloResult(
|
|
419
|
-
await this._apolloClient.mutate({
|
|
420
|
-
mutation: gql`mutation perspectiveRemoveLinks($uuid: String!, $links: [LinkExpressionInput!]!, $batchId: String) {
|
|
361
|
+
variables: { uuid, links, status, batchId }
|
|
362
|
+
}))
|
|
363
|
+
return perspectiveAddLinks
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
async removeLinks(uuid: string, links: LinkExpressionInput[], batchId?: string): Promise<LinkExpression[]> {
|
|
367
|
+
const { perspectiveRemoveLinks } = unwrapApolloResult(await this.#apolloClient.mutate({
|
|
368
|
+
mutation: gql`mutation perspectiveRemoveLinks($uuid: String!, $links: [LinkExpressionInput!]!, $batchId: String) {
|
|
421
369
|
perspectiveRemoveLinks(uuid: $uuid, links: $links, batchId: $batchId) {
|
|
422
370
|
${LINK_EXPRESSION_FIELDS}
|
|
423
371
|
}
|
|
424
372
|
}`,
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
mutations: LinkMutations,
|
|
434
|
-
status?: LinkStatus,
|
|
435
|
-
): Promise<LinkExpressionMutations> {
|
|
436
|
-
const { perspectiveLinkMutations } = unwrapApolloResult(
|
|
437
|
-
await this._apolloClient.mutate({
|
|
438
|
-
mutation: gql`mutation perspectiveLinkMutations($uuid: String!, $mutations: LinkMutations!, $status: String){
|
|
373
|
+
variables: { uuid, links, batchId }
|
|
374
|
+
}))
|
|
375
|
+
return perspectiveRemoveLinks
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
async linkMutations(uuid: string, mutations: LinkMutations, status?: LinkStatus): Promise<LinkExpressionMutations> {
|
|
379
|
+
const { perspectiveLinkMutations } = unwrapApolloResult(await this.#apolloClient.mutate({
|
|
380
|
+
mutation: gql`mutation perspectiveLinkMutations($uuid: String!, $mutations: LinkMutations!, $status: String){
|
|
439
381
|
perspectiveLinkMutations(mutations: $mutations, uuid: $uuid, status: $status) {
|
|
440
382
|
additions {
|
|
441
383
|
${LINK_EXPRESSION_FIELDS}
|
|
@@ -445,391 +387,223 @@ export class PerspectiveClient {
|
|
|
445
387
|
}
|
|
446
388
|
}
|
|
447
389
|
}`,
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
link: LinkExpression,
|
|
457
|
-
status: LinkStatus = "shared",
|
|
458
|
-
batchId?: string,
|
|
459
|
-
): Promise<LinkExpression> {
|
|
460
|
-
const { perspectiveAddLinkExpression } = unwrapApolloResult(
|
|
461
|
-
await this._apolloClient.mutate({
|
|
462
|
-
mutation: gql`mutation perspectiveAddLinkExpression($uuid: String!, $link: LinkExpressionInput!, $status: String!, $batchId: String) {
|
|
390
|
+
variables: { uuid, mutations, status }
|
|
391
|
+
}))
|
|
392
|
+
return perspectiveLinkMutations
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
async addLinkExpression(uuid: string, link: LinkExpression, status: LinkStatus = 'shared', batchId?: string): Promise<LinkExpression> {
|
|
396
|
+
const { perspectiveAddLinkExpression } = unwrapApolloResult(await this.#apolloClient.mutate({
|
|
397
|
+
mutation: gql`mutation perspectiveAddLinkExpression($uuid: String!, $link: LinkExpressionInput!, $status: String!, $batchId: String) {
|
|
463
398
|
perspectiveAddLinkExpression(uuid: $uuid, link: $link, status: $status, batchId: $batchId) {
|
|
464
399
|
${LINK_EXPRESSION_FIELDS}
|
|
465
400
|
}
|
|
466
401
|
}`,
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
oldLink: LinkExpressionInput,
|
|
476
|
-
newLink: Link,
|
|
477
|
-
batchId?: string,
|
|
478
|
-
): Promise<LinkExpression> {
|
|
479
|
-
const { perspectiveUpdateLink } = unwrapApolloResult(
|
|
480
|
-
await this._apolloClient.mutate({
|
|
481
|
-
mutation: gql`mutation perspectiveUpdateLink($uuid: String!, $oldLink: LinkExpressionInput!, $newLink: LinkInput!, $batchId: String) {
|
|
402
|
+
variables: { uuid, link, status, batchId }
|
|
403
|
+
}))
|
|
404
|
+
return perspectiveAddLinkExpression
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
async updateLink(uuid: string, oldLink: LinkExpressionInput, newLink: Link, batchId?: string): Promise<LinkExpression> {
|
|
408
|
+
const { perspectiveUpdateLink } = unwrapApolloResult(await this.#apolloClient.mutate({
|
|
409
|
+
mutation: gql`mutation perspectiveUpdateLink($uuid: String!, $oldLink: LinkExpressionInput!, $newLink: LinkInput!, $batchId: String) {
|
|
482
410
|
perspectiveUpdateLink(uuid: $uuid, oldLink: $oldLink, newLink: $newLink, batchId: $batchId) {
|
|
483
411
|
${LINK_EXPRESSION_FIELDS}
|
|
484
412
|
}
|
|
485
413
|
}`,
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
expression: string,
|
|
569
|
-
parameters: string,
|
|
570
|
-
batchId?: string,
|
|
571
|
-
): Promise<boolean> {
|
|
572
|
-
return unwrapApolloResult(
|
|
573
|
-
await this._apolloClient.mutate({
|
|
574
|
-
mutation: gql`
|
|
575
|
-
mutation perspectiveExecuteCommands(
|
|
576
|
-
$uuid: String!
|
|
577
|
-
$commands: String!
|
|
578
|
-
$expression: String!
|
|
579
|
-
$parameters: String
|
|
580
|
-
$batchId: String
|
|
581
|
-
) {
|
|
582
|
-
perspectiveExecuteCommands(
|
|
583
|
-
uuid: $uuid
|
|
584
|
-
commands: $commands
|
|
585
|
-
expression: $expression
|
|
586
|
-
parameters: $parameters
|
|
587
|
-
batchId: $batchId
|
|
588
|
-
)
|
|
589
|
-
}
|
|
590
|
-
`,
|
|
591
|
-
variables: { uuid, commands, expression, parameters, batchId },
|
|
592
|
-
}),
|
|
593
|
-
).perspectiveExecuteCommands;
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
async createSubject(
|
|
597
|
-
uuid: string,
|
|
598
|
-
subjectClass: string,
|
|
599
|
-
expressionAddress: string,
|
|
600
|
-
initialValues?: string,
|
|
601
|
-
batchId?: string,
|
|
602
|
-
): Promise<boolean> {
|
|
603
|
-
return unwrapApolloResult(
|
|
604
|
-
await this._apolloClient.mutate({
|
|
605
|
-
mutation: gql`
|
|
606
|
-
mutation perspectiveCreateSubject(
|
|
607
|
-
$uuid: String!
|
|
608
|
-
$subjectClass: String!
|
|
609
|
-
$expressionAddress: String!
|
|
610
|
-
$initialValues: String
|
|
611
|
-
$batchId: String
|
|
612
|
-
) {
|
|
613
|
-
perspectiveCreateSubject(
|
|
614
|
-
uuid: $uuid
|
|
615
|
-
subjectClass: $subjectClass
|
|
616
|
-
expressionAddress: $expressionAddress
|
|
617
|
-
initialValues: $initialValues
|
|
618
|
-
batchId: $batchId
|
|
619
|
-
)
|
|
620
|
-
}
|
|
621
|
-
`,
|
|
622
|
-
variables: {
|
|
623
|
-
uuid,
|
|
624
|
-
subjectClass,
|
|
625
|
-
expressionAddress,
|
|
626
|
-
initialValues,
|
|
627
|
-
batchId,
|
|
628
|
-
},
|
|
629
|
-
}),
|
|
630
|
-
).perspectiveCreateSubject;
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
async getSubjectData(
|
|
634
|
-
uuid: string,
|
|
635
|
-
subjectClass: string,
|
|
636
|
-
expressionAddress: string,
|
|
637
|
-
): Promise<string> {
|
|
638
|
-
return unwrapApolloResult(
|
|
639
|
-
await this._apolloClient.mutate({
|
|
640
|
-
mutation: gql`
|
|
641
|
-
mutation perspectiveGetSubjectData(
|
|
642
|
-
$uuid: String!
|
|
643
|
-
$subjectClass: String!
|
|
644
|
-
$expressionAddress: String!
|
|
645
|
-
) {
|
|
646
|
-
perspectiveGetSubjectData(
|
|
647
|
-
uuid: $uuid
|
|
648
|
-
subjectClass: $subjectClass
|
|
649
|
-
expressionAddress: $expressionAddress
|
|
650
|
-
)
|
|
651
|
-
}
|
|
652
|
-
`,
|
|
653
|
-
variables: { uuid, subjectClass, expressionAddress },
|
|
654
|
-
}),
|
|
655
|
-
).perspectiveGetSubjectData;
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
// ExpressionClient functions, needed for Subjects:
|
|
659
|
-
async getExpression(expressionURI: string): Promise<ExpressionRendered> {
|
|
660
|
-
return await this._expressionClient.get(expressionURI);
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
async createExpression(
|
|
664
|
-
content: any,
|
|
665
|
-
languageAddress: string,
|
|
666
|
-
): Promise<string> {
|
|
667
|
-
return await this._expressionClient.create(content, languageAddress);
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
// Subscriptions:
|
|
671
|
-
addPerspectiveAddedListener(cb: PerspectiveHandleCallback) {
|
|
672
|
-
this._perspectiveAddedCallbacks.push(cb);
|
|
673
|
-
}
|
|
674
|
-
|
|
675
|
-
subscribePerspectiveAdded() {
|
|
676
|
-
this._apolloClient
|
|
677
|
-
.subscribe({
|
|
678
|
-
query: gql` subscription {
|
|
414
|
+
variables: { uuid, oldLink, newLink, batchId }
|
|
415
|
+
}))
|
|
416
|
+
return perspectiveUpdateLink
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
async removeLink(uuid: string, link: LinkExpressionInput, batchId?: string): Promise<boolean> {
|
|
420
|
+
delete link.__typename
|
|
421
|
+
delete link.data.__typename
|
|
422
|
+
delete link.proof.__typename
|
|
423
|
+
delete link.status
|
|
424
|
+
const { perspectiveRemoveLink } = unwrapApolloResult(await this.#apolloClient.mutate({
|
|
425
|
+
mutation: gql`mutation perspectiveRemoveLink($link: LinkExpressionInput!, $uuid: String!, $batchId: String) {
|
|
426
|
+
perspectiveRemoveLink(link: $link, uuid: $uuid, batchId: $batchId)
|
|
427
|
+
}`,
|
|
428
|
+
variables: { uuid, link, batchId }
|
|
429
|
+
}))
|
|
430
|
+
return perspectiveRemoveLink
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* Adds Social DNA code to a perspective.
|
|
435
|
+
*
|
|
436
|
+
* Preferred usage: pass shaclJson (from SHACLShape.toJSON()) as the primary schema definition.
|
|
437
|
+
* The sdnaCode parameter is kept for backward compatibility but SHACL is the source of truth
|
|
438
|
+
* for all SDNA operations. Prolog engines remain available for complex queries.
|
|
439
|
+
*
|
|
440
|
+
* @param sdnaCode - Legacy Prolog code (pass empty string when using shaclJson)
|
|
441
|
+
* @param shaclJson - SHACL JSON string from SHACLShape.toJSON() (recommended)
|
|
442
|
+
*/
|
|
443
|
+
async addSdna(uuid: string, name: string, sdnaCode: string | undefined, sdnaType: "subject_class" | "flow" | "custom", shaclJson?: string): Promise<boolean> {
|
|
444
|
+
return unwrapApolloResult(await this.#apolloClient.mutate({
|
|
445
|
+
mutation: gql`mutation perspectiveAddSdna($uuid: String!, $name: String!, $sdnaCode: String, $sdnaType: String!, $shaclJson: String) {
|
|
446
|
+
perspectiveAddSdna(uuid: $uuid, name: $name, sdnaCode: $sdnaCode, sdnaType: $sdnaType, shaclJson: $shaclJson)
|
|
447
|
+
}`,
|
|
448
|
+
variables: { uuid, name, sdnaCode: sdnaCode || "", sdnaType, shaclJson }
|
|
449
|
+
})).perspectiveAddSdna
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
async executeCommands(uuid: string, commands: string, expression: string, parameters: string, batchId?: string): Promise<boolean> {
|
|
453
|
+
return unwrapApolloResult(await this.#apolloClient.mutate({
|
|
454
|
+
mutation: gql`mutation perspectiveExecuteCommands($uuid: String!, $commands: String!, $expression: String!, $parameters: String, $batchId: String) {
|
|
455
|
+
perspectiveExecuteCommands(uuid: $uuid, commands: $commands, expression: $expression, parameters: $parameters, batchId: $batchId)
|
|
456
|
+
}`,
|
|
457
|
+
variables: { uuid, commands, expression, parameters, batchId }
|
|
458
|
+
})).perspectiveExecuteCommands
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
async createSubject(uuid: string, subjectClass: string, expressionAddress: string, initialValues?: string, batchId?: string): Promise<boolean> {
|
|
462
|
+
return unwrapApolloResult(await this.#apolloClient.mutate({
|
|
463
|
+
mutation: gql`mutation perspectiveCreateSubject($uuid: String!, $subjectClass: String!, $expressionAddress: String!, $initialValues: String, $batchId: String) {
|
|
464
|
+
perspectiveCreateSubject(uuid: $uuid, subjectClass: $subjectClass, expressionAddress: $expressionAddress, initialValues: $initialValues, batchId: $batchId)
|
|
465
|
+
}`,
|
|
466
|
+
variables: { uuid, subjectClass, expressionAddress, initialValues, batchId }
|
|
467
|
+
})).perspectiveCreateSubject
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
async getSubjectData(uuid: string, subjectClass: string, expressionAddress: string): Promise<string> {
|
|
471
|
+
return unwrapApolloResult(await this.#apolloClient.mutate({
|
|
472
|
+
mutation: gql`mutation perspectiveGetSubjectData($uuid: String!, $subjectClass: String!, $expressionAddress: String!) {
|
|
473
|
+
perspectiveGetSubjectData(uuid: $uuid, subjectClass: $subjectClass, expressionAddress: $expressionAddress)
|
|
474
|
+
}`,
|
|
475
|
+
variables: { uuid, subjectClass, expressionAddress }
|
|
476
|
+
})).perspectiveGetSubjectData
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
// ExpressionClient functions, needed for Subjects:
|
|
480
|
+
async getExpression(expressionURI: string): Promise<ExpressionRendered> {
|
|
481
|
+
return await this.#expressionClient.get(expressionURI)
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
async createExpression(content: any, languageAddress: string): Promise<string> {
|
|
485
|
+
return await this.#expressionClient.create(content, languageAddress)
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
// Subscriptions:
|
|
489
|
+
addPerspectiveAddedListener(cb: PerspectiveHandleCallback) {
|
|
490
|
+
this.#perspectiveAddedCallbacks.push(cb)
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
subscribePerspectiveAdded() {
|
|
494
|
+
this.#apolloClient.subscribe({
|
|
495
|
+
query: gql` subscription {
|
|
679
496
|
perspectiveAdded { ${PERSPECTIVE_HANDLE_FIELDS} }
|
|
680
497
|
}
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
subscribePerspectiveUpdated() {
|
|
700
|
-
this._apolloClient
|
|
701
|
-
.subscribe({
|
|
702
|
-
query: gql` subscription {
|
|
498
|
+
`}).subscribe({
|
|
499
|
+
next: result => {
|
|
500
|
+
this.#perspectiveAddedCallbacks.forEach(cb => {
|
|
501
|
+
cb(result.data.perspectiveAdded)
|
|
502
|
+
})
|
|
503
|
+
},
|
|
504
|
+
error: (e) => console.error(e)
|
|
505
|
+
})
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
addPerspectiveUpdatedListener(cb: PerspectiveHandleCallback) {
|
|
509
|
+
this.#perspectiveUpdatedCallbacks.push(cb)
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
subscribePerspectiveUpdated() {
|
|
513
|
+
this.#apolloClient.subscribe({
|
|
514
|
+
query: gql` subscription {
|
|
703
515
|
perspectiveUpdated { ${PERSPECTIVE_HANDLE_FIELDS} }
|
|
704
516
|
}
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
}
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
async addPerspectiveSyncStateChangeListener(
|
|
724
|
-
uuid: String,
|
|
725
|
-
cb: SyncStateChangeCallback[],
|
|
726
|
-
): Promise<void> {
|
|
727
|
-
this._apolloClient
|
|
728
|
-
.subscribe({
|
|
729
|
-
query: gql` subscription {
|
|
517
|
+
`}).subscribe({
|
|
518
|
+
next: result => {
|
|
519
|
+
this.#perspectiveUpdatedCallbacks.forEach(cb => {
|
|
520
|
+
cb(result.data.perspectiveUpdated)
|
|
521
|
+
})
|
|
522
|
+
},
|
|
523
|
+
error: (e) => console.error(e)
|
|
524
|
+
})
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
addPerspectiveSyncedListener(cb: SyncStateChangeCallback) {
|
|
528
|
+
this.#perspectiveSyncStateChangeCallbacks.push(cb)
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
async addPerspectiveSyncStateChangeListener(uuid: String, cb: SyncStateChangeCallback[]): Promise<void> {
|
|
532
|
+
this.#apolloClient.subscribe({
|
|
533
|
+
query: gql` subscription {
|
|
730
534
|
perspectiveSyncStateChange(uuid: "${uuid}")
|
|
731
535
|
}
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
}
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
},
|
|
767
|
-
error: (e) => {
|
|
768
|
-
if (!isSocketCloseError(e)) console.error(e);
|
|
769
|
-
},
|
|
770
|
-
});
|
|
771
|
-
}
|
|
772
|
-
|
|
773
|
-
async addPerspectiveLinkAddedListener(
|
|
774
|
-
uuid: String,
|
|
775
|
-
cb: LinkCallback[],
|
|
776
|
-
): Promise<void> {
|
|
777
|
-
this._apolloClient
|
|
778
|
-
.subscribe({
|
|
779
|
-
query: gql` subscription {
|
|
536
|
+
`}).subscribe({
|
|
537
|
+
next: result => {
|
|
538
|
+
cb.forEach(c => {
|
|
539
|
+
c(result.data.perspectiveSyncStateChange)
|
|
540
|
+
})
|
|
541
|
+
},
|
|
542
|
+
error: (e) => console.error(e)
|
|
543
|
+
})
|
|
544
|
+
|
|
545
|
+
await new Promise<void>(resolve => setTimeout(resolve, 500))
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
addPerspectiveRemovedListener(cb: UuidCallback) {
|
|
549
|
+
this.#perspectiveRemovedCallbacks.push(cb)
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
subscribePerspectiveRemoved() {
|
|
553
|
+
this.#apolloClient.subscribe({
|
|
554
|
+
query: gql` subscription {
|
|
555
|
+
perspectiveRemoved
|
|
556
|
+
}
|
|
557
|
+
`}).subscribe({
|
|
558
|
+
next: result => {
|
|
559
|
+
this.#perspectiveRemovedCallbacks.forEach(cb => {
|
|
560
|
+
cb(result.data.perspectiveRemoved)
|
|
561
|
+
})
|
|
562
|
+
},
|
|
563
|
+
error: (e) => console.error(e)
|
|
564
|
+
})
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
async addPerspectiveLinkAddedListener(uuid: String, cb: LinkCallback[]): Promise<void> {
|
|
568
|
+
this.#apolloClient.subscribe({
|
|
569
|
+
query: gql` subscription {
|
|
780
570
|
perspectiveLinkAdded(uuid: "${uuid}") { ${LINK_EXPRESSION_FIELDS} }
|
|
781
571
|
}
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
}
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
async addPerspectiveLinkRemovedListener(
|
|
799
|
-
uuid: String,
|
|
800
|
-
cb: LinkCallback[],
|
|
801
|
-
): Promise<void> {
|
|
802
|
-
this._apolloClient
|
|
803
|
-
.subscribe({
|
|
804
|
-
query: gql` subscription {
|
|
572
|
+
`}).subscribe({
|
|
573
|
+
next: result => {
|
|
574
|
+
cb.forEach(c => {
|
|
575
|
+
c(result.data.perspectiveLinkAdded)
|
|
576
|
+
})
|
|
577
|
+
},
|
|
578
|
+
error: (e) => console.error(e)
|
|
579
|
+
})
|
|
580
|
+
|
|
581
|
+
await new Promise<void>(resolve => setTimeout(resolve, 500))
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
async addPerspectiveLinkRemovedListener(uuid: String, cb: LinkCallback[]): Promise<void> {
|
|
585
|
+
this.#apolloClient.subscribe({
|
|
586
|
+
query: gql` subscription {
|
|
805
587
|
perspectiveLinkRemoved(uuid: "${uuid}") { ${LINK_EXPRESSION_FIELDS} }
|
|
806
588
|
}
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
}
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
async addPerspectiveLinkUpdatedListener(
|
|
827
|
-
uuid: String,
|
|
828
|
-
cb: LinkCallback[],
|
|
829
|
-
): Promise<void> {
|
|
830
|
-
this._apolloClient
|
|
831
|
-
.subscribe({
|
|
832
|
-
query: gql` subscription {
|
|
589
|
+
`}).subscribe({
|
|
590
|
+
next: result => {
|
|
591
|
+
cb.forEach(c => {
|
|
592
|
+
if (!result.data.perspectiveLinkRemoved.status) {
|
|
593
|
+
delete result.data.perspectiveLinkRemoved.status
|
|
594
|
+
}
|
|
595
|
+
c(result.data.perspectiveLinkRemoved)
|
|
596
|
+
})
|
|
597
|
+
},
|
|
598
|
+
error: (e) => console.error(e)
|
|
599
|
+
})
|
|
600
|
+
|
|
601
|
+
await new Promise<void>(resolve => setTimeout(resolve, 500))
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
async addPerspectiveLinkUpdatedListener(uuid: String, cb: LinkCallback[]): Promise<void> {
|
|
605
|
+
this.#apolloClient.subscribe({
|
|
606
|
+
query: gql` subscription {
|
|
833
607
|
perspectiveLinkUpdated(uuid: "${uuid}") {
|
|
834
608
|
oldLink {
|
|
835
609
|
${LINK_EXPRESSION_FIELDS}
|
|
@@ -839,53 +613,41 @@ export class PerspectiveClient {
|
|
|
839
613
|
}
|
|
840
614
|
}
|
|
841
615
|
}
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
}
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
}),
|
|
878
|
-
);
|
|
879
|
-
return perspectiveCreateBatch;
|
|
880
|
-
}
|
|
881
|
-
|
|
882
|
-
async commitBatch(
|
|
883
|
-
uuid: string,
|
|
884
|
-
batchId: string,
|
|
885
|
-
): Promise<LinkExpressionMutations> {
|
|
886
|
-
const { perspectiveCommitBatch } = unwrapApolloResult(
|
|
887
|
-
await this._apolloClient.mutate({
|
|
888
|
-
mutation: gql`mutation perspectiveCommitBatch($uuid: String!, $batchId: String!) {
|
|
616
|
+
`}).subscribe({
|
|
617
|
+
next: result => {
|
|
618
|
+
cb.forEach(c => {
|
|
619
|
+
if (!result.data.perspectiveLinkUpdated.newLink.status) {
|
|
620
|
+
delete result.data.perspectiveLinkUpdated.newLink.status
|
|
621
|
+
}
|
|
622
|
+
if (!result.data.perspectiveLinkUpdated.oldLink.status) {
|
|
623
|
+
delete result.data.perspectiveLinkUpdated.oldLink.status
|
|
624
|
+
}
|
|
625
|
+
c(result.data.perspectiveLinkUpdated)
|
|
626
|
+
})
|
|
627
|
+
},
|
|
628
|
+
error: (e) => console.error(e)
|
|
629
|
+
})
|
|
630
|
+
|
|
631
|
+
await new Promise<void>(resolve => setTimeout(resolve, 500))
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
getNeighbourhoodProxy(uuid: string): NeighbourhoodProxy {
|
|
635
|
+
return new NeighbourhoodProxy(this.#neighbourhoodClient, uuid)
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
async createBatch(uuid: string): Promise<string> {
|
|
639
|
+
const { perspectiveCreateBatch } = unwrapApolloResult(await this.#apolloClient.mutate({
|
|
640
|
+
mutation: gql`mutation perspectiveCreateBatch($uuid: String!) {
|
|
641
|
+
perspectiveCreateBatch(uuid: $uuid)
|
|
642
|
+
}`,
|
|
643
|
+
variables: { uuid }
|
|
644
|
+
}))
|
|
645
|
+
return perspectiveCreateBatch
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
async commitBatch(uuid: string, batchId: string): Promise<LinkExpressionMutations> {
|
|
649
|
+
const { perspectiveCommitBatch } = unwrapApolloResult(await this.#apolloClient.mutate({
|
|
650
|
+
mutation: gql`mutation perspectiveCommitBatch($uuid: String!, $batchId: String!) {
|
|
889
651
|
perspectiveCommitBatch(uuid: $uuid, batchId: $batchId) {
|
|
890
652
|
additions {
|
|
891
653
|
${LINK_EXPRESSION_FIELDS}
|
|
@@ -895,9 +657,8 @@ export class PerspectiveClient {
|
|
|
895
657
|
}
|
|
896
658
|
}
|
|
897
659
|
}`,
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
}
|
|
660
|
+
variables: { uuid, batchId }
|
|
661
|
+
}))
|
|
662
|
+
return perspectiveCommitBatch
|
|
663
|
+
}
|
|
664
|
+
}
|