@coasys/ad4m 0.12.0-rc1-dev.2 → 0.12.0-rc1-dev.3
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 +6872 -5886
- package/lib/index.js +6868 -5874
- 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 +3737 -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 +4361 -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,303 +1,265 @@
|
|
|
1
|
-
import { SHACLShape } from
|
|
2
|
-
describe(
|
|
3
|
-
describe(
|
|
4
|
-
it(
|
|
5
|
-
const shape = new SHACLShape(
|
|
1
|
+
import { SHACLShape } from './SHACLShape';
|
|
2
|
+
describe('SHACLShape', () => {
|
|
3
|
+
describe('toLinks()', () => {
|
|
4
|
+
it('creates basic shape links', () => {
|
|
5
|
+
const shape = new SHACLShape('recipe://Recipe');
|
|
6
6
|
const links = shape.toLinks();
|
|
7
7
|
// Should have targetClass link
|
|
8
|
-
const targetClassLink = links.find(
|
|
8
|
+
const targetClassLink = links.find(l => l.predicate === 'sh://targetClass');
|
|
9
9
|
expect(targetClassLink).toBeDefined();
|
|
10
|
-
expect(targetClassLink.source).toBe(
|
|
11
|
-
expect(targetClassLink.target).toBe(
|
|
10
|
+
expect(targetClassLink.source).toBe('recipe://RecipeShape');
|
|
11
|
+
expect(targetClassLink.target).toBe('recipe://Recipe');
|
|
12
12
|
});
|
|
13
|
-
it(
|
|
14
|
-
const shape = new SHACLShape(
|
|
13
|
+
it('creates property shape links with named URIs', () => {
|
|
14
|
+
const shape = new SHACLShape('recipe://Recipe');
|
|
15
15
|
const prop = {
|
|
16
|
-
name:
|
|
17
|
-
path:
|
|
18
|
-
datatype:
|
|
16
|
+
name: 'name',
|
|
17
|
+
path: 'recipe://name',
|
|
18
|
+
datatype: 'xsd:string',
|
|
19
19
|
minCount: 1,
|
|
20
20
|
maxCount: 1,
|
|
21
21
|
};
|
|
22
22
|
shape.addProperty(prop);
|
|
23
23
|
const links = shape.toLinks();
|
|
24
24
|
// Property shape should use named URI
|
|
25
|
-
const propLink = links.find(
|
|
25
|
+
const propLink = links.find(l => l.predicate === 'sh://property');
|
|
26
26
|
expect(propLink).toBeDefined();
|
|
27
|
-
expect(propLink.target).toBe(
|
|
27
|
+
expect(propLink.target).toBe('recipe://Recipe.name'); // Named URI, not blank node
|
|
28
28
|
// Path link
|
|
29
|
-
const pathLink = links.find(
|
|
29
|
+
const pathLink = links.find(l => l.source === 'recipe://Recipe.name' && l.predicate === 'sh://path');
|
|
30
30
|
expect(pathLink).toBeDefined();
|
|
31
|
-
expect(pathLink.target).toBe(
|
|
31
|
+
expect(pathLink.target).toBe('recipe://name');
|
|
32
32
|
// Datatype link
|
|
33
|
-
const datatypeLink = links.find(
|
|
34
|
-
l.predicate === "sh://datatype");
|
|
33
|
+
const datatypeLink = links.find(l => l.source === 'recipe://Recipe.name' && l.predicate === 'sh://datatype');
|
|
35
34
|
expect(datatypeLink).toBeDefined();
|
|
36
|
-
expect(datatypeLink.target).toBe(
|
|
35
|
+
expect(datatypeLink.target).toBe('xsd:string');
|
|
37
36
|
// Cardinality links
|
|
38
|
-
const minCountLink = links.find(
|
|
39
|
-
l.predicate === "sh://minCount");
|
|
37
|
+
const minCountLink = links.find(l => l.source === 'recipe://Recipe.name' && l.predicate === 'sh://minCount');
|
|
40
38
|
expect(minCountLink).toBeDefined();
|
|
41
|
-
expect(minCountLink.target).toContain(
|
|
42
|
-
const maxCountLink = links.find(
|
|
43
|
-
l.predicate === "sh://maxCount");
|
|
39
|
+
expect(minCountLink.target).toContain('1');
|
|
40
|
+
const maxCountLink = links.find(l => l.source === 'recipe://Recipe.name' && l.predicate === 'sh://maxCount');
|
|
44
41
|
expect(maxCountLink).toBeDefined();
|
|
45
|
-
expect(maxCountLink.target).toContain(
|
|
42
|
+
expect(maxCountLink.target).toContain('1');
|
|
46
43
|
});
|
|
47
|
-
it(
|
|
48
|
-
const shape = new SHACLShape(
|
|
44
|
+
it('creates action links', () => {
|
|
45
|
+
const shape = new SHACLShape('recipe://Recipe');
|
|
49
46
|
const setterAction = {
|
|
50
|
-
action:
|
|
51
|
-
source:
|
|
52
|
-
predicate:
|
|
53
|
-
target:
|
|
47
|
+
action: 'addLink',
|
|
48
|
+
source: 'this',
|
|
49
|
+
predicate: 'recipe://name',
|
|
50
|
+
target: 'value',
|
|
54
51
|
};
|
|
55
52
|
const prop = {
|
|
56
|
-
name:
|
|
57
|
-
path:
|
|
53
|
+
name: 'title',
|
|
54
|
+
path: 'recipe://title',
|
|
58
55
|
setter: [setterAction],
|
|
59
56
|
};
|
|
60
57
|
shape.addProperty(prop);
|
|
61
58
|
const links = shape.toLinks();
|
|
62
59
|
// Setter action link
|
|
63
|
-
const setterLink = links.find(
|
|
64
|
-
l.predicate === "ad4m://setter");
|
|
60
|
+
const setterLink = links.find(l => l.source === 'recipe://Recipe.title' && l.predicate === 'ad4m://setter');
|
|
65
61
|
expect(setterLink).toBeDefined();
|
|
66
|
-
expect(setterLink.target).toContain(
|
|
62
|
+
expect(setterLink.target).toContain('addLink');
|
|
67
63
|
});
|
|
68
|
-
it(
|
|
69
|
-
const shape = new SHACLShape(
|
|
70
|
-
shape.constructor_actions = [
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
predicate: "ad4m://type",
|
|
83
|
-
target: "recipe://Recipe",
|
|
84
|
-
},
|
|
85
|
-
];
|
|
64
|
+
it('includes constructor and destructor actions', () => {
|
|
65
|
+
const shape = new SHACLShape('recipe://Recipe');
|
|
66
|
+
shape.constructor_actions = [{
|
|
67
|
+
action: 'addLink',
|
|
68
|
+
source: 'this',
|
|
69
|
+
predicate: 'ad4m://type',
|
|
70
|
+
target: 'recipe://Recipe',
|
|
71
|
+
}];
|
|
72
|
+
shape.destructor_actions = [{
|
|
73
|
+
action: 'removeLink',
|
|
74
|
+
source: 'this',
|
|
75
|
+
predicate: 'ad4m://type',
|
|
76
|
+
target: 'recipe://Recipe',
|
|
77
|
+
}];
|
|
86
78
|
const links = shape.toLinks();
|
|
87
|
-
const constructorLink = links.find(
|
|
79
|
+
const constructorLink = links.find(l => l.predicate === 'ad4m://constructor');
|
|
88
80
|
expect(constructorLink).toBeDefined();
|
|
89
|
-
expect(constructorLink.target).toContain(
|
|
90
|
-
const destructorLink = links.find(
|
|
81
|
+
expect(constructorLink.target).toContain('addLink');
|
|
82
|
+
const destructorLink = links.find(l => l.predicate === 'ad4m://destructor');
|
|
91
83
|
expect(destructorLink).toBeDefined();
|
|
92
|
-
expect(destructorLink.target).toContain(
|
|
84
|
+
expect(destructorLink.target).toContain('removeLink');
|
|
93
85
|
});
|
|
94
86
|
});
|
|
95
|
-
describe(
|
|
96
|
-
it(
|
|
97
|
-
const originalShape = new SHACLShape(
|
|
87
|
+
describe('fromLinks()', () => {
|
|
88
|
+
it('reconstructs shape from links', () => {
|
|
89
|
+
const originalShape = new SHACLShape('recipe://Recipe');
|
|
98
90
|
originalShape.addProperty({
|
|
99
|
-
name:
|
|
100
|
-
path:
|
|
101
|
-
datatype:
|
|
91
|
+
name: 'name',
|
|
92
|
+
path: 'recipe://name',
|
|
93
|
+
datatype: 'xsd:string',
|
|
102
94
|
minCount: 1,
|
|
103
95
|
});
|
|
104
96
|
const links = originalShape.toLinks();
|
|
105
|
-
const reconstructed = SHACLShape.fromLinks(links,
|
|
106
|
-
expect(reconstructed.targetClass).toBe(
|
|
97
|
+
const reconstructed = SHACLShape.fromLinks(links, 'recipe://RecipeShape');
|
|
98
|
+
expect(reconstructed.targetClass).toBe('recipe://Recipe');
|
|
107
99
|
expect(reconstructed.properties.length).toBe(1);
|
|
108
|
-
expect(reconstructed.properties[0].path).toBe(
|
|
109
|
-
expect(reconstructed.properties[0].datatype).toBe(
|
|
100
|
+
expect(reconstructed.properties[0].path).toBe('recipe://name');
|
|
101
|
+
expect(reconstructed.properties[0].datatype).toBe('xsd:string');
|
|
110
102
|
expect(reconstructed.properties[0].minCount).toBe(1);
|
|
111
103
|
});
|
|
112
|
-
it(
|
|
113
|
-
const originalShape = new SHACLShape(
|
|
104
|
+
it('handles multiple properties', () => {
|
|
105
|
+
const originalShape = new SHACLShape('recipe://Recipe');
|
|
114
106
|
originalShape.addProperty({
|
|
115
|
-
name:
|
|
116
|
-
path:
|
|
117
|
-
datatype:
|
|
107
|
+
name: 'name',
|
|
108
|
+
path: 'recipe://name',
|
|
109
|
+
datatype: 'xsd:string',
|
|
118
110
|
});
|
|
119
111
|
originalShape.addProperty({
|
|
120
|
-
name:
|
|
121
|
-
path:
|
|
122
|
-
datatype:
|
|
112
|
+
name: 'servings',
|
|
113
|
+
path: 'recipe://servings',
|
|
114
|
+
datatype: 'xsd:integer',
|
|
123
115
|
});
|
|
124
116
|
const links = originalShape.toLinks();
|
|
125
|
-
const reconstructed = SHACLShape.fromLinks(links,
|
|
117
|
+
const reconstructed = SHACLShape.fromLinks(links, 'recipe://RecipeShape');
|
|
126
118
|
expect(reconstructed.properties.length).toBe(2);
|
|
127
|
-
const nameProp = reconstructed.properties.find(
|
|
128
|
-
const servingsProp = reconstructed.properties.find(
|
|
119
|
+
const nameProp = reconstructed.properties.find(p => p.path === 'recipe://name');
|
|
120
|
+
const servingsProp = reconstructed.properties.find(p => p.path === 'recipe://servings');
|
|
129
121
|
expect(nameProp).toBeDefined();
|
|
130
122
|
expect(servingsProp).toBeDefined();
|
|
131
|
-
expect(nameProp.datatype).toBe(
|
|
132
|
-
expect(servingsProp.datatype).toBe(
|
|
123
|
+
expect(nameProp.datatype).toBe('xsd:string');
|
|
124
|
+
expect(servingsProp.datatype).toBe('xsd:integer');
|
|
133
125
|
});
|
|
134
|
-
it(
|
|
135
|
-
const originalShape = new SHACLShape(
|
|
126
|
+
it('reconstructs action arrays', () => {
|
|
127
|
+
const originalShape = new SHACLShape('recipe://Recipe');
|
|
136
128
|
const setterAction = {
|
|
137
|
-
action:
|
|
138
|
-
source:
|
|
139
|
-
predicate:
|
|
140
|
-
target:
|
|
129
|
+
action: 'addLink',
|
|
130
|
+
source: 'this',
|
|
131
|
+
predicate: 'recipe://name',
|
|
132
|
+
target: 'value',
|
|
141
133
|
};
|
|
142
134
|
originalShape.addProperty({
|
|
143
|
-
name:
|
|
144
|
-
path:
|
|
135
|
+
name: 'name',
|
|
136
|
+
path: 'recipe://name',
|
|
145
137
|
setter: [setterAction],
|
|
146
138
|
});
|
|
147
139
|
const links = originalShape.toLinks();
|
|
148
|
-
const reconstructed = SHACLShape.fromLinks(links,
|
|
140
|
+
const reconstructed = SHACLShape.fromLinks(links, 'recipe://RecipeShape');
|
|
149
141
|
expect(reconstructed.properties[0].setter).toBeDefined();
|
|
150
142
|
expect(reconstructed.properties[0].setter.length).toBe(1);
|
|
151
|
-
expect(reconstructed.properties[0].setter[0].action).toBe(
|
|
143
|
+
expect(reconstructed.properties[0].setter[0].action).toBe('addLink');
|
|
152
144
|
});
|
|
153
145
|
});
|
|
154
|
-
describe(
|
|
155
|
-
it(
|
|
156
|
-
const original = new SHACLShape(
|
|
146
|
+
describe('round-trip serialization', () => {
|
|
147
|
+
it('preserves all property attributes', () => {
|
|
148
|
+
const original = new SHACLShape('test://Model');
|
|
157
149
|
original.addProperty({
|
|
158
|
-
name:
|
|
159
|
-
path:
|
|
160
|
-
datatype:
|
|
161
|
-
nodeKind:
|
|
150
|
+
name: 'field',
|
|
151
|
+
path: 'test://field',
|
|
152
|
+
datatype: 'xsd:string',
|
|
153
|
+
nodeKind: 'Literal',
|
|
162
154
|
minCount: 0,
|
|
163
155
|
maxCount: 5,
|
|
164
|
-
pattern:
|
|
156
|
+
pattern: '^[a-z]+$',
|
|
165
157
|
minInclusive: 10,
|
|
166
158
|
maxInclusive: 100,
|
|
167
|
-
hasValue:
|
|
168
|
-
resolveLanguage:
|
|
159
|
+
hasValue: 'expectedValue',
|
|
160
|
+
resolveLanguage: 'test://language',
|
|
169
161
|
local: true,
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
predicate: "test://field",
|
|
175
|
-
target: "value",
|
|
176
|
-
},
|
|
177
|
-
],
|
|
178
|
-
adder: [
|
|
179
|
-
{
|
|
180
|
-
action: "addLink",
|
|
181
|
-
source: "this",
|
|
182
|
-
predicate: "test://items",
|
|
183
|
-
target: "value",
|
|
184
|
-
},
|
|
185
|
-
],
|
|
186
|
-
remover: [
|
|
187
|
-
{
|
|
188
|
-
action: "removeLink",
|
|
189
|
-
source: "this",
|
|
190
|
-
predicate: "test://items",
|
|
191
|
-
target: "value",
|
|
192
|
-
},
|
|
193
|
-
],
|
|
162
|
+
writable: true,
|
|
163
|
+
setter: [{ action: 'addLink', source: 'this', predicate: 'test://field', target: 'value' }],
|
|
164
|
+
adder: [{ action: 'addLink', source: 'this', predicate: 'test://items', target: 'value' }],
|
|
165
|
+
remover: [{ action: 'removeLink', source: 'this', predicate: 'test://items', target: 'value' }],
|
|
194
166
|
});
|
|
195
167
|
const links = original.toLinks();
|
|
196
|
-
const reconstructed = SHACLShape.fromLinks(links,
|
|
168
|
+
const reconstructed = SHACLShape.fromLinks(links, 'test://ModelShape');
|
|
197
169
|
const prop = reconstructed.properties[0];
|
|
198
|
-
expect(prop.path).toBe(
|
|
199
|
-
expect(prop.datatype).toBe(
|
|
200
|
-
expect(prop.nodeKind).toBe(
|
|
170
|
+
expect(prop.path).toBe('test://field');
|
|
171
|
+
expect(prop.datatype).toBe('xsd:string');
|
|
172
|
+
expect(prop.nodeKind).toBe('Literal');
|
|
201
173
|
expect(prop.minCount).toBe(0);
|
|
202
174
|
expect(prop.maxCount).toBe(5);
|
|
203
|
-
expect(prop.pattern).toBe(
|
|
175
|
+
expect(prop.pattern).toBe('^[a-z]+$');
|
|
204
176
|
expect(prop.minInclusive).toBe(10);
|
|
205
177
|
expect(prop.maxInclusive).toBe(100);
|
|
206
|
-
expect(prop.hasValue).toBe(
|
|
207
|
-
expect(prop.resolveLanguage).toBe(
|
|
178
|
+
expect(prop.hasValue).toBe('expectedValue');
|
|
179
|
+
expect(prop.resolveLanguage).toBe('test://language');
|
|
208
180
|
expect(prop.local).toBe(true);
|
|
209
|
-
expect(prop.
|
|
181
|
+
expect(prop.writable).toBe(true);
|
|
210
182
|
expect(prop.setter).toBeDefined();
|
|
211
183
|
expect(prop.adder).toBeDefined();
|
|
212
184
|
expect(prop.remover).toBeDefined();
|
|
213
185
|
});
|
|
214
|
-
it(
|
|
215
|
-
const original = new SHACLShape(
|
|
186
|
+
it('preserves constructor and destructor actions', () => {
|
|
187
|
+
const original = new SHACLShape('test://Model');
|
|
216
188
|
original.constructor_actions = [
|
|
217
|
-
{
|
|
218
|
-
action: "addLink",
|
|
219
|
-
source: "this",
|
|
220
|
-
predicate: "rdf://type",
|
|
221
|
-
target: "test://Model",
|
|
222
|
-
},
|
|
189
|
+
{ action: 'addLink', source: 'this', predicate: 'rdf://type', target: 'test://Model' }
|
|
223
190
|
];
|
|
224
191
|
original.destructor_actions = [
|
|
225
|
-
{
|
|
226
|
-
action: "removeLink",
|
|
227
|
-
source: "this",
|
|
228
|
-
predicate: "rdf://type",
|
|
229
|
-
target: "test://Model",
|
|
230
|
-
},
|
|
192
|
+
{ action: 'removeLink', source: 'this', predicate: 'rdf://type', target: 'test://Model' }
|
|
231
193
|
];
|
|
232
194
|
const links = original.toLinks();
|
|
233
|
-
const reconstructed = SHACLShape.fromLinks(links,
|
|
195
|
+
const reconstructed = SHACLShape.fromLinks(links, 'test://ModelShape');
|
|
234
196
|
expect(reconstructed.constructor_actions).toBeDefined();
|
|
235
197
|
expect(reconstructed.constructor_actions.length).toBe(1);
|
|
236
|
-
expect(reconstructed.constructor_actions[0].action).toBe(
|
|
198
|
+
expect(reconstructed.constructor_actions[0].action).toBe('addLink');
|
|
237
199
|
expect(reconstructed.destructor_actions).toBeDefined();
|
|
238
200
|
expect(reconstructed.destructor_actions.length).toBe(1);
|
|
239
|
-
expect(reconstructed.destructor_actions[0].action).toBe(
|
|
201
|
+
expect(reconstructed.destructor_actions[0].action).toBe('removeLink');
|
|
240
202
|
});
|
|
241
203
|
});
|
|
242
|
-
describe(
|
|
243
|
-
it(
|
|
244
|
-
const shape = new SHACLShape(
|
|
204
|
+
describe('edge cases', () => {
|
|
205
|
+
it('handles empty shape', () => {
|
|
206
|
+
const shape = new SHACLShape('test://Empty');
|
|
245
207
|
const links = shape.toLinks();
|
|
246
208
|
expect(links.length).toBeGreaterThanOrEqual(1); // At least targetClass link
|
|
247
|
-
const reconstructed = SHACLShape.fromLinks(links,
|
|
248
|
-
expect(reconstructed.targetClass).toBe(
|
|
209
|
+
const reconstructed = SHACLShape.fromLinks(links, 'test://EmptyShape');
|
|
210
|
+
expect(reconstructed.targetClass).toBe('test://Empty');
|
|
249
211
|
expect(reconstructed.properties.length).toBe(0);
|
|
250
212
|
});
|
|
251
|
-
it(
|
|
252
|
-
const shape = new SHACLShape(
|
|
213
|
+
it('handles URI with hash fragment', () => {
|
|
214
|
+
const shape = new SHACLShape('https://example.com/vocab#Recipe');
|
|
253
215
|
const links = shape.toLinks();
|
|
254
|
-
const targetClassLink = links.find(
|
|
255
|
-
expect(targetClassLink.source).toBe(
|
|
216
|
+
const targetClassLink = links.find(l => l.predicate === 'sh://targetClass');
|
|
217
|
+
expect(targetClassLink.source).toBe('https://example.com/vocab#RecipeShape');
|
|
256
218
|
});
|
|
257
|
-
it(
|
|
258
|
-
const shape = new SHACLShape(
|
|
219
|
+
it('falls back to blank nodes when property has no name', () => {
|
|
220
|
+
const shape = new SHACLShape('test://Model');
|
|
259
221
|
shape.addProperty({
|
|
260
|
-
path:
|
|
222
|
+
path: 'test://unnamed',
|
|
261
223
|
// No name property
|
|
262
224
|
});
|
|
263
225
|
const links = shape.toLinks();
|
|
264
|
-
const propLink = links.find(
|
|
226
|
+
const propLink = links.find(l => l.predicate === 'sh://property');
|
|
265
227
|
expect(propLink).toBeDefined();
|
|
266
228
|
// Should use blank node format when no name provided
|
|
267
229
|
expect(propLink.target).toMatch(/_:propShape\d+|test:\/\/Model\./);
|
|
268
230
|
});
|
|
269
231
|
});
|
|
270
|
-
describe(
|
|
271
|
-
it(
|
|
272
|
-
const original = new SHACLShape(
|
|
232
|
+
describe('toJSON/fromJSON', () => {
|
|
233
|
+
it('serializes and deserializes basic shape', () => {
|
|
234
|
+
const original = new SHACLShape('recipe://Recipe');
|
|
273
235
|
original.addProperty({
|
|
274
|
-
name:
|
|
275
|
-
path:
|
|
276
|
-
datatype:
|
|
236
|
+
name: 'name',
|
|
237
|
+
path: 'recipe://name',
|
|
238
|
+
datatype: 'xsd:string',
|
|
277
239
|
minCount: 1,
|
|
278
240
|
});
|
|
279
241
|
const json = original.toJSON();
|
|
280
242
|
const reconstructed = SHACLShape.fromJSON(json);
|
|
281
|
-
expect(reconstructed.targetClass).toBe(
|
|
243
|
+
expect(reconstructed.targetClass).toBe('recipe://Recipe');
|
|
282
244
|
expect(reconstructed.properties.length).toBe(1);
|
|
283
|
-
expect(reconstructed.properties[0].name).toBe(
|
|
284
|
-
expect(reconstructed.properties[0].path).toBe(
|
|
285
|
-
expect(reconstructed.properties[0].datatype).toBe(
|
|
245
|
+
expect(reconstructed.properties[0].name).toBe('name');
|
|
246
|
+
expect(reconstructed.properties[0].path).toBe('recipe://name');
|
|
247
|
+
expect(reconstructed.properties[0].datatype).toBe('xsd:string');
|
|
286
248
|
expect(reconstructed.properties[0].minCount).toBe(1);
|
|
287
249
|
});
|
|
288
|
-
it(
|
|
289
|
-
const original = new SHACLShape(
|
|
250
|
+
it('preserves nodeShapeUri in round-trip', () => {
|
|
251
|
+
const original = new SHACLShape('custom://CustomShape', 'recipe://Recipe');
|
|
290
252
|
const json = original.toJSON();
|
|
291
253
|
const reconstructed = SHACLShape.fromJSON(json);
|
|
292
|
-
expect(reconstructed.nodeShapeUri).toBe(
|
|
293
|
-
expect(reconstructed.targetClass).toBe(
|
|
254
|
+
expect(reconstructed.nodeShapeUri).toBe('custom://CustomShape');
|
|
255
|
+
expect(reconstructed.targetClass).toBe('recipe://Recipe');
|
|
294
256
|
});
|
|
295
|
-
it(
|
|
296
|
-
const original = new SHACLShape(
|
|
257
|
+
it('preserves minInclusive and maxInclusive', () => {
|
|
258
|
+
const original = new SHACLShape('test://Model');
|
|
297
259
|
original.addProperty({
|
|
298
|
-
name:
|
|
299
|
-
path:
|
|
300
|
-
datatype:
|
|
260
|
+
name: 'rating',
|
|
261
|
+
path: 'test://rating',
|
|
262
|
+
datatype: 'xsd:integer',
|
|
301
263
|
minInclusive: 1,
|
|
302
264
|
maxInclusive: 5,
|
|
303
265
|
});
|
|
@@ -306,96 +268,66 @@ describe("SHACLShape", () => {
|
|
|
306
268
|
expect(reconstructed.properties[0].minInclusive).toBe(1);
|
|
307
269
|
expect(reconstructed.properties[0].maxInclusive).toBe(5);
|
|
308
270
|
});
|
|
309
|
-
it(
|
|
310
|
-
const original = new SHACLShape(
|
|
271
|
+
it('preserves resolveLanguage', () => {
|
|
272
|
+
const original = new SHACLShape('test://Model');
|
|
311
273
|
original.addProperty({
|
|
312
|
-
name:
|
|
313
|
-
path:
|
|
314
|
-
resolveLanguage:
|
|
274
|
+
name: 'content',
|
|
275
|
+
path: 'test://content',
|
|
276
|
+
resolveLanguage: 'literal',
|
|
315
277
|
});
|
|
316
278
|
const json = original.toJSON();
|
|
317
279
|
const reconstructed = SHACLShape.fromJSON(json);
|
|
318
|
-
expect(reconstructed.properties[0].resolveLanguage).toBe(
|
|
280
|
+
expect(reconstructed.properties[0].resolveLanguage).toBe('literal');
|
|
319
281
|
});
|
|
320
|
-
it(
|
|
321
|
-
const original = new SHACLShape(
|
|
282
|
+
it('preserves constructor and destructor actions', () => {
|
|
283
|
+
const original = new SHACLShape('test://Model');
|
|
322
284
|
original.constructor_actions = [
|
|
323
|
-
{
|
|
324
|
-
action: "addLink",
|
|
325
|
-
source: "this",
|
|
326
|
-
predicate: "rdf://type",
|
|
327
|
-
target: "test://Model",
|
|
328
|
-
},
|
|
285
|
+
{ action: 'addLink', source: 'this', predicate: 'rdf://type', target: 'test://Model' }
|
|
329
286
|
];
|
|
330
287
|
original.destructor_actions = [
|
|
331
|
-
{
|
|
332
|
-
action: "removeLink",
|
|
333
|
-
source: "this",
|
|
334
|
-
predicate: "rdf://type",
|
|
335
|
-
target: "test://Model",
|
|
336
|
-
},
|
|
288
|
+
{ action: 'removeLink', source: 'this', predicate: 'rdf://type', target: 'test://Model' }
|
|
337
289
|
];
|
|
338
290
|
const json = original.toJSON();
|
|
339
291
|
const reconstructed = SHACLShape.fromJSON(json);
|
|
340
292
|
expect(reconstructed.constructor_actions).toEqual(original.constructor_actions);
|
|
341
293
|
expect(reconstructed.destructor_actions).toEqual(original.destructor_actions);
|
|
342
294
|
});
|
|
343
|
-
it(
|
|
344
|
-
const original = new SHACLShape(
|
|
295
|
+
it('preserves all property attributes', () => {
|
|
296
|
+
const original = new SHACLShape('test://Model');
|
|
345
297
|
original.addProperty({
|
|
346
|
-
name:
|
|
347
|
-
path:
|
|
348
|
-
datatype:
|
|
349
|
-
nodeKind:
|
|
298
|
+
name: 'field',
|
|
299
|
+
path: 'test://field',
|
|
300
|
+
datatype: 'xsd:string',
|
|
301
|
+
nodeKind: 'Literal',
|
|
350
302
|
minCount: 0,
|
|
351
303
|
maxCount: 5,
|
|
352
304
|
minInclusive: 0,
|
|
353
305
|
maxInclusive: 100,
|
|
354
|
-
pattern:
|
|
355
|
-
hasValue:
|
|
306
|
+
pattern: '^[a-z]+$',
|
|
307
|
+
hasValue: 'default',
|
|
356
308
|
local: true,
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
predicate: "test://field",
|
|
363
|
-
target: "value",
|
|
364
|
-
},
|
|
365
|
-
],
|
|
366
|
-
adder: [
|
|
367
|
-
{
|
|
368
|
-
action: "addLink",
|
|
369
|
-
source: "this",
|
|
370
|
-
predicate: "test://items",
|
|
371
|
-
target: "value",
|
|
372
|
-
},
|
|
373
|
-
],
|
|
374
|
-
remover: [
|
|
375
|
-
{
|
|
376
|
-
action: "removeLink",
|
|
377
|
-
source: "this",
|
|
378
|
-
predicate: "test://items",
|
|
379
|
-
target: "value",
|
|
380
|
-
},
|
|
381
|
-
],
|
|
309
|
+
writable: true,
|
|
310
|
+
resolveLanguage: 'literal',
|
|
311
|
+
setter: [{ action: 'addLink', source: 'this', predicate: 'test://field', target: 'value' }],
|
|
312
|
+
adder: [{ action: 'addLink', source: 'this', predicate: 'test://items', target: 'value' }],
|
|
313
|
+
remover: [{ action: 'removeLink', source: 'this', predicate: 'test://items', target: 'value' }],
|
|
382
314
|
});
|
|
383
315
|
const json = original.toJSON();
|
|
384
316
|
const reconstructed = SHACLShape.fromJSON(json);
|
|
385
317
|
const prop = reconstructed.properties[0];
|
|
386
|
-
expect(prop.name).toBe(
|
|
387
|
-
expect(prop.path).toBe(
|
|
388
|
-
expect(prop.datatype).toBe(
|
|
389
|
-
expect(prop.nodeKind).toBe(
|
|
318
|
+
expect(prop.name).toBe('field');
|
|
319
|
+
expect(prop.path).toBe('test://field');
|
|
320
|
+
expect(prop.datatype).toBe('xsd:string');
|
|
321
|
+
expect(prop.nodeKind).toBe('Literal');
|
|
390
322
|
expect(prop.minCount).toBe(0);
|
|
391
323
|
expect(prop.maxCount).toBe(5);
|
|
392
324
|
expect(prop.minInclusive).toBe(0);
|
|
393
325
|
expect(prop.maxInclusive).toBe(100);
|
|
394
|
-
expect(prop.pattern).toBe(
|
|
395
|
-
expect(prop.hasValue).toBe(
|
|
326
|
+
expect(prop.pattern).toBe('^[a-z]+$');
|
|
327
|
+
expect(prop.hasValue).toBe('default');
|
|
396
328
|
expect(prop.local).toBe(true);
|
|
397
|
-
expect(prop.
|
|
398
|
-
expect(prop.resolveLanguage).toBe(
|
|
329
|
+
expect(prop.writable).toBe(true);
|
|
330
|
+
expect(prop.resolveLanguage).toBe('literal');
|
|
399
331
|
expect(prop.setter).toEqual(original.properties[0].setter);
|
|
400
332
|
expect(prop.adder).toEqual(original.properties[0].adder);
|
|
401
333
|
expect(prop.remover).toEqual(original.properties[0].remover);
|
|
File without changes
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as src from "../node_modules/type-graphql/dist/index.js";
|
|
2
|
+
export declare const dummyValue = "";
|
|
3
|
+
export declare function dummyFn(): void;
|
|
4
|
+
export declare function dummyDecorator(): typeof dummyFn;
|
|
5
|
+
export declare const Arg: typeof src.Arg;
|
|
6
|
+
export declare const Args: typeof src.Args;
|
|
7
|
+
export declare const ArgsType: typeof src.ArgsType;
|
|
8
|
+
export declare const Authorized: typeof src.Authorized;
|
|
9
|
+
export declare const Ctx: typeof src.Ctx;
|
|
10
|
+
export declare const registerEnumType: typeof src.registerEnumType;
|
|
11
|
+
export declare const Field: typeof src.Field;
|
|
12
|
+
export declare const FieldResolver: typeof src.FieldResolver;
|
|
13
|
+
export declare const Info: typeof src.Info;
|
|
14
|
+
export declare const InputType: typeof src.InputType;
|
|
15
|
+
export declare const InterfaceType: typeof src.InterfaceType;
|
|
16
|
+
export declare const Mutation: typeof src.Mutation;
|
|
17
|
+
export declare const ObjectType: typeof src.ObjectType;
|
|
18
|
+
export declare const PubSub: typeof src.PubSub;
|
|
19
|
+
export declare const Query: typeof src.Query;
|
|
20
|
+
export declare const Resolver: typeof src.Resolver;
|
|
21
|
+
export declare const Root: typeof src.Root;
|
|
22
|
+
export declare const Subscription: typeof src.Subscription;
|
|
23
|
+
export declare const createUnionType: typeof src.createUnionType;
|
|
24
|
+
export declare const UseMiddleware: typeof src.UseMiddleware;
|
|
25
|
+
export declare const PubSubEngine: typeof src.PubSubEngine;
|
|
26
|
+
export declare class ClassType<t> {
|
|
27
|
+
}
|
|
28
|
+
export declare const Int: typeof src.Int;
|
|
29
|
+
export declare const Float: typeof src.Float;
|
|
30
|
+
export declare const ID: typeof src.ID;
|
|
31
|
+
export declare const GraphQLISODateTime: typeof src.GraphQLISODateTime;
|
|
32
|
+
export declare const GraphQLTimestamp: typeof src.GraphQLTimestamp;
|