@coasys/ad4m 0.12.0-rc1-dev.1 → 0.12.0-rc1-dev.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.
Files changed (128) hide show
  1. package/jest.config.js +4 -4
  2. package/lib/index.cjs +5999 -6046
  3. package/lib/index.js +5977 -6040
  4. package/lib/src/Ad4mClient.d.ts +16 -9
  5. package/lib/src/Ad4mClient.js +25 -46
  6. package/lib/src/Ad4mClient.test.d.ts +1 -0
  7. package/lib/src/Ad4mClient.test.js +1204 -0
  8. package/lib/src/Literal.d.ts +2 -1
  9. package/lib/src/Literal.js +35 -38
  10. package/lib/src/Literal.test.d.ts +1 -0
  11. package/lib/src/Literal.test.js +41 -0
  12. package/lib/src/SmartLiteral.d.ts +2 -1
  13. package/lib/src/SmartLiteral.js +15 -30
  14. package/lib/src/agent/AgentClient.d.ts +4 -1
  15. package/lib/src/agent/AgentClient.js +99 -79
  16. package/lib/src/ai/AIClient.d.ts +2 -1
  17. package/lib/src/ai/AIClient.js +220 -224
  18. package/lib/src/expression/ExpressionClient.d.ts +1 -1
  19. package/lib/src/expression/ExpressionClient.js +86 -73
  20. package/lib/src/index.d.ts +1 -1
  21. package/lib/src/index.js +1 -1
  22. package/lib/src/language/LanguageClient.d.ts +1 -1
  23. package/lib/src/language/LanguageClient.js +52 -52
  24. package/lib/src/model/Ad4mModel.d.ts +157 -937
  25. package/lib/src/model/Ad4mModel.js +212 -2799
  26. package/lib/src/model/Ad4mModel.test.js +1002 -561
  27. package/lib/src/model/decorators.d.ts +94 -426
  28. package/lib/src/model/decorators.js +333 -741
  29. package/lib/src/model/mutation.d.ts +81 -0
  30. package/lib/src/model/mutation.js +317 -0
  31. package/lib/src/model/parentUtils.d.ts +32 -0
  32. package/lib/src/model/parentUtils.js +64 -0
  33. package/lib/src/model/prolog/generatePrologFacts.d.ts +36 -0
  34. package/lib/src/model/prolog/generatePrologFacts.js +139 -0
  35. package/lib/src/model/prolog/index.d.ts +1 -0
  36. package/lib/src/model/prolog/index.js +1 -0
  37. package/lib/src/model/query/ModelQueryBuilder.d.ts +82 -0
  38. package/lib/src/model/query/ModelQueryBuilder.js +115 -0
  39. package/lib/src/model/query/QueryBuilder.d.ts +101 -0
  40. package/lib/src/model/query/QueryBuilder.js +193 -0
  41. package/lib/src/model/query/SurrealQueryBuilder.d.ts +48 -0
  42. package/lib/src/model/query/SurrealQueryBuilder.js +371 -0
  43. package/lib/src/model/query/fetchInstance.d.ts +24 -0
  44. package/lib/src/model/query/fetchInstance.js +144 -0
  45. package/lib/src/model/query/hydration.d.ts +54 -0
  46. package/lib/src/model/query/hydration.js +214 -0
  47. package/lib/src/model/query/operations.d.ts +59 -0
  48. package/lib/src/model/query/operations.js +384 -0
  49. package/lib/src/model/query/snapshot.d.ts +59 -0
  50. package/lib/src/model/query/snapshot.js +106 -0
  51. package/lib/src/model/query/surrealCompiler.d.ts +42 -0
  52. package/lib/src/model/query/surrealCompiler.js +304 -0
  53. package/lib/src/model/schema/fromJSONSchema.d.ts +67 -0
  54. package/lib/src/model/schema/fromJSONSchema.js +264 -0
  55. package/lib/src/model/schema/metadata.d.ts +15 -0
  56. package/lib/src/model/schema/metadata.js +112 -0
  57. package/lib/src/model/subscription.d.ts +47 -0
  58. package/lib/src/model/subscription.js +231 -0
  59. package/lib/src/model/transaction.d.ts +27 -0
  60. package/lib/src/model/transaction.js +32 -0
  61. package/lib/src/model/types.d.ts +195 -0
  62. package/lib/src/model/types.js +8 -0
  63. package/lib/src/model/util.js +7 -7
  64. package/lib/src/neighbourhood/NeighbourhoodClient.d.ts +5 -1
  65. package/lib/src/neighbourhood/NeighbourhoodClient.js +263 -181
  66. package/lib/src/neighbourhood/NeighbourhoodProxy.d.ts +2 -1
  67. package/lib/src/neighbourhood/NeighbourhoodProxy.js +13 -28
  68. package/lib/src/neighbourhood/NeighbourhoodProxy.test.js +1 -5
  69. package/lib/src/perspectives/PerspectiveClient.d.ts +9 -9
  70. package/lib/src/perspectives/PerspectiveClient.js +316 -240
  71. package/lib/src/perspectives/PerspectiveProxy.d.ts +54 -92
  72. package/lib/src/perspectives/PerspectiveProxy.js +803 -444
  73. package/lib/src/runtime/RuntimeClient.d.ts +5 -1
  74. package/lib/src/runtime/RuntimeClient.js +412 -238
  75. package/lib/src/shacl/SHACLFlow.test.js +164 -105
  76. package/lib/src/shacl/SHACLShape.d.ts +17 -3
  77. package/lib/src/shacl/SHACLShape.js +127 -90
  78. package/lib/src/shacl/SHACLShape.test.js +244 -176
  79. package/lib/src/utils.d.ts +8 -0
  80. package/lib/src/utils.js +21 -7
  81. package/package.json +8 -13
  82. package/src/Ad4mClient.test.ts +1564 -1315
  83. package/src/Ad4mClient.ts +55 -54
  84. package/src/Literal.test.ts +45 -26
  85. package/src/Literal.ts +82 -66
  86. package/src/SmartLiteral.ts +74 -58
  87. package/src/agent/AgentClient.ts +144 -99
  88. package/src/ai/AIClient.ts +409 -359
  89. package/src/expression/ExpressionClient.ts +142 -96
  90. package/src/index.ts +1 -1
  91. package/src/language/LanguageClient.ts +137 -113
  92. package/src/model/Ad4mModel.test.ts +1128 -647
  93. package/src/model/Ad4mModel.ts +485 -3249
  94. package/src/model/IMPROVEMENTS.md +482 -0
  95. package/src/model/PREDICATE_COLLISION_FIX.md +651 -0
  96. package/src/model/README.md +317 -0
  97. package/src/model/SHACL_MUTATION_DECOUPLING.md +356 -0
  98. package/src/model/SUBSCRIPTION_STRATEGY.md +317 -0
  99. package/src/model/TC39_STAGE_3_DECORATORS.md +609 -0
  100. package/src/model/decorators.ts +689 -1046
  101. package/src/model/mutation.ts +461 -0
  102. package/src/model/parentUtils.ts +91 -0
  103. package/src/model/prolog/generatePrologFacts.ts +176 -0
  104. package/src/model/prolog/index.ts +1 -0
  105. package/src/model/query/ModelQueryBuilder.ts +173 -0
  106. package/src/model/query/fetchInstance.ts +181 -0
  107. package/src/model/query/hydration.ts +273 -0
  108. package/src/model/query/operations.ts +510 -0
  109. package/src/model/query/snapshot.ts +126 -0
  110. package/src/model/query/surrealCompiler.ts +376 -0
  111. package/src/model/schema/fromJSONSchema.ts +411 -0
  112. package/src/model/schema/metadata.ts +148 -0
  113. package/src/model/subscription.ts +307 -0
  114. package/src/model/transaction.ts +60 -0
  115. package/src/model/types.ts +207 -0
  116. package/src/model/util.ts +47 -48
  117. package/src/neighbourhood/NeighbourhoodClient.ts +393 -251
  118. package/src/neighbourhood/NeighbourhoodProxy.test.ts +3 -7
  119. package/src/neighbourhood/NeighbourhoodProxy.ts +58 -40
  120. package/src/perspectives/PerspectiveClient.ts +779 -540
  121. package/src/perspectives/PerspectiveProxy.ts +2860 -2053
  122. package/src/runtime/RuntimeClient.ts +775 -476
  123. package/src/shacl/SHACLFlow.test.ts +196 -129
  124. package/src/shacl/SHACLShape.test.ts +284 -190
  125. package/src/shacl/SHACLShape.ts +225 -172
  126. package/src/utils.ts +31 -17
  127. package/tsconfig.json +9 -10
  128. package/src/model/Subject.ts +0 -159
@@ -1,265 +1,303 @@
1
- import { SHACLShape } from './SHACLShape';
2
- describe('SHACLShape', () => {
3
- describe('toLinks()', () => {
4
- it('creates basic shape links', () => {
5
- const shape = new SHACLShape('recipe://Recipe');
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(l => l.predicate === 'sh://targetClass');
8
+ const targetClassLink = links.find((l) => l.predicate === "sh://targetClass");
9
9
  expect(targetClassLink).toBeDefined();
10
- expect(targetClassLink.source).toBe('recipe://RecipeShape');
11
- expect(targetClassLink.target).toBe('recipe://Recipe');
10
+ expect(targetClassLink.source).toBe("recipe://RecipeShape");
11
+ expect(targetClassLink.target).toBe("recipe://Recipe");
12
12
  });
13
- it('creates property shape links with named URIs', () => {
14
- const shape = new SHACLShape('recipe://Recipe');
13
+ it("creates property shape links with named URIs", () => {
14
+ const shape = new SHACLShape("recipe://Recipe");
15
15
  const prop = {
16
- name: 'name',
17
- path: 'recipe://name',
18
- datatype: 'xsd:string',
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(l => l.predicate === 'sh://property');
25
+ const propLink = links.find((l) => l.predicate === "sh://property");
26
26
  expect(propLink).toBeDefined();
27
- expect(propLink.target).toBe('recipe://Recipe.name'); // Named URI, not blank node
27
+ expect(propLink.target).toBe("recipe://Recipe.name"); // Named URI, not blank node
28
28
  // Path link
29
- const pathLink = links.find(l => l.source === 'recipe://Recipe.name' && l.predicate === 'sh://path');
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('recipe://name');
31
+ expect(pathLink.target).toBe("recipe://name");
32
32
  // Datatype link
33
- const datatypeLink = links.find(l => l.source === 'recipe://Recipe.name' && l.predicate === 'sh://datatype');
33
+ const datatypeLink = links.find((l) => l.source === "recipe://Recipe.name" &&
34
+ l.predicate === "sh://datatype");
34
35
  expect(datatypeLink).toBeDefined();
35
- expect(datatypeLink.target).toBe('xsd:string');
36
+ expect(datatypeLink.target).toBe("xsd:string");
36
37
  // Cardinality links
37
- const minCountLink = links.find(l => l.source === 'recipe://Recipe.name' && l.predicate === 'sh://minCount');
38
+ const minCountLink = links.find((l) => l.source === "recipe://Recipe.name" &&
39
+ l.predicate === "sh://minCount");
38
40
  expect(minCountLink).toBeDefined();
39
- expect(minCountLink.target).toContain('1');
40
- const maxCountLink = links.find(l => l.source === 'recipe://Recipe.name' && l.predicate === 'sh://maxCount');
41
+ expect(minCountLink.target).toContain("1");
42
+ const maxCountLink = links.find((l) => l.source === "recipe://Recipe.name" &&
43
+ l.predicate === "sh://maxCount");
41
44
  expect(maxCountLink).toBeDefined();
42
- expect(maxCountLink.target).toContain('1');
45
+ expect(maxCountLink.target).toContain("1");
43
46
  });
44
- it('creates action links', () => {
45
- const shape = new SHACLShape('recipe://Recipe');
47
+ it("creates action links", () => {
48
+ const shape = new SHACLShape("recipe://Recipe");
46
49
  const setterAction = {
47
- action: 'addLink',
48
- source: 'this',
49
- predicate: 'recipe://name',
50
- target: 'value',
50
+ action: "addLink",
51
+ source: "this",
52
+ predicate: "recipe://name",
53
+ target: "value",
51
54
  };
52
55
  const prop = {
53
- name: 'title',
54
- path: 'recipe://title',
56
+ name: "title",
57
+ path: "recipe://title",
55
58
  setter: [setterAction],
56
59
  };
57
60
  shape.addProperty(prop);
58
61
  const links = shape.toLinks();
59
62
  // Setter action link
60
- const setterLink = links.find(l => l.source === 'recipe://Recipe.title' && l.predicate === 'ad4m://setter');
63
+ const setterLink = links.find((l) => l.source === "recipe://Recipe.title" &&
64
+ l.predicate === "ad4m://setter");
61
65
  expect(setterLink).toBeDefined();
62
- expect(setterLink.target).toContain('addLink');
66
+ expect(setterLink.target).toContain("addLink");
63
67
  });
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
- }];
68
+ it("includes constructor and destructor actions", () => {
69
+ const shape = new SHACLShape("recipe://Recipe");
70
+ shape.constructor_actions = [
71
+ {
72
+ action: "addLink",
73
+ source: "this",
74
+ predicate: "ad4m://type",
75
+ target: "recipe://Recipe",
76
+ },
77
+ ];
78
+ shape.destructor_actions = [
79
+ {
80
+ action: "removeLink",
81
+ source: "this",
82
+ predicate: "ad4m://type",
83
+ target: "recipe://Recipe",
84
+ },
85
+ ];
78
86
  const links = shape.toLinks();
79
- const constructorLink = links.find(l => l.predicate === 'ad4m://constructor');
87
+ const constructorLink = links.find((l) => l.predicate === "ad4m://constructor");
80
88
  expect(constructorLink).toBeDefined();
81
- expect(constructorLink.target).toContain('addLink');
82
- const destructorLink = links.find(l => l.predicate === 'ad4m://destructor');
89
+ expect(constructorLink.target).toContain("addLink");
90
+ const destructorLink = links.find((l) => l.predicate === "ad4m://destructor");
83
91
  expect(destructorLink).toBeDefined();
84
- expect(destructorLink.target).toContain('removeLink');
92
+ expect(destructorLink.target).toContain("removeLink");
85
93
  });
86
94
  });
87
- describe('fromLinks()', () => {
88
- it('reconstructs shape from links', () => {
89
- const originalShape = new SHACLShape('recipe://Recipe');
95
+ describe("fromLinks()", () => {
96
+ it("reconstructs shape from links", () => {
97
+ const originalShape = new SHACLShape("recipe://Recipe");
90
98
  originalShape.addProperty({
91
- name: 'name',
92
- path: 'recipe://name',
93
- datatype: 'xsd:string',
99
+ name: "name",
100
+ path: "recipe://name",
101
+ datatype: "xsd:string",
94
102
  minCount: 1,
95
103
  });
96
104
  const links = originalShape.toLinks();
97
- const reconstructed = SHACLShape.fromLinks(links, 'recipe://RecipeShape');
98
- expect(reconstructed.targetClass).toBe('recipe://Recipe');
105
+ const reconstructed = SHACLShape.fromLinks(links, "recipe://RecipeShape");
106
+ expect(reconstructed.targetClass).toBe("recipe://Recipe");
99
107
  expect(reconstructed.properties.length).toBe(1);
100
- expect(reconstructed.properties[0].path).toBe('recipe://name');
101
- expect(reconstructed.properties[0].datatype).toBe('xsd:string');
108
+ expect(reconstructed.properties[0].path).toBe("recipe://name");
109
+ expect(reconstructed.properties[0].datatype).toBe("xsd:string");
102
110
  expect(reconstructed.properties[0].minCount).toBe(1);
103
111
  });
104
- it('handles multiple properties', () => {
105
- const originalShape = new SHACLShape('recipe://Recipe');
112
+ it("handles multiple properties", () => {
113
+ const originalShape = new SHACLShape("recipe://Recipe");
106
114
  originalShape.addProperty({
107
- name: 'name',
108
- path: 'recipe://name',
109
- datatype: 'xsd:string',
115
+ name: "name",
116
+ path: "recipe://name",
117
+ datatype: "xsd:string",
110
118
  });
111
119
  originalShape.addProperty({
112
- name: 'servings',
113
- path: 'recipe://servings',
114
- datatype: 'xsd:integer',
120
+ name: "servings",
121
+ path: "recipe://servings",
122
+ datatype: "xsd:integer",
115
123
  });
116
124
  const links = originalShape.toLinks();
117
- const reconstructed = SHACLShape.fromLinks(links, 'recipe://RecipeShape');
125
+ const reconstructed = SHACLShape.fromLinks(links, "recipe://RecipeShape");
118
126
  expect(reconstructed.properties.length).toBe(2);
119
- const nameProp = reconstructed.properties.find(p => p.path === 'recipe://name');
120
- const servingsProp = reconstructed.properties.find(p => p.path === 'recipe://servings');
127
+ const nameProp = reconstructed.properties.find((p) => p.path === "recipe://name");
128
+ const servingsProp = reconstructed.properties.find((p) => p.path === "recipe://servings");
121
129
  expect(nameProp).toBeDefined();
122
130
  expect(servingsProp).toBeDefined();
123
- expect(nameProp.datatype).toBe('xsd:string');
124
- expect(servingsProp.datatype).toBe('xsd:integer');
131
+ expect(nameProp.datatype).toBe("xsd:string");
132
+ expect(servingsProp.datatype).toBe("xsd:integer");
125
133
  });
126
- it('reconstructs action arrays', () => {
127
- const originalShape = new SHACLShape('recipe://Recipe');
134
+ it("reconstructs action arrays", () => {
135
+ const originalShape = new SHACLShape("recipe://Recipe");
128
136
  const setterAction = {
129
- action: 'addLink',
130
- source: 'this',
131
- predicate: 'recipe://name',
132
- target: 'value',
137
+ action: "addLink",
138
+ source: "this",
139
+ predicate: "recipe://name",
140
+ target: "value",
133
141
  };
134
142
  originalShape.addProperty({
135
- name: 'name',
136
- path: 'recipe://name',
143
+ name: "name",
144
+ path: "recipe://name",
137
145
  setter: [setterAction],
138
146
  });
139
147
  const links = originalShape.toLinks();
140
- const reconstructed = SHACLShape.fromLinks(links, 'recipe://RecipeShape');
148
+ const reconstructed = SHACLShape.fromLinks(links, "recipe://RecipeShape");
141
149
  expect(reconstructed.properties[0].setter).toBeDefined();
142
150
  expect(reconstructed.properties[0].setter.length).toBe(1);
143
- expect(reconstructed.properties[0].setter[0].action).toBe('addLink');
151
+ expect(reconstructed.properties[0].setter[0].action).toBe("addLink");
144
152
  });
145
153
  });
146
- describe('round-trip serialization', () => {
147
- it('preserves all property attributes', () => {
148
- const original = new SHACLShape('test://Model');
154
+ describe("round-trip serialization", () => {
155
+ it("preserves all property attributes", () => {
156
+ const original = new SHACLShape("test://Model");
149
157
  original.addProperty({
150
- name: 'field',
151
- path: 'test://field',
152
- datatype: 'xsd:string',
153
- nodeKind: 'Literal',
158
+ name: "field",
159
+ path: "test://field",
160
+ datatype: "xsd:string",
161
+ nodeKind: "Literal",
154
162
  minCount: 0,
155
163
  maxCount: 5,
156
- pattern: '^[a-z]+$',
164
+ pattern: "^[a-z]+$",
157
165
  minInclusive: 10,
158
166
  maxInclusive: 100,
159
- hasValue: 'expectedValue',
160
- resolveLanguage: 'test://language',
167
+ hasValue: "expectedValue",
168
+ resolveLanguage: "test://language",
161
169
  local: true,
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' }],
170
+ setter: [
171
+ {
172
+ action: "addLink",
173
+ source: "this",
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
+ ],
166
194
  });
167
195
  const links = original.toLinks();
168
- const reconstructed = SHACLShape.fromLinks(links, 'test://ModelShape');
196
+ const reconstructed = SHACLShape.fromLinks(links, "test://ModelShape");
169
197
  const prop = reconstructed.properties[0];
170
- expect(prop.path).toBe('test://field');
171
- expect(prop.datatype).toBe('xsd:string');
172
- expect(prop.nodeKind).toBe('Literal');
198
+ expect(prop.path).toBe("test://field");
199
+ expect(prop.datatype).toBe("xsd:string");
200
+ expect(prop.nodeKind).toBe("Literal");
173
201
  expect(prop.minCount).toBe(0);
174
202
  expect(prop.maxCount).toBe(5);
175
- expect(prop.pattern).toBe('^[a-z]+$');
203
+ expect(prop.pattern).toBe("^[a-z]+$");
176
204
  expect(prop.minInclusive).toBe(10);
177
205
  expect(prop.maxInclusive).toBe(100);
178
- expect(prop.hasValue).toBe('expectedValue');
179
- expect(prop.resolveLanguage).toBe('test://language');
206
+ expect(prop.hasValue).toBe("expectedValue");
207
+ expect(prop.resolveLanguage).toBe("test://language");
180
208
  expect(prop.local).toBe(true);
181
- expect(prop.writable).toBe(true);
209
+ expect(prop.readOnly).toBeFalsy();
182
210
  expect(prop.setter).toBeDefined();
183
211
  expect(prop.adder).toBeDefined();
184
212
  expect(prop.remover).toBeDefined();
185
213
  });
186
- it('preserves constructor and destructor actions', () => {
187
- const original = new SHACLShape('test://Model');
214
+ it("preserves constructor and destructor actions", () => {
215
+ const original = new SHACLShape("test://Model");
188
216
  original.constructor_actions = [
189
- { action: 'addLink', source: 'this', predicate: 'rdf://type', target: 'test://Model' }
217
+ {
218
+ action: "addLink",
219
+ source: "this",
220
+ predicate: "rdf://type",
221
+ target: "test://Model",
222
+ },
190
223
  ];
191
224
  original.destructor_actions = [
192
- { action: 'removeLink', source: 'this', predicate: 'rdf://type', target: 'test://Model' }
225
+ {
226
+ action: "removeLink",
227
+ source: "this",
228
+ predicate: "rdf://type",
229
+ target: "test://Model",
230
+ },
193
231
  ];
194
232
  const links = original.toLinks();
195
- const reconstructed = SHACLShape.fromLinks(links, 'test://ModelShape');
233
+ const reconstructed = SHACLShape.fromLinks(links, "test://ModelShape");
196
234
  expect(reconstructed.constructor_actions).toBeDefined();
197
235
  expect(reconstructed.constructor_actions.length).toBe(1);
198
- expect(reconstructed.constructor_actions[0].action).toBe('addLink');
236
+ expect(reconstructed.constructor_actions[0].action).toBe("addLink");
199
237
  expect(reconstructed.destructor_actions).toBeDefined();
200
238
  expect(reconstructed.destructor_actions.length).toBe(1);
201
- expect(reconstructed.destructor_actions[0].action).toBe('removeLink');
239
+ expect(reconstructed.destructor_actions[0].action).toBe("removeLink");
202
240
  });
203
241
  });
204
- describe('edge cases', () => {
205
- it('handles empty shape', () => {
206
- const shape = new SHACLShape('test://Empty');
242
+ describe("edge cases", () => {
243
+ it("handles empty shape", () => {
244
+ const shape = new SHACLShape("test://Empty");
207
245
  const links = shape.toLinks();
208
246
  expect(links.length).toBeGreaterThanOrEqual(1); // At least targetClass link
209
- const reconstructed = SHACLShape.fromLinks(links, 'test://EmptyShape');
210
- expect(reconstructed.targetClass).toBe('test://Empty');
247
+ const reconstructed = SHACLShape.fromLinks(links, "test://EmptyShape");
248
+ expect(reconstructed.targetClass).toBe("test://Empty");
211
249
  expect(reconstructed.properties.length).toBe(0);
212
250
  });
213
- it('handles URI with hash fragment', () => {
214
- const shape = new SHACLShape('https://example.com/vocab#Recipe');
251
+ it("handles URI with hash fragment", () => {
252
+ const shape = new SHACLShape("https://example.com/vocab#Recipe");
215
253
  const links = shape.toLinks();
216
- const targetClassLink = links.find(l => l.predicate === 'sh://targetClass');
217
- expect(targetClassLink.source).toBe('https://example.com/vocab#RecipeShape');
254
+ const targetClassLink = links.find((l) => l.predicate === "sh://targetClass");
255
+ expect(targetClassLink.source).toBe("https://example.com/vocab#RecipeShape");
218
256
  });
219
- it('falls back to blank nodes when property has no name', () => {
220
- const shape = new SHACLShape('test://Model');
257
+ it("falls back to blank nodes when property has no name", () => {
258
+ const shape = new SHACLShape("test://Model");
221
259
  shape.addProperty({
222
- path: 'test://unnamed',
260
+ path: "test://unnamed",
223
261
  // No name property
224
262
  });
225
263
  const links = shape.toLinks();
226
- const propLink = links.find(l => l.predicate === 'sh://property');
264
+ const propLink = links.find((l) => l.predicate === "sh://property");
227
265
  expect(propLink).toBeDefined();
228
266
  // Should use blank node format when no name provided
229
267
  expect(propLink.target).toMatch(/_:propShape\d+|test:\/\/Model\./);
230
268
  });
231
269
  });
232
- describe('toJSON/fromJSON', () => {
233
- it('serializes and deserializes basic shape', () => {
234
- const original = new SHACLShape('recipe://Recipe');
270
+ describe("toJSON/fromJSON", () => {
271
+ it("serializes and deserializes basic shape", () => {
272
+ const original = new SHACLShape("recipe://Recipe");
235
273
  original.addProperty({
236
- name: 'name',
237
- path: 'recipe://name',
238
- datatype: 'xsd:string',
274
+ name: "name",
275
+ path: "recipe://name",
276
+ datatype: "xsd:string",
239
277
  minCount: 1,
240
278
  });
241
279
  const json = original.toJSON();
242
280
  const reconstructed = SHACLShape.fromJSON(json);
243
- expect(reconstructed.targetClass).toBe('recipe://Recipe');
281
+ expect(reconstructed.targetClass).toBe("recipe://Recipe");
244
282
  expect(reconstructed.properties.length).toBe(1);
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');
283
+ expect(reconstructed.properties[0].name).toBe("name");
284
+ expect(reconstructed.properties[0].path).toBe("recipe://name");
285
+ expect(reconstructed.properties[0].datatype).toBe("xsd:string");
248
286
  expect(reconstructed.properties[0].minCount).toBe(1);
249
287
  });
250
- it('preserves nodeShapeUri in round-trip', () => {
251
- const original = new SHACLShape('custom://CustomShape', 'recipe://Recipe');
288
+ it("preserves nodeShapeUri in round-trip", () => {
289
+ const original = new SHACLShape("custom://CustomShape", "recipe://Recipe");
252
290
  const json = original.toJSON();
253
291
  const reconstructed = SHACLShape.fromJSON(json);
254
- expect(reconstructed.nodeShapeUri).toBe('custom://CustomShape');
255
- expect(reconstructed.targetClass).toBe('recipe://Recipe');
292
+ expect(reconstructed.nodeShapeUri).toBe("custom://CustomShape");
293
+ expect(reconstructed.targetClass).toBe("recipe://Recipe");
256
294
  });
257
- it('preserves minInclusive and maxInclusive', () => {
258
- const original = new SHACLShape('test://Model');
295
+ it("preserves minInclusive and maxInclusive", () => {
296
+ const original = new SHACLShape("test://Model");
259
297
  original.addProperty({
260
- name: 'rating',
261
- path: 'test://rating',
262
- datatype: 'xsd:integer',
298
+ name: "rating",
299
+ path: "test://rating",
300
+ datatype: "xsd:integer",
263
301
  minInclusive: 1,
264
302
  maxInclusive: 5,
265
303
  });
@@ -268,66 +306,96 @@ describe('SHACLShape', () => {
268
306
  expect(reconstructed.properties[0].minInclusive).toBe(1);
269
307
  expect(reconstructed.properties[0].maxInclusive).toBe(5);
270
308
  });
271
- it('preserves resolveLanguage', () => {
272
- const original = new SHACLShape('test://Model');
309
+ it("preserves resolveLanguage", () => {
310
+ const original = new SHACLShape("test://Model");
273
311
  original.addProperty({
274
- name: 'content',
275
- path: 'test://content',
276
- resolveLanguage: 'literal',
312
+ name: "content",
313
+ path: "test://content",
314
+ resolveLanguage: "literal",
277
315
  });
278
316
  const json = original.toJSON();
279
317
  const reconstructed = SHACLShape.fromJSON(json);
280
- expect(reconstructed.properties[0].resolveLanguage).toBe('literal');
318
+ expect(reconstructed.properties[0].resolveLanguage).toBe("literal");
281
319
  });
282
- it('preserves constructor and destructor actions', () => {
283
- const original = new SHACLShape('test://Model');
320
+ it("preserves constructor and destructor actions", () => {
321
+ const original = new SHACLShape("test://Model");
284
322
  original.constructor_actions = [
285
- { action: 'addLink', source: 'this', predicate: 'rdf://type', target: 'test://Model' }
323
+ {
324
+ action: "addLink",
325
+ source: "this",
326
+ predicate: "rdf://type",
327
+ target: "test://Model",
328
+ },
286
329
  ];
287
330
  original.destructor_actions = [
288
- { action: 'removeLink', source: 'this', predicate: 'rdf://type', target: 'test://Model' }
331
+ {
332
+ action: "removeLink",
333
+ source: "this",
334
+ predicate: "rdf://type",
335
+ target: "test://Model",
336
+ },
289
337
  ];
290
338
  const json = original.toJSON();
291
339
  const reconstructed = SHACLShape.fromJSON(json);
292
340
  expect(reconstructed.constructor_actions).toEqual(original.constructor_actions);
293
341
  expect(reconstructed.destructor_actions).toEqual(original.destructor_actions);
294
342
  });
295
- it('preserves all property attributes', () => {
296
- const original = new SHACLShape('test://Model');
343
+ it("preserves all property attributes", () => {
344
+ const original = new SHACLShape("test://Model");
297
345
  original.addProperty({
298
- name: 'field',
299
- path: 'test://field',
300
- datatype: 'xsd:string',
301
- nodeKind: 'Literal',
346
+ name: "field",
347
+ path: "test://field",
348
+ datatype: "xsd:string",
349
+ nodeKind: "Literal",
302
350
  minCount: 0,
303
351
  maxCount: 5,
304
352
  minInclusive: 0,
305
353
  maxInclusive: 100,
306
- pattern: '^[a-z]+$',
307
- hasValue: 'default',
354
+ pattern: "^[a-z]+$",
355
+ hasValue: "default",
308
356
  local: true,
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' }],
357
+ resolveLanguage: "literal",
358
+ setter: [
359
+ {
360
+ action: "addLink",
361
+ source: "this",
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
+ ],
314
382
  });
315
383
  const json = original.toJSON();
316
384
  const reconstructed = SHACLShape.fromJSON(json);
317
385
  const prop = reconstructed.properties[0];
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');
386
+ expect(prop.name).toBe("field");
387
+ expect(prop.path).toBe("test://field");
388
+ expect(prop.datatype).toBe("xsd:string");
389
+ expect(prop.nodeKind).toBe("Literal");
322
390
  expect(prop.minCount).toBe(0);
323
391
  expect(prop.maxCount).toBe(5);
324
392
  expect(prop.minInclusive).toBe(0);
325
393
  expect(prop.maxInclusive).toBe(100);
326
- expect(prop.pattern).toBe('^[a-z]+$');
327
- expect(prop.hasValue).toBe('default');
394
+ expect(prop.pattern).toBe("^[a-z]+$");
395
+ expect(prop.hasValue).toBe("default");
328
396
  expect(prop.local).toBe(true);
329
- expect(prop.writable).toBe(true);
330
- expect(prop.resolveLanguage).toBe('literal');
397
+ expect(prop.readOnly).toBeFalsy();
398
+ expect(prop.resolveLanguage).toBe("literal");
331
399
  expect(prop.setter).toEqual(original.properties[0].setter);
332
400
  expect(prop.adder).toEqual(original.properties[0].adder);
333
401
  expect(prop.remover).toEqual(original.properties[0].remover);
@@ -1,3 +1,11 @@
1
+ /**
2
+ * WebSocket close code 1006 (abnormal closure) is emitted on every active
3
+ * GraphQL subscription when the server process shuts down — it simply means
4
+ * the server didn't send a clean close frame. This is expected at the end
5
+ * of every test run and whenever the executor is stopped, so it must not be
6
+ * treated as an application error. All other errors are still surfaced.
7
+ */
8
+ export declare function isSocketCloseError(e: any): boolean;
1
9
  export declare function formatList(list: any): any;
2
10
  export declare function capSentence(cap: any): string;
3
11
  /**