@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,118 +1,118 @@
|
|
|
1
|
-
import { Field, ObjectType, InputType } from "type-graphql";
|
|
2
|
-
import { ExpressionGeneric } from "../expression/Expression";
|
|
3
|
-
import { Link, LinkExpression, LinkExpressionInput, LinkInput } from "../links/Links";
|
|
4
|
-
import { LinkQuery } from "./LinkQuery";
|
|
5
|
-
|
|
6
|
-
/** A Perspective represents subjective meaning, encoded through
|
|
7
|
-
* associations between expressions, a.k.a. Links, that is a graph
|
|
8
|
-
* over the objective Expressions of any subset of Languages.
|
|
9
|
-
*
|
|
10
|
-
* This type represents the clean onotological concept of a Perspective.
|
|
11
|
-
* An instance of this class can be regarded as an immutable snapshot of
|
|
12
|
-
* a mutable perspective.
|
|
13
|
-
*
|
|
14
|
-
* The types PerspectiveProxy and PerspectiveHandle are used when dealing
|
|
15
|
-
* with an instantiated mutable perspective as is done through most of
|
|
16
|
-
* the GraphQL mutations.
|
|
17
|
-
*/
|
|
18
|
-
@ObjectType()
|
|
19
|
-
export class Perspective {
|
|
20
|
-
/** The content of the perspective, a list/graph of links */
|
|
21
|
-
@Field(type => [LinkExpression])
|
|
22
|
-
links: LinkExpression[]
|
|
23
|
-
|
|
24
|
-
constructor(links?: LinkExpression[]) {
|
|
25
|
-
if(links) {
|
|
26
|
-
this.links = links
|
|
27
|
-
} else {
|
|
28
|
-
this.links = []
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/** Convenience function for filtering links just like with PerspectiveProxy */
|
|
33
|
-
get(query: LinkQuery): LinkExpression[] {
|
|
34
|
-
if(!query || !query.source && !query.predicate && !query.target) {
|
|
35
|
-
return this.links
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if(query.source) {
|
|
39
|
-
let result = JSON.parse(JSON.stringify(this.links))
|
|
40
|
-
// @ts-ignore
|
|
41
|
-
if(query.target) result = result.filter(l => l.data.target === query.target)
|
|
42
|
-
// @ts-ignore
|
|
43
|
-
if(query.predicate) result = result.filter(l => l.data.predicate === query.predicate)
|
|
44
|
-
//@ts-ignore
|
|
45
|
-
if (query.fromDate) result = result.filter(l => new Date(l.timestamp) >= query.fromDate!)
|
|
46
|
-
//@ts-ignore
|
|
47
|
-
if (query.untilDate) result = result.filter(l => new Date(l.timestamp) <= query.untilDate!)
|
|
48
|
-
// console.debug("result", result)
|
|
49
|
-
if (query.limit) result = result.slice(0, query.limit);
|
|
50
|
-
return result
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// console.debug("getLinks 3")
|
|
54
|
-
|
|
55
|
-
if(query.target) {
|
|
56
|
-
//@ts-ignore
|
|
57
|
-
let result = JSON.parse(JSON.stringify(this.links))
|
|
58
|
-
// @ts-ignore
|
|
59
|
-
if(query.predicate) result = result.filter(l => l.data.predicate === query.predicate)
|
|
60
|
-
//@ts-ignore
|
|
61
|
-
if (query.fromDate) result = result.filter(l => new Date(l.timestamp) >= query.fromDate!)
|
|
62
|
-
//@ts-ignore
|
|
63
|
-
if (query.untilDate) result = result.filter(l => new Date(l.timestamp) <= query.untilDate!)
|
|
64
|
-
if (query.limit) result = result.slice(0, query.limit);
|
|
65
|
-
return result
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// console.debug("getLinks 4")
|
|
69
|
-
|
|
70
|
-
//@ts-ignore
|
|
71
|
-
let result = JSON.parse(JSON.stringify(this.links))
|
|
72
|
-
result = result.filter(link => link.data.predicate === query.predicate)
|
|
73
|
-
if (query.limit) result = result.slice(0, query.limit)
|
|
74
|
-
return result
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/** Convenience function to get the target of the first link that matches the given query
|
|
78
|
-
* This makes sense when the query is expected to return only one link
|
|
79
|
-
* and the target of that link is what you are looking for.
|
|
80
|
-
*/
|
|
81
|
-
getSingleTarget(query: LinkQuery): string|void {
|
|
82
|
-
delete query.target
|
|
83
|
-
const foundLinks = this.get(query)
|
|
84
|
-
if(foundLinks.length)
|
|
85
|
-
return foundLinks[0].data.target
|
|
86
|
-
else
|
|
87
|
-
return null
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
@InputType()
|
|
93
|
-
export class PerspectiveInput {
|
|
94
|
-
@Field(type => [LinkExpressionInput])
|
|
95
|
-
links: LinkExpressionInput[]
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
@InputType()
|
|
99
|
-
export class PerspectiveUnsignedInput {
|
|
100
|
-
@Field(type => [LinkInput])
|
|
101
|
-
links: LinkInput[]
|
|
102
|
-
|
|
103
|
-
constructor(links?: LinkInput[]) {
|
|
104
|
-
if(links)
|
|
105
|
-
this.links = links
|
|
106
|
-
else
|
|
107
|
-
this.links = []
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
static fromLink(link: Link): PerspectiveUnsignedInput {
|
|
111
|
-
let obj = new PerspectiveUnsignedInput()
|
|
112
|
-
obj.links.push(link)
|
|
113
|
-
return obj
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
@ObjectType()
|
|
118
|
-
export class PerspectiveExpression extends ExpressionGeneric(Perspective) {};
|
|
1
|
+
import { Field, ObjectType, InputType } from "type-graphql";
|
|
2
|
+
import { ExpressionGeneric } from "../expression/Expression";
|
|
3
|
+
import { Link, LinkExpression, LinkExpressionInput, LinkInput } from "../links/Links";
|
|
4
|
+
import { LinkQuery } from "./LinkQuery";
|
|
5
|
+
|
|
6
|
+
/** A Perspective represents subjective meaning, encoded through
|
|
7
|
+
* associations between expressions, a.k.a. Links, that is a graph
|
|
8
|
+
* over the objective Expressions of any subset of Languages.
|
|
9
|
+
*
|
|
10
|
+
* This type represents the clean onotological concept of a Perspective.
|
|
11
|
+
* An instance of this class can be regarded as an immutable snapshot of
|
|
12
|
+
* a mutable perspective.
|
|
13
|
+
*
|
|
14
|
+
* The types PerspectiveProxy and PerspectiveHandle are used when dealing
|
|
15
|
+
* with an instantiated mutable perspective as is done through most of
|
|
16
|
+
* the GraphQL mutations.
|
|
17
|
+
*/
|
|
18
|
+
@ObjectType()
|
|
19
|
+
export class Perspective {
|
|
20
|
+
/** The content of the perspective, a list/graph of links */
|
|
21
|
+
@Field(type => [LinkExpression])
|
|
22
|
+
links: LinkExpression[]
|
|
23
|
+
|
|
24
|
+
constructor(links?: LinkExpression[]) {
|
|
25
|
+
if(links) {
|
|
26
|
+
this.links = links
|
|
27
|
+
} else {
|
|
28
|
+
this.links = []
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Convenience function for filtering links just like with PerspectiveProxy */
|
|
33
|
+
get(query: LinkQuery): LinkExpression[] {
|
|
34
|
+
if(!query || !query.source && !query.predicate && !query.target) {
|
|
35
|
+
return this.links
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if(query.source) {
|
|
39
|
+
let result = JSON.parse(JSON.stringify(this.links))
|
|
40
|
+
// @ts-ignore
|
|
41
|
+
if(query.target) result = result.filter(l => l.data.target === query.target)
|
|
42
|
+
// @ts-ignore
|
|
43
|
+
if(query.predicate) result = result.filter(l => l.data.predicate === query.predicate)
|
|
44
|
+
//@ts-ignore
|
|
45
|
+
if (query.fromDate) result = result.filter(l => new Date(l.timestamp) >= query.fromDate!)
|
|
46
|
+
//@ts-ignore
|
|
47
|
+
if (query.untilDate) result = result.filter(l => new Date(l.timestamp) <= query.untilDate!)
|
|
48
|
+
// console.debug("result", result)
|
|
49
|
+
if (query.limit) result = result.slice(0, query.limit);
|
|
50
|
+
return result
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// console.debug("getLinks 3")
|
|
54
|
+
|
|
55
|
+
if(query.target) {
|
|
56
|
+
//@ts-ignore
|
|
57
|
+
let result = JSON.parse(JSON.stringify(this.links))
|
|
58
|
+
// @ts-ignore
|
|
59
|
+
if(query.predicate) result = result.filter(l => l.data.predicate === query.predicate)
|
|
60
|
+
//@ts-ignore
|
|
61
|
+
if (query.fromDate) result = result.filter(l => new Date(l.timestamp) >= query.fromDate!)
|
|
62
|
+
//@ts-ignore
|
|
63
|
+
if (query.untilDate) result = result.filter(l => new Date(l.timestamp) <= query.untilDate!)
|
|
64
|
+
if (query.limit) result = result.slice(0, query.limit);
|
|
65
|
+
return result
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// console.debug("getLinks 4")
|
|
69
|
+
|
|
70
|
+
//@ts-ignore
|
|
71
|
+
let result = JSON.parse(JSON.stringify(this.links))
|
|
72
|
+
result = result.filter(link => link.data.predicate === query.predicate)
|
|
73
|
+
if (query.limit) result = result.slice(0, query.limit)
|
|
74
|
+
return result
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Convenience function to get the target of the first link that matches the given query
|
|
78
|
+
* This makes sense when the query is expected to return only one link
|
|
79
|
+
* and the target of that link is what you are looking for.
|
|
80
|
+
*/
|
|
81
|
+
getSingleTarget(query: LinkQuery): string|void {
|
|
82
|
+
delete query.target
|
|
83
|
+
const foundLinks = this.get(query)
|
|
84
|
+
if(foundLinks.length)
|
|
85
|
+
return foundLinks[0].data.target
|
|
86
|
+
else
|
|
87
|
+
return null
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
@InputType()
|
|
93
|
+
export class PerspectiveInput {
|
|
94
|
+
@Field(type => [LinkExpressionInput])
|
|
95
|
+
links: LinkExpressionInput[]
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
@InputType()
|
|
99
|
+
export class PerspectiveUnsignedInput {
|
|
100
|
+
@Field(type => [LinkInput])
|
|
101
|
+
links: LinkInput[]
|
|
102
|
+
|
|
103
|
+
constructor(links?: LinkInput[]) {
|
|
104
|
+
if(links)
|
|
105
|
+
this.links = links
|
|
106
|
+
else
|
|
107
|
+
this.links = []
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
static fromLink(link: Link): PerspectiveUnsignedInput {
|
|
111
|
+
let obj = new PerspectiveUnsignedInput()
|
|
112
|
+
obj.links.push(link)
|
|
113
|
+
return obj
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
@ObjectType()
|
|
118
|
+
export class PerspectiveExpression extends ExpressionGeneric(Perspective) {};
|