glossarist 0.4.17 → 0.4.18

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.
@@ -391,6 +391,24 @@ gloss:ConceptSourceShape a sh:NodeShape ;
391
391
  sh:path gloss:modification ;
392
392
  sh:datatype xsd:string ;
393
393
  sh:maxCount 1 ;
394
+ ] ;
395
+ sh:property [
396
+ sh:path gloss:sourcedFrom ;
397
+ sh:class gloss:Citation ;
398
+ ] ;
399
+ sh:sparql [
400
+ sh:message "sourced_from is only allowed on sources of type lineage"@en ;
401
+ sh:select """
402
+ PREFIX gloss: <https://www.glossarist.org/ontologies/>
403
+ PREFIX srctype: <https://www.glossarist.org/ontologies/srctype/>
404
+ SELECT $this
405
+ WHERE {
406
+ $this gloss:sourcedFrom ?target .
407
+ FILTER NOT EXISTS {
408
+ $this gloss:sourceType srctype:lineage .
409
+ }
410
+ }
411
+ """ ;
394
412
  ] .
395
413
 
396
414
  gloss:ConceptDateShape a sh:NodeShape ;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "glossarist",
3
- "version": "0.4.17",
3
+ "version": "0.4.18",
4
4
  "description": "JavaScript SDK for Glossarist GCR packages — read, write, validate, and manage terminology concepts",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -11,6 +11,9 @@ export class ConceptSource extends GlossaristModel {
11
11
  ? (data.origin instanceof Citation ? data.origin : new Citation(data.origin))
12
12
  : null;
13
13
  this.modification = data.modification ?? null;
14
+ this.sourced_from = (data.sourced_from ?? []).map(
15
+ c => c instanceof Citation ? c : new Citation(c)
16
+ );
14
17
  }
15
18
 
16
19
  toJSON() {
@@ -20,6 +23,7 @@ export class ConceptSource extends GlossaristModel {
20
23
  if (this.type != null) obj.type = this.type;
21
24
  if (this.origin != null) obj.origin = this.origin.toJSON();
22
25
  if (this.modification != null) obj.modification = this.modification;
26
+ if (this.sourced_from.length > 0) obj.sourced_from = this.sourced_from.map(c => c.toJSON());
23
27
  return obj;
24
28
  }
25
29
 
@@ -257,6 +257,7 @@ export class ConceptSource extends GlossaristModel {
257
257
  readonly type: string | null;
258
258
  readonly origin: Citation | null;
259
259
  readonly modification: string | null;
260
+ readonly sourced_from: Citation[];
260
261
  }
261
262
 
262
263
  export const RELATIONSHIP_TYPES: readonly string[];
@@ -27,13 +27,18 @@ export function* conceptSourceToQuads(source, { subjectUri, index }) {
27
27
  }
28
28
 
29
29
  if (source.origin) {
30
- yield* citationToQuads(source.origin, { subjectUri: srcSubject });
30
+ yield* citationToQuads(source.origin, { subjectUri: srcSubject, predicate: PRED.gloss.sourceOrigin, bnodeKey: 'origin' });
31
+ }
32
+
33
+ const sourcedFrom = source.sourced_from ?? [];
34
+ for (let i = 0; i < sourcedFrom.length; i++) {
35
+ yield* citationToQuads(sourcedFrom[i], { subjectUri: srcSubject, predicate: PRED.gloss.sourcedFrom, bnodeKey: 'sourced_from', index: i });
31
36
  }
32
37
  }
33
38
 
34
- function* citationToQuads(citation, { subjectUri }) {
35
- const citSubject = deterministicBnode(subjectUri, 'origin', 0);
36
- yield quad(namedNode(subjectUri), namedNode(PRED.gloss.sourceOrigin), namedNode(citSubject));
39
+ function* citationToQuads(citation, { subjectUri, predicate, bnodeKey, index = 0 }) {
40
+ const citSubject = deterministicBnode(subjectUri, bnodeKey, index);
41
+ yield quad(namedNode(subjectUri), namedNode(predicate), namedNode(citSubject));
37
42
  yield quad(namedNode(citSubject), namedNode(WELL_KNOWN.rdfType), namedNode(PRED.gloss.Citation));
38
43
 
39
44
  if (citation.original) {
@@ -104,6 +104,7 @@ export declare const PRED = {
104
104
  "sourceId": "https://www.glossarist.org/ontologies/sourceId",
105
105
  "sourceOrigin": "https://www.glossarist.org/ontologies/sourceOrigin",
106
106
  "modification": "https://www.glossarist.org/ontologies/modification",
107
+ "sourcedFrom": "https://www.glossarist.org/ontologies/sourcedFrom",
107
108
  "hasCitationRef": "https://www.glossarist.org/ontologies/hasCitationRef",
108
109
  "hasCitationLocality": "https://www.glossarist.org/ontologies/hasCitationLocality",
109
110
  "citationOriginal": "https://www.glossarist.org/ontologies/citationOriginal",
@@ -362,6 +363,7 @@ export type Predicate =
362
363
  | "https://www.glossarist.org/ontologies/sourceId"
363
364
  | "https://www.glossarist.org/ontologies/sourceOrigin"
364
365
  | "https://www.glossarist.org/ontologies/modification"
366
+ | "https://www.glossarist.org/ontologies/sourcedFrom"
365
367
  | "https://www.glossarist.org/ontologies/hasCitationRef"
366
368
  | "https://www.glossarist.org/ontologies/hasCitationLocality"
367
369
  | "https://www.glossarist.org/ontologies/citationOriginal"
@@ -104,6 +104,7 @@ export const PRED = {
104
104
  "sourceId": "https://www.glossarist.org/ontologies/sourceId",
105
105
  "sourceOrigin": "https://www.glossarist.org/ontologies/sourceOrigin",
106
106
  "modification": "https://www.glossarist.org/ontologies/modification",
107
+ "sourcedFrom": "https://www.glossarist.org/ontologies/sourcedFrom",
107
108
  "hasCitationRef": "https://www.glossarist.org/ontologies/hasCitationRef",
108
109
  "hasCitationLocality": "https://www.glossarist.org/ontologies/hasCitationLocality",
109
110
  "citationOriginal": "https://www.glossarist.org/ontologies/citationOriginal",