@coasys/ad4m 0.12.0-rc1-dev → 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 -6044
  3. package/lib/index.js +5977 -6038
  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 -2797
  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 -3247
  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
@@ -8,7 +8,7 @@
8
8
  */
9
9
  function extractNamespace(uri) {
10
10
  // Handle hash fragments first (highest priority)
11
- const hashIndex = uri.lastIndexOf('#');
11
+ const hashIndex = uri.lastIndexOf("#");
12
12
  if (hashIndex !== -1) {
13
13
  return uri.substring(0, hashIndex + 1);
14
14
  }
@@ -16,7 +16,7 @@ function extractNamespace(uri) {
16
16
  const protocolMatch = uri.match(/^([a-zA-Z][a-zA-Z0-9+.-]*:\/\/)(.*)$/);
17
17
  if (protocolMatch) {
18
18
  const afterScheme = protocolMatch[2];
19
- const lastSlash = afterScheme.lastIndexOf('/');
19
+ const lastSlash = afterScheme.lastIndexOf("/");
20
20
  if (lastSlash !== -1) {
21
21
  // Has path segments - namespace includes up to last slash
22
22
  return protocolMatch[1] + afterScheme.substring(0, lastSlash + 1);
@@ -30,7 +30,7 @@ function extractNamespace(uri) {
30
30
  return colonMatch[1];
31
31
  }
32
32
  // Fallback: no clear namespace
33
- return '';
33
+ return "";
34
34
  }
35
35
  /**
36
36
  * Escape special characters for Turtle string literals
@@ -38,13 +38,13 @@ function extractNamespace(uri) {
38
38
  */
39
39
  function escapeTurtleString(value) {
40
40
  return value
41
- .replace(/\\/g, '\\\\') // Backslash must be first
41
+ .replace(/\\/g, "\\\\") // Backslash must be first
42
42
  .replace(/"/g, '\\"') // Double quotes
43
- .replace(/\n/g, '\\n') // Newlines
44
- .replace(/\r/g, '\\r') // Carriage returns
45
- .replace(/\t/g, '\\t') // Tabs
46
- .replace(/\b/g, '\\b') // Backspace
47
- .replace(/\f/g, '\\f'); // Form feed
43
+ .replace(/\n/g, "\\n") // Newlines
44
+ .replace(/\r/g, "\\r") // Carriage returns
45
+ .replace(/\t/g, "\\t") // Tabs
46
+ .replace(/\b/g, "\\b") // Backspace
47
+ .replace(/\f/g, "\\f"); // Form feed
48
48
  }
49
49
  /**
50
50
  * Extract local name from a URI
@@ -56,12 +56,12 @@ function escapeTurtleString(value) {
56
56
  */
57
57
  function extractLocalName(uri) {
58
58
  // Handle hash fragments
59
- const hashIndex = uri.lastIndexOf('#');
59
+ const hashIndex = uri.lastIndexOf("#");
60
60
  if (hashIndex !== -1) {
61
61
  return uri.substring(hashIndex + 1);
62
62
  }
63
63
  // Handle slash-based namespaces
64
- const lastSlash = uri.lastIndexOf('/');
64
+ const lastSlash = uri.lastIndexOf("/");
65
65
  if (lastSlash !== -1 && lastSlash < uri.length - 1) {
66
66
  return uri.substring(lastSlash + 1);
67
67
  }
@@ -106,6 +106,15 @@ export class SHACLShape {
106
106
  addProperty(prop) {
107
107
  this.properties.push(prop);
108
108
  }
109
+ /**
110
+ * Add a parent shape reference (sh:node) for SHACL inheritance.
111
+ * The child shape will reference the parent shape instead of duplicating its properties.
112
+ * @param parentShapeUri - URI of the parent SHACL shape
113
+ */
114
+ addParentShape(parentShapeUri) {
115
+ this.parentShapes = this.parentShapes ?? [];
116
+ this.parentShapes.push(parentShapeUri);
117
+ }
109
118
  /**
110
119
  * Set constructor actions for this shape
111
120
  */
@@ -131,12 +140,23 @@ export class SHACLShape {
131
140
  if (this.targetClass) {
132
141
  turtle += ` sh:targetClass <${this.targetClass}> ;\n`;
133
142
  }
143
+ // Emit sh:node references for parent shapes (SHACL inheritance)
144
+ if (this.parentShapes && this.parentShapes.length > 0) {
145
+ for (const parentUri of this.parentShapes) {
146
+ turtle += ` sh:node <${parentUri}> ;\n`;
147
+ }
148
+ }
134
149
  // Add property shapes
135
150
  for (let i = 0; i < this.properties.length; i++) {
136
151
  const prop = this.properties[i];
137
152
  const isLast = i === this.properties.length - 1;
138
153
  turtle += ` sh:property [\n`;
139
- turtle += ` sh:path <${prop.path}> ;\n`;
154
+ if (prop.inversePath) {
155
+ turtle += ` sh:path [ sh:inversePath <${prop.path}> ] ;\n`;
156
+ }
157
+ else {
158
+ turtle += ` sh:path <${prop.path}> ;\n`;
159
+ }
140
160
  if (prop.datatype) {
141
161
  turtle += ` sh:datatype <${prop.datatype}> ;\n`;
142
162
  }
@@ -165,11 +185,11 @@ export class SHACLShape {
165
185
  if (prop.local !== undefined) {
166
186
  turtle += ` ad4m:local ${prop.local} ;\n`;
167
187
  }
168
- if (prop.writable !== undefined) {
169
- turtle += ` ad4m:writable ${prop.writable} ;\n`;
188
+ if (prop.readOnly !== undefined) {
189
+ turtle += ` ad4m:readOnly ${prop.readOnly} ;\n`;
170
190
  }
171
191
  // Remove trailing semicolon and close bracket
172
- turtle = turtle.slice(0, -2) + '\n';
192
+ turtle = turtle.slice(0, -2) + "\n";
173
193
  turtle += isLast ? ` ] .\n` : ` ] ;\n`;
174
194
  }
175
195
  return turtle;
@@ -184,22 +204,35 @@ export class SHACLShape {
184
204
  links.push({
185
205
  source: this.nodeShapeUri,
186
206
  predicate: "rdf://type",
187
- target: "sh://NodeShape"
207
+ target: "sh://NodeShape",
188
208
  });
189
209
  // Target class
190
210
  if (this.targetClass) {
191
211
  links.push({
192
212
  source: this.nodeShapeUri,
193
213
  predicate: "sh://targetClass",
194
- target: this.targetClass
214
+ target: this.targetClass,
195
215
  });
196
216
  }
197
- // Constructor actions
198
- if (this.constructor_actions && this.constructor_actions.length > 0) {
217
+ // Parent shape references (sh:node — SHACL inheritance)
218
+ if (this.parentShapes && this.parentShapes.length > 0) {
219
+ for (const parentUri of this.parentShapes) {
220
+ links.push({
221
+ source: this.nodeShapeUri,
222
+ predicate: "sh://node",
223
+ target: parentUri,
224
+ });
225
+ }
226
+ }
227
+ // Constructor actions – always emit this link (even for an empty array)
228
+ // so the Rust backend can distinguish "class registered but no init steps"
229
+ // from "class not registered", and create_subject can succeed with 0
230
+ // commands for classes that have no @Flag / initial-valued properties.
231
+ if (this.constructor_actions !== undefined) {
199
232
  links.push({
200
233
  source: this.nodeShapeUri,
201
234
  predicate: "ad4m://constructor",
202
- target: `literal://string:${JSON.stringify(this.constructor_actions)}`
235
+ target: `literal://string:${JSON.stringify(this.constructor_actions)}`,
203
236
  });
204
237
  }
205
238
  // Destructor actions
@@ -207,7 +240,7 @@ export class SHACLShape {
207
240
  links.push({
208
241
  source: this.nodeShapeUri,
209
242
  predicate: "ad4m://destructor",
210
- target: `literal://string:${JSON.stringify(this.destructor_actions)}`
243
+ target: `literal://string:${JSON.stringify(this.destructor_actions)}`,
211
244
  });
212
245
  }
213
246
  // Property shapes (each gets a named URI: {namespace}/{ClassName}.{propertyName})
@@ -230,69 +263,69 @@ export class SHACLShape {
230
263
  links.push({
231
264
  source: this.nodeShapeUri,
232
265
  predicate: "sh://property",
233
- target: propShapeId
266
+ target: propShapeId,
234
267
  });
235
- // Property path
268
+ // Property path (forward or inverse)
236
269
  links.push({
237
270
  source: propShapeId,
238
- predicate: "sh://path",
239
- target: prop.path
271
+ predicate: prop.inversePath ? "sh://inversePath" : "sh://path",
272
+ target: prop.path,
240
273
  });
241
274
  // Constraints
242
275
  if (prop.datatype) {
243
276
  links.push({
244
277
  source: propShapeId,
245
278
  predicate: "sh://datatype",
246
- target: prop.datatype
279
+ target: prop.datatype,
247
280
  });
248
281
  }
249
282
  if (prop.nodeKind) {
250
283
  links.push({
251
284
  source: propShapeId,
252
285
  predicate: "sh://nodeKind",
253
- target: `sh://${prop.nodeKind}`
286
+ target: `sh://${prop.nodeKind}`,
254
287
  });
255
288
  }
256
289
  if (prop.minCount !== undefined) {
257
290
  links.push({
258
291
  source: propShapeId,
259
292
  predicate: "sh://minCount",
260
- target: `literal://${prop.minCount}^^xsd:integer`
293
+ target: `literal://${prop.minCount}^^xsd:integer`,
261
294
  });
262
295
  }
263
296
  if (prop.maxCount !== undefined) {
264
297
  links.push({
265
298
  source: propShapeId,
266
299
  predicate: "sh://maxCount",
267
- target: `literal://${prop.maxCount}^^xsd:integer`
300
+ target: `literal://${prop.maxCount}^^xsd:integer`,
268
301
  });
269
302
  }
270
303
  if (prop.pattern) {
271
304
  links.push({
272
305
  source: propShapeId,
273
306
  predicate: "sh://pattern",
274
- target: `literal://${prop.pattern}`
307
+ target: `literal://${prop.pattern}`,
275
308
  });
276
309
  }
277
310
  if (prop.minInclusive !== undefined) {
278
311
  links.push({
279
312
  source: propShapeId,
280
313
  predicate: "sh://minInclusive",
281
- target: `literal://${prop.minInclusive}`
314
+ target: `literal://${prop.minInclusive}`,
282
315
  });
283
316
  }
284
317
  if (prop.maxInclusive !== undefined) {
285
318
  links.push({
286
319
  source: propShapeId,
287
320
  predicate: "sh://maxInclusive",
288
- target: `literal://${prop.maxInclusive}`
321
+ target: `literal://${prop.maxInclusive}`,
289
322
  });
290
323
  }
291
324
  if (prop.hasValue) {
292
325
  links.push({
293
326
  source: propShapeId,
294
327
  predicate: "sh://hasValue",
295
- target: `literal://${prop.hasValue}`
328
+ target: `literal://${prop.hasValue}`,
296
329
  });
297
330
  }
298
331
  // AD4M-specific metadata
@@ -300,21 +333,21 @@ export class SHACLShape {
300
333
  links.push({
301
334
  source: propShapeId,
302
335
  predicate: "ad4m://local",
303
- target: `literal://${prop.local}`
336
+ target: `literal://${prop.local}`,
304
337
  });
305
338
  }
306
- if (prop.writable !== undefined) {
339
+ if (prop.readOnly !== undefined) {
307
340
  links.push({
308
341
  source: propShapeId,
309
- predicate: "ad4m://writable",
310
- target: `literal://${prop.writable}`
342
+ predicate: "ad4m://readOnly",
343
+ target: `literal://${prop.readOnly}`,
311
344
  });
312
345
  }
313
346
  if (prop.resolveLanguage) {
314
347
  links.push({
315
348
  source: propShapeId,
316
349
  predicate: "ad4m://resolveLanguage",
317
- target: `literal://string:${prop.resolveLanguage}`
350
+ target: `literal://string:${prop.resolveLanguage}`,
318
351
  });
319
352
  }
320
353
  // AD4M-specific actions
@@ -322,21 +355,21 @@ export class SHACLShape {
322
355
  links.push({
323
356
  source: propShapeId,
324
357
  predicate: "ad4m://setter",
325
- target: `literal://string:${JSON.stringify(prop.setter)}`
358
+ target: `literal://string:${JSON.stringify(prop.setter)}`,
326
359
  });
327
360
  }
328
361
  if (prop.adder && prop.adder.length > 0) {
329
362
  links.push({
330
363
  source: propShapeId,
331
364
  predicate: "ad4m://adder",
332
- target: `literal://string:${JSON.stringify(prop.adder)}`
365
+ target: `literal://string:${JSON.stringify(prop.adder)}`,
333
366
  });
334
367
  }
335
368
  if (prop.remover && prop.remover.length > 0) {
336
369
  links.push({
337
370
  source: propShapeId,
338
371
  predicate: "ad4m://remover",
339
- target: `literal://string:${JSON.stringify(prop.remover)}`
372
+ target: `literal://string:${JSON.stringify(prop.remover)}`,
340
373
  });
341
374
  }
342
375
  }
@@ -347,13 +380,13 @@ export class SHACLShape {
347
380
  */
348
381
  static fromLinks(links, shapeUri) {
349
382
  // Find target class
350
- const targetClassLink = links.find(l => l.source === shapeUri && l.predicate === "sh://targetClass");
383
+ const targetClassLink = links.find((l) => l.source === shapeUri && l.predicate === "sh://targetClass");
351
384
  const shape = new SHACLShape(shapeUri, targetClassLink?.target);
352
385
  // Find constructor actions
353
- const constructorLink = links.find(l => l.source === shapeUri && l.predicate === "ad4m://constructor");
386
+ const constructorLink = links.find((l) => l.source === shapeUri && l.predicate === "ad4m://constructor");
354
387
  if (constructorLink) {
355
388
  try {
356
- const jsonStr = constructorLink.target.replace('literal://string:', '');
389
+ const jsonStr = constructorLink.target.replace("literal://string:", "");
357
390
  shape.constructor_actions = JSON.parse(jsonStr);
358
391
  }
359
392
  catch (e) {
@@ -361,10 +394,10 @@ export class SHACLShape {
361
394
  }
362
395
  }
363
396
  // Find destructor actions
364
- const destructorLink = links.find(l => l.source === shapeUri && l.predicate === "ad4m://destructor");
397
+ const destructorLink = links.find((l) => l.source === shapeUri && l.predicate === "ad4m://destructor");
365
398
  if (destructorLink) {
366
399
  try {
367
- const jsonStr = destructorLink.target.replace('literal://string:', '');
400
+ const jsonStr = destructorLink.target.replace("literal://string:", "");
368
401
  shape.destructor_actions = JSON.parse(jsonStr);
369
402
  }
370
403
  catch (e) {
@@ -372,120 +405,124 @@ export class SHACLShape {
372
405
  }
373
406
  }
374
407
  // Find all property shapes
375
- const propShapeLinks = links.filter(l => l.source === shapeUri && l.predicate === "sh://property");
408
+ const propShapeLinks = links.filter((l) => l.source === shapeUri && l.predicate === "sh://property");
376
409
  for (const propLink of propShapeLinks) {
377
410
  const propShapeId = propLink.target;
378
411
  // Reconstruct property from its links
379
- const pathLink = links.find(l => l.source === propShapeId && l.predicate === "sh://path");
412
+ const pathLink = links.find((l) => l.source === propShapeId && l.predicate === "sh://path");
380
413
  if (!pathLink)
381
414
  continue;
382
415
  // Extract property name from propShapeId if it's a named URI
383
416
  // Format: {namespace}{ClassName}.{propertyName}
384
417
  let propertyName;
385
- if (!propShapeId.startsWith('_:')) {
386
- const lastDotIndex = propShapeId.lastIndexOf('.');
418
+ if (!propShapeId.startsWith("_:")) {
419
+ const lastDotIndex = propShapeId.lastIndexOf(".");
387
420
  if (lastDotIndex !== -1) {
388
421
  propertyName = propShapeId.substring(lastDotIndex + 1);
389
422
  }
390
423
  }
391
424
  const prop = {
392
425
  name: propertyName,
393
- path: pathLink.target
426
+ path: pathLink.target,
394
427
  };
395
428
  // Extract constraints
396
- const datatypeLink = links.find(l => l.source === propShapeId && l.predicate === "sh://datatype");
429
+ const datatypeLink = links.find((l) => l.source === propShapeId && l.predicate === "sh://datatype");
397
430
  if (datatypeLink)
398
431
  prop.datatype = datatypeLink.target;
399
- const nodeKindLink = links.find(l => l.source === propShapeId && l.predicate === "sh://nodeKind");
432
+ const nodeKindLink = links.find((l) => l.source === propShapeId && l.predicate === "sh://nodeKind");
400
433
  if (nodeKindLink) {
401
- prop.nodeKind = nodeKindLink.target.replace('sh://', '');
434
+ prop.nodeKind = nodeKindLink.target.replace("sh://", "");
402
435
  }
403
- const minCountLink = links.find(l => l.source === propShapeId && l.predicate === "sh://minCount");
436
+ const minCountLink = links.find((l) => l.source === propShapeId && l.predicate === "sh://minCount");
404
437
  if (minCountLink) {
405
438
  // Handle both formats: literal://5^^xsd:integer and literal://number:5
406
- let val = minCountLink.target.replace('literal://', '').replace(/\^\^.*$/, '');
407
- if (val.startsWith('number:'))
439
+ let val = minCountLink.target
440
+ .replace("literal://", "")
441
+ .replace(/\^\^.*$/, "");
442
+ if (val.startsWith("number:"))
408
443
  val = val.substring(7);
409
444
  prop.minCount = parseInt(val);
410
445
  }
411
- const maxCountLink = links.find(l => l.source === propShapeId && l.predicate === "sh://maxCount");
446
+ const maxCountLink = links.find((l) => l.source === propShapeId && l.predicate === "sh://maxCount");
412
447
  if (maxCountLink) {
413
448
  // Handle both formats: literal://5^^xsd:integer and literal://number:5
414
- let val = maxCountLink.target.replace('literal://', '').replace(/\^\^.*$/, '');
415
- if (val.startsWith('number:'))
449
+ let val = maxCountLink.target
450
+ .replace("literal://", "")
451
+ .replace(/\^\^.*$/, "");
452
+ if (val.startsWith("number:"))
416
453
  val = val.substring(7);
417
454
  prop.maxCount = parseInt(val);
418
455
  }
419
- const patternLink = links.find(l => l.source === propShapeId && l.predicate === "sh://pattern");
456
+ const patternLink = links.find((l) => l.source === propShapeId && l.predicate === "sh://pattern");
420
457
  if (patternLink) {
421
- prop.pattern = patternLink.target.replace('literal://', '');
458
+ prop.pattern = patternLink.target.replace("literal://", "");
422
459
  }
423
- const minInclusiveLink = links.find(l => l.source === propShapeId && l.predicate === "sh://minInclusive");
460
+ const minInclusiveLink = links.find((l) => l.source === propShapeId && l.predicate === "sh://minInclusive");
424
461
  if (minInclusiveLink) {
425
462
  // Handle both formats: literal://5 and literal://number:5
426
- let val = minInclusiveLink.target.replace('literal://', '');
427
- if (val.startsWith('number:'))
463
+ let val = minInclusiveLink.target.replace("literal://", "");
464
+ if (val.startsWith("number:"))
428
465
  val = val.substring(7);
429
466
  prop.minInclusive = parseFloat(val);
430
467
  }
431
- const maxInclusiveLink = links.find(l => l.source === propShapeId && l.predicate === "sh://maxInclusive");
468
+ const maxInclusiveLink = links.find((l) => l.source === propShapeId && l.predicate === "sh://maxInclusive");
432
469
  if (maxInclusiveLink) {
433
470
  // Handle both formats: literal://5 and literal://number:5
434
- let val = maxInclusiveLink.target.replace('literal://', '');
435
- if (val.startsWith('number:'))
471
+ let val = maxInclusiveLink.target.replace("literal://", "");
472
+ if (val.startsWith("number:"))
436
473
  val = val.substring(7);
437
474
  prop.maxInclusive = parseFloat(val);
438
475
  }
439
- const hasValueLink = links.find(l => l.source === propShapeId && l.predicate === "sh://hasValue");
476
+ const hasValueLink = links.find((l) => l.source === propShapeId && l.predicate === "sh://hasValue");
440
477
  if (hasValueLink) {
441
- prop.hasValue = hasValueLink.target.replace('literal://', '');
478
+ prop.hasValue = hasValueLink.target.replace("literal://", "");
442
479
  }
443
480
  // AD4M-specific
444
- const localLink = links.find(l => l.source === propShapeId && l.predicate === "ad4m://local");
481
+ const localLink = links.find((l) => l.source === propShapeId && l.predicate === "ad4m://local");
445
482
  if (localLink) {
446
483
  // Handle both formats: literal://true and literal://boolean:true
447
- let val = localLink.target.replace('literal://', '');
448
- if (val.startsWith('boolean:'))
484
+ let val = localLink.target.replace("literal://", "");
485
+ if (val.startsWith("boolean:"))
449
486
  val = val.substring(8);
450
- prop.local = val === 'true';
487
+ prop.local = val === "true";
451
488
  }
452
- const writableLink = links.find(l => l.source === propShapeId && l.predicate === "ad4m://writable");
453
- if (writableLink) {
489
+ const readOnlyLink = links.find((l) => l.source === propShapeId && l.predicate === "ad4m://readOnly");
490
+ if (readOnlyLink) {
454
491
  // Handle both formats: literal://true and literal://boolean:true
455
- let val = writableLink.target.replace('literal://', '');
456
- if (val.startsWith('boolean:'))
492
+ let val = readOnlyLink.target.replace("literal://", "");
493
+ if (val.startsWith("boolean:"))
457
494
  val = val.substring(8);
458
- prop.writable = val === 'true';
495
+ prop.readOnly = val === "true";
459
496
  }
460
- const resolveLangLink = links.find(l => l.source === propShapeId && l.predicate === "ad4m://resolveLanguage");
497
+ const resolveLangLink = links.find((l) => l.source === propShapeId && l.predicate === "ad4m://resolveLanguage");
461
498
  if (resolveLangLink) {
462
- prop.resolveLanguage = resolveLangLink.target.replace('literal://string:', '');
499
+ prop.resolveLanguage = resolveLangLink.target.replace("literal://string:", "");
463
500
  }
464
501
  // Parse action arrays
465
- const setterLink = links.find(l => l.source === propShapeId && l.predicate === "ad4m://setter");
502
+ const setterLink = links.find((l) => l.source === propShapeId && l.predicate === "ad4m://setter");
466
503
  if (setterLink) {
467
504
  try {
468
- const jsonStr = setterLink.target.replace('literal://string:', '');
505
+ const jsonStr = setterLink.target.replace("literal://string:", "");
469
506
  prop.setter = JSON.parse(jsonStr);
470
507
  }
471
508
  catch (e) {
472
509
  // Ignore parse errors
473
510
  }
474
511
  }
475
- const adderLink = links.find(l => l.source === propShapeId && l.predicate === "ad4m://adder");
512
+ const adderLink = links.find((l) => l.source === propShapeId && l.predicate === "ad4m://adder");
476
513
  if (adderLink) {
477
514
  try {
478
- const jsonStr = adderLink.target.replace('literal://string:', '');
515
+ const jsonStr = adderLink.target.replace("literal://string:", "");
479
516
  prop.adder = JSON.parse(jsonStr);
480
517
  }
481
518
  catch (e) {
482
519
  // Ignore parse errors
483
520
  }
484
521
  }
485
- const removerLink = links.find(l => l.source === propShapeId && l.predicate === "ad4m://remover");
522
+ const removerLink = links.find((l) => l.source === propShapeId && l.predicate === "ad4m://remover");
486
523
  if (removerLink) {
487
524
  try {
488
- const jsonStr = removerLink.target.replace('literal://string:', '');
525
+ const jsonStr = removerLink.target.replace("literal://string:", "");
489
526
  prop.remover = JSON.parse(jsonStr);
490
527
  }
491
528
  catch (e) {
@@ -506,7 +543,7 @@ export class SHACLShape {
506
543
  return {
507
544
  node_shape_uri: this.nodeShapeUri,
508
545
  target_class: this.targetClass,
509
- properties: this.properties.map(p => ({
546
+ properties: this.properties.map((p) => ({
510
547
  path: p.path,
511
548
  name: p.name,
512
549
  datatype: p.datatype,
@@ -518,7 +555,7 @@ export class SHACLShape {
518
555
  pattern: p.pattern,
519
556
  has_value: p.hasValue,
520
557
  local: p.local,
521
- writable: p.writable,
558
+ read_only: p.readOnly,
522
559
  resolve_language: p.resolveLanguage,
523
560
  setter: p.setter,
524
561
  adder: p.adder,
@@ -548,7 +585,7 @@ export class SHACLShape {
548
585
  pattern: p.pattern,
549
586
  hasValue: p.has_value,
550
587
  local: p.local,
551
- writable: p.writable,
588
+ readOnly: p.read_only,
552
589
  resolveLanguage: p.resolve_language,
553
590
  setter: p.setter,
554
591
  adder: p.adder,