@coasys/ad4m 0.12.1-dev → 0.13.0-test-2
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/lib/index.cjs +1469 -781
- package/lib/index.js +1453 -779
- package/lib/src/Literal.js +6 -5
- package/lib/src/agent/AgentClient.d.ts +8 -1
- package/lib/src/agent/AgentClient.js +73 -2
- package/lib/src/expression/ExpressionRef.js +2 -2
- package/lib/src/language/Language.d.ts +41 -3
- package/lib/src/model/Ad4mModel.d.ts +28 -28
- package/lib/src/model/Ad4mModel.js +129 -101
- package/lib/src/model/Ad4mModel.test.js +1543 -535
- package/lib/src/model/ModelQueryBuilder.d.ts +48 -34
- package/lib/src/model/ModelQueryBuilder.js +163 -78
- package/lib/src/model/Subject.js +6 -6
- package/lib/src/model/decorators.d.ts +14 -8
- package/lib/src/model/decorators.js +41 -14
- package/lib/src/model/hydration-batch.d.ts +34 -0
- package/lib/src/model/hydration-batch.js +147 -0
- package/lib/src/model/hydration.d.ts +3 -3
- package/lib/src/model/hydration.js +106 -36
- package/lib/src/model/index.d.ts +4 -1
- package/lib/src/model/index.js +4 -1
- package/lib/src/model/json-schema.js +2 -2
- package/lib/src/model/query-cache.d.ts +30 -0
- package/lib/src/model/query-cache.js +66 -0
- package/lib/src/model/query-cache.test.d.ts +1 -0
- package/lib/src/model/query-cache.test.js +43 -0
- package/lib/src/model/query-common.d.ts +1 -1
- package/lib/src/model/query-common.js +1 -1
- package/lib/src/model/query-sparql-batch.d.ts +17 -0
- package/lib/src/model/query-sparql-batch.js +260 -0
- package/lib/src/model/query-sparql.d.ts +47 -0
- package/lib/src/model/query-sparql.js +336 -0
- package/lib/src/model/query-utils.d.ts +45 -0
- package/lib/src/model/query-utils.js +140 -0
- package/lib/src/model/relation-filtering.test.js +15 -15
- package/lib/src/model/sdna.js +1 -1
- package/lib/src/model/shacl-gen.js +42 -18
- package/lib/src/model/subscription-pool.d.ts +39 -0
- package/lib/src/model/subscription-pool.js +119 -0
- package/lib/src/model/types.d.ts +3 -3
- package/lib/src/model/types.js +1 -1
- package/lib/src/perspectives/PerspectiveClient.d.ts +1 -17
- package/lib/src/perspectives/PerspectiveClient.js +5 -57
- package/lib/src/perspectives/PerspectiveProxy.d.ts +51 -30
- package/lib/src/perspectives/PerspectiveProxy.js +224 -177
- package/lib/src/perspectives/PerspectiveResolver.d.ts +0 -1
- package/lib/src/perspectives/PerspectiveResolver.js +0 -11
- package/lib/src/perspectives/WakerSubscriptionManager.d.ts +3 -3
- package/lib/src/perspectives/WakerSubscriptionManager.js +7 -8
- package/lib/src/runtime/RuntimeClient.d.ts +2 -0
- package/lib/src/runtime/RuntimeClient.js +17 -0
- package/lib/src/runtime/RuntimeResolver.d.ts +14 -0
- package/lib/src/runtime/RuntimeResolver.js +84 -0
- package/lib/src/schema.gql +14 -1
- package/lib/src/shacl/SHACLFlow.d.ts +1 -1
- package/lib/src/shacl/SHACLFlow.js +9 -9
- package/lib/src/shacl/SHACLShape.d.ts +1 -1
- package/lib/src/shacl/SHACLShape.js +38 -38
- package/lib/src/typeDefs.js +14 -1
- package/lib/src/utils.d.ts +6 -6
- package/lib/src/utils.js +6 -6
- package/package.json +1 -1
- package/src/Literal.test.ts +10 -5
- package/src/Literal.ts +6 -5
- package/src/agent/AgentClient.ts +81 -1
- package/src/expression/ExpressionRef.ts +2 -2
- package/src/language/Language.ts +48 -3
- package/src/model/Ad4mModel.test.ts +1515 -565
- package/src/model/Ad4mModel.ts +142 -102
- package/src/model/ModelQueryBuilder.ts +185 -86
- package/src/model/Subject.ts +6 -6
- package/src/model/decorators.ts +51 -22
- package/src/model/hydration-batch.ts +205 -0
- package/src/model/hydration.ts +102 -39
- package/src/model/index.ts +4 -1
- package/src/model/json-schema.ts +2 -2
- package/src/model/query-cache.test.ts +54 -0
- package/src/model/query-cache.ts +79 -0
- package/src/model/query-common.ts +1 -1
- package/src/model/query-sparql-batch.ts +301 -0
- package/src/model/query-sparql.ts +363 -0
- package/src/model/{surreal-utils.ts → query-utils.ts} +40 -27
- package/src/model/relation-filtering.test.ts +15 -15
- package/src/model/sdna.ts +1 -1
- package/src/model/shacl-gen.ts +42 -17
- package/src/model/subscription-pool.ts +163 -0
- package/src/model/types.ts +3 -3
- package/src/perspectives/PerspectiveClient.ts +5 -61
- package/src/perspectives/PerspectiveProxy.ts +226 -181
- package/src/perspectives/PerspectiveResolver.ts +0 -8
- package/src/perspectives/WakerSubscriptionManager.ts +8 -9
- package/src/runtime/RuntimeClient.ts +19 -0
- package/src/runtime/RuntimeResolver.ts +58 -0
- package/src/shacl/SHACLFlow.ts +9 -9
- package/src/shacl/SHACLShape.ts +39 -39
- package/src/utils.ts +6 -6
- package/src/model/query-surreal.ts +0 -280
package/src/language/Language.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { Perspective, PerspectiveExpression } from '../perspectives/Perspective'
|
|
|
5
5
|
import { PerspectiveDiff } from '../perspectives/PerspectiveDiff';
|
|
6
6
|
import { InputType, Field, ObjectType } from "type-graphql";
|
|
7
7
|
import { PerspectiveState } from '../perspectives/PerspectiveHandle';
|
|
8
|
+
import { LinkQuery } from '../perspectives/LinkQuery';
|
|
8
9
|
|
|
9
10
|
/** Interface of AD4M Languages
|
|
10
11
|
*
|
|
@@ -41,8 +42,14 @@ export interface Language {
|
|
|
41
42
|
/** Interface for getting UI/web components for rendering Expressions of this Language */
|
|
42
43
|
readonly expressionUI?: ExpressionUI;
|
|
43
44
|
|
|
45
|
+
// TODO: Rename linksAdapter to perspectiveSyncAdapter needs a lot of changes elsewhere...
|
|
44
46
|
/** Interface of LinkLanguages for the core implementation of Neighbourhoods */
|
|
45
|
-
readonly
|
|
47
|
+
readonly perspectiveSyncAdapter?: PerspectiveSyncAdapter;
|
|
48
|
+
|
|
49
|
+
/** Interface for Languages that implement a query return a Perspective (snapshot)
|
|
50
|
+
* Used for back-links and wrapping of APIs that implement queries.
|
|
51
|
+
*/
|
|
52
|
+
readonly pespectiveQueryAdapter?: PerspectiveQueryAdapter;
|
|
46
53
|
|
|
47
54
|
/** Additional Interface of LinkLanguages that support telepresence features,
|
|
48
55
|
* that is:
|
|
@@ -156,11 +163,11 @@ export type SyncStateChangeObserver = (state: PerspectiveState)=>void;
|
|
|
156
163
|
* The assumption is that every version of the shared Perspective
|
|
157
164
|
* is labeled with a unique revision string.
|
|
158
165
|
* Changes are committed and retrieved through diffs.
|
|
159
|
-
* Think of a
|
|
166
|
+
* Think of a PerspectiveSyncAdapter as a git branch to which agents commit
|
|
160
167
|
* their changes to and pull diffs from their current revision
|
|
161
168
|
* to the latest one.
|
|
162
169
|
*/
|
|
163
|
-
export interface
|
|
170
|
+
export interface PerspectiveSyncAdapter {
|
|
164
171
|
writable(): boolean;
|
|
165
172
|
public(): boolean;
|
|
166
173
|
others(): Promise<DID[]>;
|
|
@@ -276,3 +283,41 @@ export interface TelepresenceAdapter {
|
|
|
276
283
|
sendBroadcast(payload: PerspectiveExpression): Promise<object>;
|
|
277
284
|
registerSignalCallback(callback: TelepresenceSignalCallback): Promise<void>;
|
|
278
285
|
}
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
/** Interface for Languages that implement queries returning links, i.e. a Perspective (-snapshot)
|
|
289
|
+
* Main differentiation between these Languages and LinkLanguages is that this enables
|
|
290
|
+
* access to other shared perspectives without forcing a full-sync.
|
|
291
|
+
*
|
|
292
|
+
* All PerspectiveQuery Languages are supposed to implement `linkQuery` which is a simple graph query
|
|
293
|
+
* specifying non or all of source, predicate, target of the links we want to get.
|
|
294
|
+
* This is enough to implement simple back-links.
|
|
295
|
+
*
|
|
296
|
+
* Prolog queries are optional since this requires a Prolog engine to be available.
|
|
297
|
+
*
|
|
298
|
+
*/
|
|
299
|
+
export interface PerspectiveQueryAdapter {
|
|
300
|
+
/** Same semantic as PerspectiveProxy.get(LinkQuery) */
|
|
301
|
+
linkQuery(query: LinkQuery): Promise<Perspective>;
|
|
302
|
+
|
|
303
|
+
/** Tells ADAM if Prolog queries are implemented by this Language.
|
|
304
|
+
* If not, prologQuery won't be used, instead in some circumstances,
|
|
305
|
+
* linkQuery() might be called with an all-query, followed by using
|
|
306
|
+
* ADAM's internal Prolog engine on the result.
|
|
307
|
+
*/
|
|
308
|
+
supportsPrologQueries(): boolean;
|
|
309
|
+
|
|
310
|
+
/** Same semantic as PerspectiveProxy.infer, will return plain Prolog results */
|
|
311
|
+
infer(prologQuery: string): Promise<any>
|
|
312
|
+
|
|
313
|
+
/** Specify which links shall be returned through Prolog.
|
|
314
|
+
* Assumes unbound variables in query that describe a LinkExpression:
|
|
315
|
+
* - Source
|
|
316
|
+
* - Predicate
|
|
317
|
+
* - Target
|
|
318
|
+
* - Author
|
|
319
|
+
* - Timestamp
|
|
320
|
+
* Will construct a Perspective where each link is a solution to the query.
|
|
321
|
+
*/
|
|
322
|
+
prologQuery(query: string): Promise<Perspective>;
|
|
323
|
+
}
|