@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.
Files changed (153) hide show
  1. package/jest.config.js +10 -3
  2. package/lib/index.cjs +6872 -5886
  3. package/lib/index.js +6868 -5874
  4. package/lib/src/Ad4mClient.d.ts +9 -16
  5. package/lib/src/Ad4mClient.js +46 -25
  6. package/lib/src/Literal.d.ts +1 -2
  7. package/lib/src/Literal.js +38 -35
  8. package/lib/src/SmartLiteral.d.ts +1 -2
  9. package/lib/src/SmartLiteral.js +30 -15
  10. package/lib/src/agent/AgentClient.d.ts +1 -4
  11. package/lib/src/agent/AgentClient.js +79 -99
  12. package/lib/src/ai/AIClient.d.ts +1 -2
  13. package/lib/src/ai/AIClient.js +224 -220
  14. package/lib/src/expression/ExpressionClient.d.ts +1 -1
  15. package/lib/src/expression/ExpressionClient.js +73 -86
  16. package/lib/src/index.d.ts +1 -1
  17. package/lib/src/index.js +1 -1
  18. package/lib/src/language/LanguageClient.d.ts +1 -1
  19. package/lib/src/language/LanguageClient.js +52 -52
  20. package/lib/src/model/Ad4mModel.d.ts +1351 -144
  21. package/lib/src/model/Ad4mModel.js +3737 -228
  22. package/lib/src/model/Ad4mModel.test.js +522 -979
  23. package/lib/src/model/Subject.d.ts +3 -3
  24. package/lib/src/model/Subject.js +25 -25
  25. package/lib/src/model/decorators.d.ts +444 -100
  26. package/lib/src/model/decorators.js +686 -321
  27. package/lib/src/model/util.d.ts +6 -6
  28. package/lib/src/model/util.js +24 -24
  29. package/lib/src/neighbourhood/NeighbourhoodClient.d.ts +1 -5
  30. package/lib/src/neighbourhood/NeighbourhoodClient.js +179 -242
  31. package/lib/src/neighbourhood/NeighbourhoodProxy.d.ts +1 -2
  32. package/lib/src/neighbourhood/NeighbourhoodProxy.js +28 -13
  33. package/lib/src/neighbourhood/NeighbourhoodProxy.test.js +5 -1
  34. package/lib/src/perspectives/PerspectiveClient.d.ts +9 -9
  35. package/lib/src/perspectives/PerspectiveClient.js +240 -316
  36. package/lib/src/perspectives/PerspectiveProxy.d.ts +99 -61
  37. package/lib/src/perspectives/PerspectiveProxy.js +485 -832
  38. package/lib/src/runtime/RuntimeClient.d.ts +1 -5
  39. package/lib/src/runtime/RuntimeClient.js +238 -412
  40. package/lib/src/shacl/SHACLFlow.test.js +105 -164
  41. package/lib/src/shacl/SHACLShape.d.ts +12 -17
  42. package/lib/src/shacl/SHACLShape.js +115 -128
  43. package/lib/src/shacl/SHACLShape.test.js +176 -244
  44. package/lib/src/shims/reflect-metadata.d.ts +0 -0
  45. package/lib/src/shims/type-graphql.d.ts +32 -0
  46. package/lib/src/src/Ad4mClient.d.ts +28 -0
  47. package/lib/src/src/Address.d.ts +1 -0
  48. package/lib/src/src/DID.d.ts +1 -0
  49. package/lib/src/src/Exception.d.ts +7 -0
  50. package/lib/src/src/Literal.d.ts +7 -0
  51. package/lib/src/src/PubSub.d.ts +17 -0
  52. package/lib/src/src/SmartLiteral.d.ts +12 -0
  53. package/lib/src/src/agent/Agent.d.ts +110 -0
  54. package/lib/src/src/agent/AgentClient.d.ts +62 -0
  55. package/lib/src/src/agent/AgentResolver.d.ts +30 -0
  56. package/lib/src/src/agent/AgentStatus.d.ts +8 -0
  57. package/lib/src/src/ai/AIClient.d.ts +32 -0
  58. package/lib/src/src/ai/AIResolver.d.ts +75 -0
  59. package/lib/src/src/ai/Tasks.d.ts +37 -0
  60. package/lib/src/src/buildSchema.d.ts +1 -0
  61. package/lib/src/src/expression/Expression.d.ts +28 -0
  62. package/lib/src/src/expression/ExpressionClient.d.ts +13 -0
  63. package/lib/src/src/expression/ExpressionRef.d.ts +9 -0
  64. package/lib/src/src/expression/ExpressionResolver.d.ts +10 -0
  65. package/lib/src/src/index.d.ts +35 -0
  66. package/lib/src/src/jestSetup.d.ts +1 -0
  67. package/lib/src/src/language/Icon.d.ts +4 -0
  68. package/lib/src/src/language/Language.d.ts +206 -0
  69. package/lib/src/src/language/LanguageClient.d.ts +17 -0
  70. package/lib/src/src/language/LanguageContext.d.ts +37 -0
  71. package/lib/src/src/language/LanguageHandle.d.ts +9 -0
  72. package/lib/src/src/language/LanguageMeta.d.ts +35 -0
  73. package/lib/src/src/language/LanguageRef.d.ts +6 -0
  74. package/lib/src/src/language/LanguageResolver.d.ts +19 -0
  75. package/lib/src/src/links/Links.d.ts +39 -0
  76. package/lib/src/src/links/Links.test.d.ts +1 -0
  77. package/lib/src/src/model/Ad4mModel.d.ts +1438 -0
  78. package/lib/src/src/model/Ad4mModel.test.d.ts +1 -0
  79. package/lib/src/src/model/Subject.d.ts +25 -0
  80. package/lib/src/src/model/decorators.d.ts +545 -0
  81. package/lib/src/src/model/util.d.ts +12 -0
  82. package/lib/src/src/neighbourhood/Neighbourhood.d.ts +10 -0
  83. package/lib/src/src/neighbourhood/NeighbourhoodClient.d.ts +25 -0
  84. package/lib/src/src/neighbourhood/NeighbourhoodProxy.d.ts +19 -0
  85. package/lib/src/src/neighbourhood/NeighbourhoodProxy.test.d.ts +1 -0
  86. package/lib/src/src/neighbourhood/NeighbourhoodResolver.d.ts +24 -0
  87. package/lib/src/src/perspectives/LinkQuery.d.ts +11 -0
  88. package/lib/src/src/perspectives/Perspective.d.ts +38 -0
  89. package/lib/src/src/perspectives/Perspective.test.d.ts +1 -0
  90. package/lib/src/src/perspectives/PerspectiveClient.d.ts +97 -0
  91. package/lib/src/src/perspectives/PerspectiveDiff.d.ts +9 -0
  92. package/lib/src/src/perspectives/PerspectiveHandle.d.ts +18 -0
  93. package/lib/src/src/perspectives/PerspectiveProxy.d.ts +865 -0
  94. package/lib/src/src/perspectives/PerspectiveResolver.d.ts +57 -0
  95. package/lib/src/src/runtime/RuntimeClient.d.ts +56 -0
  96. package/lib/src/src/runtime/RuntimeResolver.d.ts +132 -0
  97. package/lib/src/src/shacl/SHACLFlow.d.ts +171 -0
  98. package/lib/src/src/shacl/SHACLFlow.test.d.ts +1 -0
  99. package/lib/src/src/shacl/SHACLShape.d.ts +117 -0
  100. package/lib/src/src/shacl/SHACLShape.test.d.ts +1 -0
  101. package/lib/src/src/typeDefs.d.ts +1 -0
  102. package/lib/src/src/unwrapApolloResult.d.ts +2 -0
  103. package/lib/src/src/utils.d.ts +25 -0
  104. package/lib/src/utils.d.ts +0 -8
  105. package/lib/src/utils.js +7 -21
  106. package/package.json +15 -14
  107. package/src/Ad4mClient.test.ts +1315 -1564
  108. package/src/Ad4mClient.ts +54 -55
  109. package/src/Literal.test.ts +26 -45
  110. package/src/Literal.ts +66 -82
  111. package/src/SmartLiteral.ts +58 -74
  112. package/src/agent/AgentClient.ts +99 -144
  113. package/src/ai/AIClient.ts +359 -409
  114. package/src/expression/ExpressionClient.ts +96 -142
  115. package/src/index.ts +1 -1
  116. package/src/language/LanguageClient.ts +113 -137
  117. package/src/model/Ad4mModel.test.ts +616 -1114
  118. package/src/model/Ad4mModel.ts +4361 -451
  119. package/src/model/Subject.ts +159 -0
  120. package/src/model/decorators.ts +1168 -667
  121. package/src/model/util.ts +54 -53
  122. package/src/neighbourhood/NeighbourhoodClient.ts +266 -392
  123. package/src/neighbourhood/NeighbourhoodProxy.test.ts +7 -3
  124. package/src/neighbourhood/NeighbourhoodProxy.ts +40 -58
  125. package/src/perspectives/PerspectiveClient.ts +540 -779
  126. package/src/perspectives/PerspectiveProxy.ts +2067 -2860
  127. package/src/runtime/RuntimeClient.ts +476 -775
  128. package/src/shacl/SHACLFlow.test.ts +129 -196
  129. package/src/shacl/SHACLShape.test.ts +190 -284
  130. package/src/shacl/SHACLShape.ts +200 -224
  131. package/src/utils.ts +17 -31
  132. package/tsconfig.json +10 -9
  133. package/src/model/IMPROVEMENTS.md +0 -482
  134. package/src/model/PREDICATE_COLLISION_FIX.md +0 -651
  135. package/src/model/README.md +0 -317
  136. package/src/model/SHACL_MUTATION_DECOUPLING.md +0 -356
  137. package/src/model/SUBSCRIPTION_STRATEGY.md +0 -317
  138. package/src/model/TC39_STAGE_3_DECORATORS.md +0 -609
  139. package/src/model/mutation.ts +0 -461
  140. package/src/model/parentUtils.ts +0 -91
  141. package/src/model/prolog/generatePrologFacts.ts +0 -176
  142. package/src/model/prolog/index.ts +0 -1
  143. package/src/model/query/ModelQueryBuilder.ts +0 -173
  144. package/src/model/query/fetchInstance.ts +0 -181
  145. package/src/model/query/hydration.ts +0 -273
  146. package/src/model/query/operations.ts +0 -510
  147. package/src/model/query/snapshot.ts +0 -126
  148. package/src/model/query/surrealCompiler.ts +0 -376
  149. package/src/model/schema/fromJSONSchema.ts +0 -411
  150. package/src/model/schema/metadata.ts +0 -148
  151. package/src/model/subscription.ts +0 -307
  152. package/src/model/transaction.ts +0 -60
  153. package/src/model/types.ts +0 -207
@@ -1,26 +1,24 @@
1
- import { SHACLShape, SHACLPropertyShape, AD4MAction } from "./SHACLShape";
1
+ import { SHACLShape, SHACLPropertyShape, AD4MAction } from './SHACLShape';
2
2
 
3
- describe("SHACLShape", () => {
4
- describe("toLinks()", () => {
5
- it("creates basic shape links", () => {
6
- const shape = new SHACLShape("recipe://Recipe");
3
+ describe('SHACLShape', () => {
4
+ describe('toLinks()', () => {
5
+ it('creates basic shape links', () => {
6
+ const shape = new SHACLShape('recipe://Recipe');
7
7
  const links = shape.toLinks();
8
8
 
9
9
  // Should have targetClass link
10
- const targetClassLink = links.find(
11
- (l) => l.predicate === "sh://targetClass",
12
- );
10
+ const targetClassLink = links.find(l => l.predicate === 'sh://targetClass');
13
11
  expect(targetClassLink).toBeDefined();
14
- expect(targetClassLink!.source).toBe("recipe://RecipeShape");
15
- expect(targetClassLink!.target).toBe("recipe://Recipe");
12
+ expect(targetClassLink!.source).toBe('recipe://RecipeShape');
13
+ expect(targetClassLink!.target).toBe('recipe://Recipe');
16
14
  });
17
15
 
18
- it("creates property shape links with named URIs", () => {
19
- const shape = new SHACLShape("recipe://Recipe");
16
+ it('creates property shape links with named URIs', () => {
17
+ const shape = new SHACLShape('recipe://Recipe');
20
18
  const prop: SHACLPropertyShape = {
21
- name: "name",
22
- path: "recipe://name",
23
- datatype: "xsd:string",
19
+ name: 'name',
20
+ path: 'recipe://name',
21
+ datatype: 'xsd:string',
24
22
  minCount: 1,
25
23
  maxCount: 1,
26
24
  };
@@ -28,351 +26,293 @@ describe("SHACLShape", () => {
28
26
  const links = shape.toLinks();
29
27
 
30
28
  // Property shape should use named URI
31
- const propLink = links.find((l) => l.predicate === "sh://property");
29
+ const propLink = links.find(l => l.predicate === 'sh://property');
32
30
  expect(propLink).toBeDefined();
33
- expect(propLink!.target).toBe("recipe://Recipe.name"); // Named URI, not blank node
31
+ expect(propLink!.target).toBe('recipe://Recipe.name'); // Named URI, not blank node
34
32
 
35
33
  // Path link
36
- const pathLink = links.find(
37
- (l) =>
38
- l.source === "recipe://Recipe.name" && l.predicate === "sh://path",
34
+ const pathLink = links.find(l =>
35
+ l.source === 'recipe://Recipe.name' && l.predicate === 'sh://path'
39
36
  );
40
37
  expect(pathLink).toBeDefined();
41
- expect(pathLink!.target).toBe("recipe://name");
38
+ expect(pathLink!.target).toBe('recipe://name');
42
39
 
43
40
  // Datatype link
44
- const datatypeLink = links.find(
45
- (l) =>
46
- l.source === "recipe://Recipe.name" &&
47
- l.predicate === "sh://datatype",
41
+ const datatypeLink = links.find(l =>
42
+ l.source === 'recipe://Recipe.name' && l.predicate === 'sh://datatype'
48
43
  );
49
44
  expect(datatypeLink).toBeDefined();
50
- expect(datatypeLink!.target).toBe("xsd:string");
45
+ expect(datatypeLink!.target).toBe('xsd:string');
51
46
 
52
47
  // Cardinality links
53
- const minCountLink = links.find(
54
- (l) =>
55
- l.source === "recipe://Recipe.name" &&
56
- l.predicate === "sh://minCount",
48
+ const minCountLink = links.find(l =>
49
+ l.source === 'recipe://Recipe.name' && l.predicate === 'sh://minCount'
57
50
  );
58
51
  expect(minCountLink).toBeDefined();
59
- expect(minCountLink!.target).toContain("1");
52
+ expect(minCountLink!.target).toContain('1');
60
53
 
61
- const maxCountLink = links.find(
62
- (l) =>
63
- l.source === "recipe://Recipe.name" &&
64
- l.predicate === "sh://maxCount",
54
+ const maxCountLink = links.find(l =>
55
+ l.source === 'recipe://Recipe.name' && l.predicate === 'sh://maxCount'
65
56
  );
66
57
  expect(maxCountLink).toBeDefined();
67
- expect(maxCountLink!.target).toContain("1");
58
+ expect(maxCountLink!.target).toContain('1');
68
59
  });
69
60
 
70
- it("creates action links", () => {
71
- const shape = new SHACLShape("recipe://Recipe");
61
+ it('creates action links', () => {
62
+ const shape = new SHACLShape('recipe://Recipe');
72
63
  const setterAction: AD4MAction = {
73
- action: "addLink",
74
- source: "this",
75
- predicate: "recipe://name",
76
- target: "value",
64
+ action: 'addLink',
65
+ source: 'this',
66
+ predicate: 'recipe://name',
67
+ target: 'value',
77
68
  };
78
69
  const prop: SHACLPropertyShape = {
79
- name: "title",
80
- path: "recipe://title",
70
+ name: 'title',
71
+ path: 'recipe://title',
81
72
  setter: [setterAction],
82
73
  };
83
74
  shape.addProperty(prop);
84
75
  const links = shape.toLinks();
85
76
 
86
77
  // Setter action link
87
- const setterLink = links.find(
88
- (l) =>
89
- l.source === "recipe://Recipe.title" &&
90
- l.predicate === "ad4m://setter",
78
+ const setterLink = links.find(l =>
79
+ l.source === 'recipe://Recipe.title' && l.predicate === 'ad4m://setter'
91
80
  );
92
81
  expect(setterLink).toBeDefined();
93
- expect(setterLink!.target).toContain("addLink");
82
+ expect(setterLink!.target).toContain('addLink');
94
83
  });
95
84
 
96
- it("includes constructor and destructor actions", () => {
97
- const shape = new SHACLShape("recipe://Recipe");
98
- shape.constructor_actions = [
99
- {
100
- action: "addLink",
101
- source: "this",
102
- predicate: "ad4m://type",
103
- target: "recipe://Recipe",
104
- },
105
- ];
106
- shape.destructor_actions = [
107
- {
108
- action: "removeLink",
109
- source: "this",
110
- predicate: "ad4m://type",
111
- target: "recipe://Recipe",
112
- },
113
- ];
85
+ it('includes constructor and destructor actions', () => {
86
+ const shape = new SHACLShape('recipe://Recipe');
87
+ shape.constructor_actions = [{
88
+ action: 'addLink',
89
+ source: 'this',
90
+ predicate: 'ad4m://type',
91
+ target: 'recipe://Recipe',
92
+ }];
93
+ shape.destructor_actions = [{
94
+ action: 'removeLink',
95
+ source: 'this',
96
+ predicate: 'ad4m://type',
97
+ target: 'recipe://Recipe',
98
+ }];
114
99
  const links = shape.toLinks();
115
100
 
116
- const constructorLink = links.find(
117
- (l) => l.predicate === "ad4m://constructor",
118
- );
101
+ const constructorLink = links.find(l => l.predicate === 'ad4m://constructor');
119
102
  expect(constructorLink).toBeDefined();
120
- expect(constructorLink!.target).toContain("addLink");
103
+ expect(constructorLink!.target).toContain('addLink');
121
104
 
122
- const destructorLink = links.find(
123
- (l) => l.predicate === "ad4m://destructor",
124
- );
105
+ const destructorLink = links.find(l => l.predicate === 'ad4m://destructor');
125
106
  expect(destructorLink).toBeDefined();
126
- expect(destructorLink!.target).toContain("removeLink");
107
+ expect(destructorLink!.target).toContain('removeLink');
127
108
  });
128
109
  });
129
110
 
130
- describe("fromLinks()", () => {
131
- it("reconstructs shape from links", () => {
132
- const originalShape = new SHACLShape("recipe://Recipe");
111
+ describe('fromLinks()', () => {
112
+ it('reconstructs shape from links', () => {
113
+ const originalShape = new SHACLShape('recipe://Recipe');
133
114
  originalShape.addProperty({
134
- name: "name",
135
- path: "recipe://name",
136
- datatype: "xsd:string",
115
+ name: 'name',
116
+ path: 'recipe://name',
117
+ datatype: 'xsd:string',
137
118
  minCount: 1,
138
119
  });
139
-
120
+
140
121
  const links = originalShape.toLinks();
141
- const reconstructed = SHACLShape.fromLinks(links, "recipe://RecipeShape");
122
+ const reconstructed = SHACLShape.fromLinks(links, 'recipe://RecipeShape');
142
123
 
143
- expect(reconstructed.targetClass).toBe("recipe://Recipe");
124
+ expect(reconstructed.targetClass).toBe('recipe://Recipe');
144
125
  expect(reconstructed.properties.length).toBe(1);
145
- expect(reconstructed.properties[0].path).toBe("recipe://name");
146
- expect(reconstructed.properties[0].datatype).toBe("xsd:string");
126
+ expect(reconstructed.properties[0].path).toBe('recipe://name');
127
+ expect(reconstructed.properties[0].datatype).toBe('xsd:string');
147
128
  expect(reconstructed.properties[0].minCount).toBe(1);
148
129
  });
149
130
 
150
- it("handles multiple properties", () => {
151
- const originalShape = new SHACLShape("recipe://Recipe");
131
+ it('handles multiple properties', () => {
132
+ const originalShape = new SHACLShape('recipe://Recipe');
152
133
  originalShape.addProperty({
153
- name: "name",
154
- path: "recipe://name",
155
- datatype: "xsd:string",
134
+ name: 'name',
135
+ path: 'recipe://name',
136
+ datatype: 'xsd:string',
156
137
  });
157
138
  originalShape.addProperty({
158
- name: "servings",
159
- path: "recipe://servings",
160
- datatype: "xsd:integer",
139
+ name: 'servings',
140
+ path: 'recipe://servings',
141
+ datatype: 'xsd:integer',
161
142
  });
162
-
143
+
163
144
  const links = originalShape.toLinks();
164
- const reconstructed = SHACLShape.fromLinks(links, "recipe://RecipeShape");
145
+ const reconstructed = SHACLShape.fromLinks(links, 'recipe://RecipeShape');
165
146
 
166
147
  expect(reconstructed.properties.length).toBe(2);
167
- const nameProp = reconstructed.properties.find(
168
- (p) => p.path === "recipe://name",
169
- );
170
- const servingsProp = reconstructed.properties.find(
171
- (p) => p.path === "recipe://servings",
172
- );
148
+ const nameProp = reconstructed.properties.find(p => p.path === 'recipe://name');
149
+ const servingsProp = reconstructed.properties.find(p => p.path === 'recipe://servings');
173
150
  expect(nameProp).toBeDefined();
174
151
  expect(servingsProp).toBeDefined();
175
- expect(nameProp!.datatype).toBe("xsd:string");
176
- expect(servingsProp!.datatype).toBe("xsd:integer");
152
+ expect(nameProp!.datatype).toBe('xsd:string');
153
+ expect(servingsProp!.datatype).toBe('xsd:integer');
177
154
  });
178
155
 
179
- it("reconstructs action arrays", () => {
180
- const originalShape = new SHACLShape("recipe://Recipe");
156
+ it('reconstructs action arrays', () => {
157
+ const originalShape = new SHACLShape('recipe://Recipe');
181
158
  const setterAction: AD4MAction = {
182
- action: "addLink",
183
- source: "this",
184
- predicate: "recipe://name",
185
- target: "value",
159
+ action: 'addLink',
160
+ source: 'this',
161
+ predicate: 'recipe://name',
162
+ target: 'value',
186
163
  };
187
164
  originalShape.addProperty({
188
- name: "name",
189
- path: "recipe://name",
165
+ name: 'name',
166
+ path: 'recipe://name',
190
167
  setter: [setterAction],
191
168
  });
192
-
169
+
193
170
  const links = originalShape.toLinks();
194
- const reconstructed = SHACLShape.fromLinks(links, "recipe://RecipeShape");
171
+ const reconstructed = SHACLShape.fromLinks(links, 'recipe://RecipeShape');
195
172
 
196
173
  expect(reconstructed.properties[0].setter).toBeDefined();
197
174
  expect(reconstructed.properties[0].setter!.length).toBe(1);
198
- expect(reconstructed.properties[0].setter![0].action).toBe("addLink");
175
+ expect(reconstructed.properties[0].setter![0].action).toBe('addLink');
199
176
  });
200
177
  });
201
178
 
202
- describe("round-trip serialization", () => {
203
- it("preserves all property attributes", () => {
204
- const original = new SHACLShape("test://Model");
179
+ describe('round-trip serialization', () => {
180
+ it('preserves all property attributes', () => {
181
+ const original = new SHACLShape('test://Model');
205
182
  original.addProperty({
206
- name: "field",
207
- path: "test://field",
208
- datatype: "xsd:string",
209
- nodeKind: "Literal",
183
+ name: 'field',
184
+ path: 'test://field',
185
+ datatype: 'xsd:string',
186
+ nodeKind: 'Literal',
210
187
  minCount: 0,
211
188
  maxCount: 5,
212
- pattern: "^[a-z]+$",
189
+ pattern: '^[a-z]+$',
213
190
  minInclusive: 10,
214
191
  maxInclusive: 100,
215
- hasValue: "expectedValue",
216
- resolveLanguage: "test://language",
192
+ hasValue: 'expectedValue',
193
+ resolveLanguage: 'test://language',
217
194
  local: true,
218
- setter: [
219
- {
220
- action: "addLink",
221
- source: "this",
222
- predicate: "test://field",
223
- target: "value",
224
- },
225
- ],
226
- adder: [
227
- {
228
- action: "addLink",
229
- source: "this",
230
- predicate: "test://items",
231
- target: "value",
232
- },
233
- ],
234
- remover: [
235
- {
236
- action: "removeLink",
237
- source: "this",
238
- predicate: "test://items",
239
- target: "value",
240
- },
241
- ],
195
+ writable: true,
196
+ setter: [{ action: 'addLink', source: 'this', predicate: 'test://field', target: 'value' }],
197
+ adder: [{ action: 'addLink', source: 'this', predicate: 'test://items', target: 'value' }],
198
+ remover: [{ action: 'removeLink', source: 'this', predicate: 'test://items', target: 'value' }],
242
199
  });
243
200
 
244
201
  const links = original.toLinks();
245
- const reconstructed = SHACLShape.fromLinks(links, "test://ModelShape");
202
+ const reconstructed = SHACLShape.fromLinks(links, 'test://ModelShape');
246
203
 
247
204
  const prop = reconstructed.properties[0];
248
- expect(prop.path).toBe("test://field");
249
- expect(prop.datatype).toBe("xsd:string");
250
- expect(prop.nodeKind).toBe("Literal");
205
+ expect(prop.path).toBe('test://field');
206
+ expect(prop.datatype).toBe('xsd:string');
207
+ expect(prop.nodeKind).toBe('Literal');
251
208
  expect(prop.minCount).toBe(0);
252
209
  expect(prop.maxCount).toBe(5);
253
- expect(prop.pattern).toBe("^[a-z]+$");
210
+ expect(prop.pattern).toBe('^[a-z]+$');
254
211
  expect(prop.minInclusive).toBe(10);
255
212
  expect(prop.maxInclusive).toBe(100);
256
- expect(prop.hasValue).toBe("expectedValue");
257
- expect(prop.resolveLanguage).toBe("test://language");
213
+ expect(prop.hasValue).toBe('expectedValue');
214
+ expect(prop.resolveLanguage).toBe('test://language');
258
215
  expect(prop.local).toBe(true);
259
- expect(prop.readOnly).toBeFalsy();
216
+ expect(prop.writable).toBe(true);
260
217
  expect(prop.setter).toBeDefined();
261
218
  expect(prop.adder).toBeDefined();
262
219
  expect(prop.remover).toBeDefined();
263
220
  });
264
221
 
265
- it("preserves constructor and destructor actions", () => {
266
- const original = new SHACLShape("test://Model");
222
+ it('preserves constructor and destructor actions', () => {
223
+ const original = new SHACLShape('test://Model');
267
224
  original.constructor_actions = [
268
- {
269
- action: "addLink",
270
- source: "this",
271
- predicate: "rdf://type",
272
- target: "test://Model",
273
- },
225
+ { action: 'addLink', source: 'this', predicate: 'rdf://type', target: 'test://Model' }
274
226
  ];
275
227
  original.destructor_actions = [
276
- {
277
- action: "removeLink",
278
- source: "this",
279
- predicate: "rdf://type",
280
- target: "test://Model",
281
- },
228
+ { action: 'removeLink', source: 'this', predicate: 'rdf://type', target: 'test://Model' }
282
229
  ];
283
230
 
284
231
  const links = original.toLinks();
285
- const reconstructed = SHACLShape.fromLinks(links, "test://ModelShape");
232
+ const reconstructed = SHACLShape.fromLinks(links, 'test://ModelShape');
286
233
 
287
234
  expect(reconstructed.constructor_actions).toBeDefined();
288
235
  expect(reconstructed.constructor_actions!.length).toBe(1);
289
- expect(reconstructed.constructor_actions![0].action).toBe("addLink");
236
+ expect(reconstructed.constructor_actions![0].action).toBe('addLink');
290
237
 
291
238
  expect(reconstructed.destructor_actions).toBeDefined();
292
239
  expect(reconstructed.destructor_actions!.length).toBe(1);
293
- expect(reconstructed.destructor_actions![0].action).toBe("removeLink");
240
+ expect(reconstructed.destructor_actions![0].action).toBe('removeLink');
294
241
  });
295
242
  });
296
243
 
297
- describe("edge cases", () => {
298
- it("handles empty shape", () => {
299
- const shape = new SHACLShape("test://Empty");
244
+ describe('edge cases', () => {
245
+ it('handles empty shape', () => {
246
+ const shape = new SHACLShape('test://Empty');
300
247
  const links = shape.toLinks();
301
-
248
+
302
249
  expect(links.length).toBeGreaterThanOrEqual(1); // At least targetClass link
303
-
304
- const reconstructed = SHACLShape.fromLinks(links, "test://EmptyShape");
305
- expect(reconstructed.targetClass).toBe("test://Empty");
250
+
251
+ const reconstructed = SHACLShape.fromLinks(links, 'test://EmptyShape');
252
+ expect(reconstructed.targetClass).toBe('test://Empty');
306
253
  expect(reconstructed.properties.length).toBe(0);
307
254
  });
308
255
 
309
- it("handles URI with hash fragment", () => {
310
- const shape = new SHACLShape("https://example.com/vocab#Recipe");
256
+ it('handles URI with hash fragment', () => {
257
+ const shape = new SHACLShape('https://example.com/vocab#Recipe');
311
258
  const links = shape.toLinks();
312
-
313
- const targetClassLink = links.find(
314
- (l) => l.predicate === "sh://targetClass",
315
- );
316
- expect(targetClassLink!.source).toBe(
317
- "https://example.com/vocab#RecipeShape",
318
- );
259
+
260
+ const targetClassLink = links.find(l => l.predicate === 'sh://targetClass');
261
+ expect(targetClassLink!.source).toBe('https://example.com/vocab#RecipeShape');
319
262
  });
320
263
 
321
- it("falls back to blank nodes when property has no name", () => {
322
- const shape = new SHACLShape("test://Model");
264
+ it('falls back to blank nodes when property has no name', () => {
265
+ const shape = new SHACLShape('test://Model');
323
266
  shape.addProperty({
324
- path: "test://unnamed",
267
+ path: 'test://unnamed',
325
268
  // No name property
326
269
  });
327
270
  const links = shape.toLinks();
328
-
329
- const propLink = links.find((l) => l.predicate === "sh://property");
271
+
272
+ const propLink = links.find(l => l.predicate === 'sh://property');
330
273
  expect(propLink).toBeDefined();
331
274
  // Should use blank node format when no name provided
332
275
  expect(propLink!.target).toMatch(/_:propShape\d+|test:\/\/Model\./);
333
276
  });
334
277
  });
335
278
 
336
- describe("toJSON/fromJSON", () => {
337
- it("serializes and deserializes basic shape", () => {
338
- const original = new SHACLShape("recipe://Recipe");
279
+ describe('toJSON/fromJSON', () => {
280
+ it('serializes and deserializes basic shape', () => {
281
+ const original = new SHACLShape('recipe://Recipe');
339
282
  original.addProperty({
340
- name: "name",
341
- path: "recipe://name",
342
- datatype: "xsd:string",
283
+ name: 'name',
284
+ path: 'recipe://name',
285
+ datatype: 'xsd:string',
343
286
  minCount: 1,
344
287
  });
345
288
 
346
289
  const json = original.toJSON();
347
290
  const reconstructed = SHACLShape.fromJSON(json);
348
291
 
349
- expect(reconstructed.targetClass).toBe("recipe://Recipe");
292
+ expect(reconstructed.targetClass).toBe('recipe://Recipe');
350
293
  expect(reconstructed.properties.length).toBe(1);
351
- expect(reconstructed.properties[0].name).toBe("name");
352
- expect(reconstructed.properties[0].path).toBe("recipe://name");
353
- expect(reconstructed.properties[0].datatype).toBe("xsd:string");
294
+ expect(reconstructed.properties[0].name).toBe('name');
295
+ expect(reconstructed.properties[0].path).toBe('recipe://name');
296
+ expect(reconstructed.properties[0].datatype).toBe('xsd:string');
354
297
  expect(reconstructed.properties[0].minCount).toBe(1);
355
298
  });
356
299
 
357
- it("preserves nodeShapeUri in round-trip", () => {
358
- const original = new SHACLShape(
359
- "custom://CustomShape",
360
- "recipe://Recipe",
361
- );
300
+ it('preserves nodeShapeUri in round-trip', () => {
301
+ const original = new SHACLShape('custom://CustomShape', 'recipe://Recipe');
362
302
 
363
303
  const json = original.toJSON();
364
304
  const reconstructed = SHACLShape.fromJSON(json);
365
305
 
366
- expect(reconstructed.nodeShapeUri).toBe("custom://CustomShape");
367
- expect(reconstructed.targetClass).toBe("recipe://Recipe");
306
+ expect(reconstructed.nodeShapeUri).toBe('custom://CustomShape');
307
+ expect(reconstructed.targetClass).toBe('recipe://Recipe');
368
308
  });
369
309
 
370
- it("preserves minInclusive and maxInclusive", () => {
371
- const original = new SHACLShape("test://Model");
310
+ it('preserves minInclusive and maxInclusive', () => {
311
+ const original = new SHACLShape('test://Model');
372
312
  original.addProperty({
373
- name: "rating",
374
- path: "test://rating",
375
- datatype: "xsd:integer",
313
+ name: 'rating',
314
+ path: 'test://rating',
315
+ datatype: 'xsd:integer',
376
316
  minInclusive: 1,
377
317
  maxInclusive: 5,
378
318
  });
@@ -384,108 +324,74 @@ describe("SHACLShape", () => {
384
324
  expect(reconstructed.properties[0].maxInclusive).toBe(5);
385
325
  });
386
326
 
387
- it("preserves resolveLanguage", () => {
388
- const original = new SHACLShape("test://Model");
327
+ it('preserves resolveLanguage', () => {
328
+ const original = new SHACLShape('test://Model');
389
329
  original.addProperty({
390
- name: "content",
391
- path: "test://content",
392
- resolveLanguage: "literal",
330
+ name: 'content',
331
+ path: 'test://content',
332
+ resolveLanguage: 'literal',
393
333
  });
394
334
 
395
335
  const json = original.toJSON();
396
336
  const reconstructed = SHACLShape.fromJSON(json);
397
337
 
398
- expect(reconstructed.properties[0].resolveLanguage).toBe("literal");
338
+ expect(reconstructed.properties[0].resolveLanguage).toBe('literal');
399
339
  });
400
340
 
401
- it("preserves constructor and destructor actions", () => {
402
- const original = new SHACLShape("test://Model");
341
+ it('preserves constructor and destructor actions', () => {
342
+ const original = new SHACLShape('test://Model');
403
343
  original.constructor_actions = [
404
- {
405
- action: "addLink",
406
- source: "this",
407
- predicate: "rdf://type",
408
- target: "test://Model",
409
- },
344
+ { action: 'addLink', source: 'this', predicate: 'rdf://type', target: 'test://Model' }
410
345
  ];
411
346
  original.destructor_actions = [
412
- {
413
- action: "removeLink",
414
- source: "this",
415
- predicate: "rdf://type",
416
- target: "test://Model",
417
- },
347
+ { action: 'removeLink', source: 'this', predicate: 'rdf://type', target: 'test://Model' }
418
348
  ];
419
349
 
420
350
  const json = original.toJSON();
421
351
  const reconstructed = SHACLShape.fromJSON(json);
422
352
 
423
- expect(reconstructed.constructor_actions).toEqual(
424
- original.constructor_actions,
425
- );
426
- expect(reconstructed.destructor_actions).toEqual(
427
- original.destructor_actions,
428
- );
353
+ expect(reconstructed.constructor_actions).toEqual(original.constructor_actions);
354
+ expect(reconstructed.destructor_actions).toEqual(original.destructor_actions);
429
355
  });
430
356
 
431
- it("preserves all property attributes", () => {
432
- const original = new SHACLShape("test://Model");
357
+ it('preserves all property attributes', () => {
358
+ const original = new SHACLShape('test://Model');
433
359
  original.addProperty({
434
- name: "field",
435
- path: "test://field",
436
- datatype: "xsd:string",
437
- nodeKind: "Literal",
360
+ name: 'field',
361
+ path: 'test://field',
362
+ datatype: 'xsd:string',
363
+ nodeKind: 'Literal',
438
364
  minCount: 0,
439
365
  maxCount: 5,
440
366
  minInclusive: 0,
441
367
  maxInclusive: 100,
442
- pattern: "^[a-z]+$",
443
- hasValue: "default",
368
+ pattern: '^[a-z]+$',
369
+ hasValue: 'default',
444
370
  local: true,
445
- resolveLanguage: "literal",
446
- setter: [
447
- {
448
- action: "addLink",
449
- source: "this",
450
- predicate: "test://field",
451
- target: "value",
452
- },
453
- ],
454
- adder: [
455
- {
456
- action: "addLink",
457
- source: "this",
458
- predicate: "test://items",
459
- target: "value",
460
- },
461
- ],
462
- remover: [
463
- {
464
- action: "removeLink",
465
- source: "this",
466
- predicate: "test://items",
467
- target: "value",
468
- },
469
- ],
371
+ writable: true,
372
+ resolveLanguage: 'literal',
373
+ setter: [{ action: 'addLink', source: 'this', predicate: 'test://field', target: 'value' }],
374
+ adder: [{ action: 'addLink', source: 'this', predicate: 'test://items', target: 'value' }],
375
+ remover: [{ action: 'removeLink', source: 'this', predicate: 'test://items', target: 'value' }],
470
376
  });
471
377
 
472
378
  const json = original.toJSON();
473
379
  const reconstructed = SHACLShape.fromJSON(json);
474
380
 
475
381
  const prop = reconstructed.properties[0];
476
- expect(prop.name).toBe("field");
477
- expect(prop.path).toBe("test://field");
478
- expect(prop.datatype).toBe("xsd:string");
479
- expect(prop.nodeKind).toBe("Literal");
382
+ expect(prop.name).toBe('field');
383
+ expect(prop.path).toBe('test://field');
384
+ expect(prop.datatype).toBe('xsd:string');
385
+ expect(prop.nodeKind).toBe('Literal');
480
386
  expect(prop.minCount).toBe(0);
481
387
  expect(prop.maxCount).toBe(5);
482
388
  expect(prop.minInclusive).toBe(0);
483
389
  expect(prop.maxInclusive).toBe(100);
484
- expect(prop.pattern).toBe("^[a-z]+$");
485
- expect(prop.hasValue).toBe("default");
390
+ expect(prop.pattern).toBe('^[a-z]+$');
391
+ expect(prop.hasValue).toBe('default');
486
392
  expect(prop.local).toBe(true);
487
- expect(prop.readOnly).toBeFalsy();
488
- expect(prop.resolveLanguage).toBe("literal");
393
+ expect(prop.writable).toBe(true);
394
+ expect(prop.resolveLanguage).toBe('literal');
489
395
  expect(prop.setter).toEqual(original.properties[0].setter);
490
396
  expect(prop.adder).toEqual(original.properties[0].adder);
491
397
  expect(prop.remover).toEqual(original.properties[0].remover);