@comake/skl-js-engine 1.1.4 → 1.1.5

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 (33) hide show
  1. package/dist/JsExecutor/jsExecutor.js +2 -1
  2. package/dist/JsExecutor/jsExecutor.js.map +1 -1
  3. package/dist/JsExecutor/transport/stdio/ChildStdioTransport.js +2 -2
  4. package/dist/JsExecutor/transport/stdio/ChildStdioTransport.js.map +1 -1
  5. package/dist/JsExecutor/transport/stdio/ParentStdioTransport.js +2 -2
  6. package/dist/JsExecutor/transport/stdio/ParentStdioTransport.js.map +1 -1
  7. package/dist/SklEngine.d.ts +2 -1
  8. package/dist/SklEngine.js +93 -49
  9. package/dist/SklEngine.js.map +1 -1
  10. package/dist/constants.d.ts +74 -86
  11. package/dist/constants.js +38 -50
  12. package/dist/constants.js.map +1 -1
  13. package/dist/storage/query-adapter/sparql/SparqlQueryBuilder.d.ts +1 -1
  14. package/dist/storage/query-adapter/sparql/SparqlQueryBuilder.js +107 -106
  15. package/dist/storage/query-adapter/sparql/SparqlQueryBuilder.js.map +1 -1
  16. package/dist/storage/query-adapter/sparql/query-executor/SparqlEndpointQueryExecutor.d.ts +1 -1
  17. package/dist/storage/query-adapter/sparql/query-executor/SparqlEndpointQueryExecutor.js +1 -1
  18. package/dist/storage/query-adapter/sparql/query-executor/SparqlEndpointQueryExecutor.js.map +1 -1
  19. package/dist/util/SparqlUtil.d.ts +2 -2
  20. package/dist/util/TripleUtil.d.ts +2 -2
  21. package/dist/util/TripleUtil.js +9 -9
  22. package/dist/util/TripleUtil.js.map +1 -1
  23. package/dist/util/Types.d.ts +1 -3
  24. package/dist/util/Vocabularies/Shared.d.ts +2 -2
  25. package/dist/util/Vocabularies/Shared.js +4 -4
  26. package/dist/util/Vocabularies/Shared.js.map +1 -1
  27. package/dist/util/Vocabularies/index.d.ts +6 -6
  28. package/dist/util/Vocabularies/index.js +43 -50
  29. package/dist/util/Vocabularies/index.js.map +1 -1
  30. package/package.json +1 -1
  31. package/dist/JsExecutor/transport/StdioTransport.d.ts +0 -0
  32. package/dist/JsExecutor/transport/StdioTransport.js +0 -641
  33. package/dist/JsExecutor/transport/StdioTransport.js.map +0 -1
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.SparqlQueryBuilder = void 0;
7
7
  const data_model_1 = __importDefault(require("@rdfjs/data-model"));
8
+ const constants_1 = require("../../../constants");
8
9
  const SparqlUtil_1 = require("../../../util/SparqlUtil");
9
10
  const TripleUtil_1 = require("../../../util/TripleUtil");
10
11
  const Util_1 = require("../../../util/Util");
@@ -47,16 +48,16 @@ class SparqlQueryBuilder {
47
48
  const variable = this.createVariable();
48
49
  return {
49
50
  variable,
50
- expression: order.expression,
51
+ expression: order.expression
51
52
  };
52
53
  });
53
54
  const orders = selectVariables.map((selectVar, index) => ({
54
55
  expression: selectVar.variable,
55
- descending: orderQueryData.orders[index].descending,
56
+ descending: orderQueryData.orders[index].descending
56
57
  }));
57
58
  if (orders.length > 0) {
58
59
  orders.push({
59
- expression: SparqlUtil_1.entityVariable,
60
+ expression: SparqlUtil_1.entityVariable
60
61
  });
61
62
  }
62
63
  const returnData = {
@@ -64,7 +65,7 @@ class SparqlQueryBuilder {
64
65
  orders,
65
66
  group: orderQueryData.groupByParent ? subject : undefined,
66
67
  graphWhere: graphWherePatterns,
67
- graphSelectionTriples: relationsQueryData.selectionTriples,
68
+ graphSelectionTriples: relationsQueryData.selectionTriples
68
69
  };
69
70
  if (selectVariables.length > 0) {
70
71
  returnData.selectVariables = selectVariables;
@@ -78,7 +79,7 @@ class SparqlQueryBuilder {
78
79
  if (subQuery.groupBy && Array.isArray(subQuery.groupBy)) {
79
80
  subQuery.groupBy.forEach((group) => {
80
81
  queryGroup.push({
81
- expression: data_model_1.default.variable(group),
82
+ expression: data_model_1.default.variable(group)
82
83
  });
83
84
  });
84
85
  }
@@ -89,7 +90,7 @@ class SparqlQueryBuilder {
89
90
  where: this.createWherePatternsFromQueryData(subQueryWhere.values, subQueryWhere.triples, subQueryWhere.filters, undefined, undefined, subQueryWhere.patterns ?? []),
90
91
  group: queryGroup.length > 0 ? queryGroup : undefined,
91
92
  having: subQuery.having ? this.createWhereQueryData(SparqlUtil_1.entityVariable, subQuery.having).filters : undefined,
92
- prefixes: {},
93
+ prefixes: {}
93
94
  };
94
95
  return (0, SparqlUtil_1.createSparqlSelectGroup)([selectQuery]);
95
96
  });
@@ -109,7 +110,7 @@ class SparqlQueryBuilder {
109
110
  triples = [SparqlUtil_1.entityGraphTriple, ...graphSelectionTriples];
110
111
  where = [
111
112
  ...graphWhere,
112
- (0, SparqlUtil_1.createSparqlGraphPattern)(SparqlUtil_1.entityVariable, [(0, SparqlUtil_1.createSparqlBasicGraphPattern)([SparqlUtil_1.entityGraphTriple])]),
113
+ (0, SparqlUtil_1.createSparqlGraphPattern)(SparqlUtil_1.entityVariable, [(0, SparqlUtil_1.createSparqlBasicGraphPattern)([SparqlUtil_1.entityGraphTriple])])
113
114
  ];
114
115
  }
115
116
  // // Add select variables to the query
@@ -135,7 +136,7 @@ class SparqlQueryBuilder {
135
136
  graphValues: values,
136
137
  graphFilters: filters,
137
138
  graphTriples: triples,
138
- binds: [],
139
+ binds: []
139
140
  };
140
141
  }
141
142
  // Handle binds if specified in where options
@@ -144,7 +145,7 @@ class SparqlQueryBuilder {
144
145
  binds.push(...where.binds.map((bind) => ({
145
146
  type: 'bind',
146
147
  expression: bind.expression,
147
- variable: bind.variable,
148
+ variable: bind.variable
148
149
  })));
149
150
  // Delete binds from where as it's a special key
150
151
  const { binds: _, ...restWhere } = where;
@@ -157,7 +158,7 @@ class SparqlQueryBuilder {
157
158
  triples: [...obj.triples, ...whereQueryDataForField.triples],
158
159
  filters: [...obj.filters, ...whereQueryDataForField.filters],
159
160
  patterns: [...obj.patterns ?? [], ...whereQueryDataForField.patterns ?? []],
160
- binds: [...obj.binds ?? [], ...whereQueryDataForField.binds ?? []],
161
+ binds: [...obj.binds ?? [], ...whereQueryDataForField.binds ?? []]
161
162
  };
162
163
  }, { values: [], triples: [], filters: [], patterns: [], binds });
163
164
  return {
@@ -166,7 +167,7 @@ class SparqlQueryBuilder {
166
167
  graphFilters: [],
167
168
  graphTriples: [],
168
169
  patterns: whereQueryData.patterns ?? [],
169
- binds: whereQueryData.binds ?? [],
170
+ binds: whereQueryData.binds ?? []
170
171
  };
171
172
  }
172
173
  createWhereQueryDataForField(subject, field, value) {
@@ -192,16 +193,16 @@ class SparqlQueryBuilder {
192
193
  type: 'values',
193
194
  values: [
194
195
  {
195
- [`?${term.value}`]: data_model_1.default.namedNode(value),
196
- },
197
- ],
198
- },
196
+ [`?${term.value}`]: data_model_1.default.namedNode(value)
197
+ }
198
+ ]
199
+ }
199
200
  ];
200
201
  }
201
202
  return {
202
203
  values,
203
204
  filters,
204
- triples,
205
+ triples
205
206
  };
206
207
  }
207
208
  createWhereQueryDataForType(subject, value) {
@@ -215,13 +216,13 @@ class SparqlQueryBuilder {
215
216
  return {
216
217
  subject,
217
218
  predicate: SparqlUtil_1.allTypesAndSuperTypesPath,
218
- object: data_model_1.default.namedNode(typeStr),
219
+ object: data_model_1.default.namedNode(typeStr)
219
220
  };
220
221
  });
221
222
  return {
222
223
  values: [],
223
224
  filters: [],
224
- triples,
225
+ triples
225
226
  };
226
227
  }
227
228
  if (value.operator === 'inverse') {
@@ -230,7 +231,7 @@ class SparqlQueryBuilder {
230
231
  return {
231
232
  values: inverseWhereQueryData.values,
232
233
  filters: inverseWhereQueryData.filters,
233
- triples: inverseWhereQueryData.triples,
234
+ triples: inverseWhereQueryData.triples
234
235
  };
235
236
  }
236
237
  if (value.operator === 'sequence') {
@@ -241,12 +242,12 @@ class SparqlQueryBuilder {
241
242
  const triples = value.map(typeVal => ({
242
243
  subject,
243
244
  predicate: SparqlUtil_1.allTypesAndSuperTypesPath,
244
- object: typeof typeVal === 'string' ? data_model_1.default.namedNode(typeVal) : data_model_1.default.namedNode(typeVal.toString()),
245
+ object: typeof typeVal === 'string' ? data_model_1.default.namedNode(typeVal) : data_model_1.default.namedNode(typeVal.toString())
245
246
  }));
246
247
  return {
247
248
  values: [],
248
249
  filters: [],
249
- triples,
250
+ triples
250
251
  };
251
252
  }
252
253
  const variable = this.createVariable();
@@ -255,7 +256,7 @@ class SparqlQueryBuilder {
255
256
  return {
256
257
  values: valuePattern ? [valuePattern] : [],
257
258
  filters: filter ? [filter] : [],
258
- triples: tripleInFilter ? [] : [triple],
259
+ triples: tripleInFilter ? [] : [triple]
259
260
  };
260
261
  }
261
262
  return {
@@ -265,9 +266,9 @@ class SparqlQueryBuilder {
265
266
  {
266
267
  subject,
267
268
  predicate: SparqlUtil_1.allTypesAndSuperTypesPath,
268
- object: data_model_1.default.namedNode(value),
269
- },
270
- ],
269
+ object: data_model_1.default.namedNode(value)
270
+ }
271
+ ]
271
272
  };
272
273
  }
273
274
  createWhereQueryDataFromKeyValue(subject, predicate, value) {
@@ -284,7 +285,7 @@ class SparqlQueryBuilder {
284
285
  values: [...obj.values, ...valueWhereQueryData.values],
285
286
  filters: [...obj.filters, ...valueWhereQueryData.filters],
286
287
  triples: [...obj.triples, ...valueWhereQueryData.triples],
287
- patterns: [...obj.patterns ?? [], ...valueWhereQueryData.patterns ?? []],
288
+ patterns: [...obj.patterns ?? [], ...valueWhereQueryData.patterns ?? []]
288
289
  };
289
290
  }, { values: [], filters: [], triples: [], patterns: [] });
290
291
  }
@@ -298,7 +299,7 @@ class SparqlQueryBuilder {
298
299
  return {
299
300
  values: [],
300
301
  filters: [],
301
- triples: [{ subject, predicate, object: term }],
302
+ triples: [{ subject, predicate, object: term }]
302
303
  };
303
304
  }
304
305
  createWhereQueryDataForFindOperator(subject, predicate, operator) {
@@ -321,7 +322,7 @@ class SparqlQueryBuilder {
321
322
  return {
322
323
  values: valuePattern ? [valuePattern] : [],
323
324
  filters: filter ? [filter] : [],
324
- triples: tripleInFilter ? [] : [triple],
325
+ triples: tripleInFilter ? [] : [triple]
325
326
  };
326
327
  }
327
328
  pathOperatorToPropertyPath(operator) {
@@ -376,7 +377,7 @@ class SparqlQueryBuilder {
376
377
  const whereQueryData = {
377
378
  values: [],
378
379
  filters: [],
379
- triples: [triple],
380
+ triples: [triple]
380
381
  };
381
382
  return operators.reduce((obj, operator) => {
382
383
  const { filter, valuePattern } = this.resolveFindOperatorAsExpressionWithMultipleValues(variable, operator, triple);
@@ -396,7 +397,7 @@ class SparqlQueryBuilder {
396
397
  values: [...subWhereQueryData.values, ...subWhereQueryData.graphValues],
397
398
  filters: subWhereQueryData.filters,
398
399
  triples: [{ subject, predicate, object: subNodeVariable }, ...subWhereQueryData.triples],
399
- patterns: [...subWhereQueryData.patterns ?? []],
400
+ patterns: [...subWhereQueryData.patterns ?? []]
400
401
  };
401
402
  }
402
403
  createWhereQueryDataForValueObject(subject, predicate, valueObject) {
@@ -406,13 +407,13 @@ class SparqlQueryBuilder {
406
407
  values: [],
407
408
  filters: [],
408
409
  triples: [],
409
- patterns: [(0, SparqlUtil_1.createSparqlOptional)([(0, SparqlUtil_1.createSparqlBasicGraphPattern)([{ subject, predicate, object: term }])])],
410
+ patterns: [(0, SparqlUtil_1.createSparqlOptional)([(0, SparqlUtil_1.createSparqlBasicGraphPattern)([{ subject, predicate, object: term }])])]
410
411
  };
411
412
  }
412
413
  return {
413
414
  values: [],
414
415
  filters: [],
415
- triples: [{ subject, predicate, object: term }],
416
+ triples: [{ subject, predicate, object: term }]
416
417
  };
417
418
  }
418
419
  valueObjectToTerm(valueObject) {
@@ -439,7 +440,7 @@ class SparqlQueryBuilder {
439
440
  if (values.length === 1) {
440
441
  // If only one value, treat as equality
441
442
  return {
442
- filter: (0, SparqlUtil_1.createSparqlEqualOperation)(leftSide, this.resolveValueToExpression(values[0])),
443
+ filter: (0, SparqlUtil_1.createSparqlEqualOperation)(leftSide, this.resolveValueToExpression(values[0]))
443
444
  };
444
445
  }
445
446
  // Create individual equality conditions for each value
@@ -449,8 +450,8 @@ class SparqlQueryBuilder {
449
450
  filter: {
450
451
  type: 'operation',
451
452
  operator: '&&',
452
- args: equalityConditions,
453
- },
453
+ args: equalityConditions
454
+ }
454
455
  };
455
456
  }
456
457
  if (operator.operator === 'in') {
@@ -459,25 +460,25 @@ class SparqlQueryBuilder {
459
460
  return {
460
461
  valuePattern: {
461
462
  type: 'values',
462
- values: resolvedValue.map((value) => ({ [`?${leftSide.value}`]: value })),
463
- },
463
+ values: resolvedValue.map((value) => ({ [`?${leftSide.value}`]: value }))
464
+ }
464
465
  };
465
466
  }
466
467
  return {
467
- filter: (0, SparqlUtil_1.createSparqlInOperation)(leftSide, resolvedValue),
468
+ filter: (0, SparqlUtil_1.createSparqlInOperation)(leftSide, resolvedValue)
468
469
  };
469
470
  }
470
471
  if (operator.operator === 'not') {
471
472
  const resolvedExpression = this.resolveValueToExpression(operator.value);
472
473
  return {
473
474
  filter: this.buildNotOperationForMultiValued(leftSide, resolvedExpression, triple),
474
- tripleInFilter: true,
475
+ tripleInFilter: true
475
476
  };
476
477
  }
477
478
  if (operator.operator === 'exists') {
478
479
  return {
479
480
  filter: (0, SparqlUtil_1.createSparqlExistsOperation)([(0, SparqlUtil_1.createSparqlBasicGraphPattern)([triple])]),
480
- tripleInFilter: true,
481
+ tripleInFilter: true
481
482
  };
482
483
  }
483
484
  if (operator.operator === 'contains') {
@@ -486,7 +487,7 @@ class SparqlQueryBuilder {
486
487
  // Directly use the variable as an expression
487
488
  (0, SparqlUtil_1.createSparqlLcaseOperation)(data_model_1.default.variable(leftSide.value)), (0, SparqlUtil_1.createSparqlLcaseOperation)(data_model_1.default.literal(searchString.value.toLowerCase())));
488
489
  return {
489
- filter,
490
+ filter
490
491
  };
491
492
  }
492
493
  const resolvedExpression = this.resolveValueToExpression(operator.value);
@@ -519,7 +520,7 @@ class SparqlQueryBuilder {
519
520
  values: [
520
521
  {
521
522
  type: 'values',
522
- values: resolvedValue.map((value) => ({ [`?${leftSide.value}`]: value })),
523
+ values: resolvedValue.map((value) => ({ [`?${leftSide.value}`]: value }))
523
524
  },
524
525
  ],
525
526
  };
@@ -536,7 +537,7 @@ class SparqlQueryBuilder {
536
537
  return {
537
538
  triples: [],
538
539
  values: [],
539
- filters: [(0, SparqlUtil_1.createSparqlEqualOperation)(leftSide, this.resolveValueToExpression(operator.value))],
540
+ filters: [(0, SparqlUtil_1.createSparqlEqualOperation)(leftSide, this.resolveValueToExpression(operator.value))]
540
541
  };
541
542
  default:
542
543
  throw new Error(`Unsupported operator "${operator.operator}"`);
@@ -571,7 +572,7 @@ class SparqlQueryBuilder {
571
572
  filterExpression = (0, SparqlUtil_1.createSparqlFilterWithExpression)((0, SparqlUtil_1.createSparqlEqualOperation)(leftSide, rightSide));
572
573
  }
573
574
  return (0, SparqlUtil_1.createSparqlNotExistsOperation)([
574
- (0, SparqlUtil_1.createSparqlSelectGroup)([(0, SparqlUtil_1.createSparqlBasicGraphPattern)([triple]), filterExpression]),
575
+ (0, SparqlUtil_1.createSparqlSelectGroup)([(0, SparqlUtil_1.createSparqlBasicGraphPattern)([triple]), filterExpression])
575
576
  ]);
576
577
  }
577
578
  buildNotOperationForId(leftSide, rightSide) {
@@ -617,7 +618,7 @@ class SparqlQueryBuilder {
617
618
  const inverseRelationTriple = {
618
619
  subject,
619
620
  predicate: (0, SparqlUtil_1.createSparqlInversePredicate)([predicate]),
620
- object: variable,
621
+ object: variable
621
622
  };
622
623
  const subRelationOperatorValue = orderValue
623
624
  .value;
@@ -632,11 +633,11 @@ class SparqlQueryBuilder {
632
633
  const aggregateExpression = {
633
634
  type: 'aggregate',
634
635
  expression: baseExpression,
635
- aggregation: order.descending ? 'max' : 'min',
636
+ aggregation: order.descending ? 'max' : 'min'
636
637
  };
637
638
  return {
638
639
  expression: aggregateExpression,
639
- descending: order.descending,
640
+ descending: order.descending
640
641
  };
641
642
  });
642
643
  return {
@@ -644,7 +645,7 @@ class SparqlQueryBuilder {
644
645
  filters: subRelationWhereQueryData.filters,
645
646
  orders: aggregateOrders,
646
647
  groupByParent: true,
647
- patterns: [...subRelationWhereQueryData.patterns ?? [], ...subRelationOrderQueryData.patterns ?? []],
648
+ patterns: [...subRelationWhereQueryData.patterns ?? [], ...subRelationOrderQueryData.patterns ?? []]
648
649
  };
649
650
  }
650
651
  if (property === 'id') {
@@ -654,9 +655,9 @@ class SparqlQueryBuilder {
654
655
  orders: [
655
656
  {
656
657
  expression: subject,
657
- descending: orderValue === 'DESC' || orderValue === 'desc',
658
- },
659
- ],
658
+ descending: orderValue === 'DESC' || orderValue === 'desc'
659
+ }
660
+ ]
660
661
  };
661
662
  }
662
663
  const variable = this.createVariable();
@@ -670,12 +671,12 @@ class SparqlQueryBuilder {
670
671
  ? {
671
672
  type: 'aggregate',
672
673
  expression: variable,
673
- aggregation: isDescending ? 'max' : 'min',
674
+ aggregation: isDescending ? 'max' : 'min'
674
675
  }
675
676
  : variable,
676
- descending: isDescending,
677
- },
678
- ],
677
+ descending: isDescending
678
+ }
679
+ ]
679
680
  };
680
681
  }
681
682
  createRelationsQueryData(subject, relations) {
@@ -689,28 +690,28 @@ class SparqlQueryBuilder {
689
690
  const { patterns, selectionTriples } = this.createRelationsQueryDataForInverseRelation(subject, predicate, relationsValue);
690
691
  return {
691
692
  patterns: [...obj.patterns, ...patterns],
692
- selectionTriples: [...obj.selectionTriples, ...selectionTriples],
693
+ selectionTriples: [...obj.selectionTriples, ...selectionTriples]
693
694
  };
694
695
  }
695
696
  const { patterns, selectionTriples } = this.createRelationsQueryDataForNestedRelation(subject, predicate, relationsValue);
696
697
  return {
697
698
  patterns: [...obj.patterns, ...patterns],
698
- selectionTriples: [...obj.selectionTriples, ...selectionTriples],
699
+ selectionTriples: [...obj.selectionTriples, ...selectionTriples]
699
700
  };
700
701
  }
701
702
  const variable = this.createVariable();
702
703
  const graphTriple = {
703
704
  subject: this.createVariable(),
704
705
  predicate: this.createVariable(),
705
- object: this.createVariable(),
706
+ object: this.createVariable()
706
707
  };
707
708
  const relationPattern = (0, SparqlUtil_1.createSparqlOptional)([
708
709
  (0, SparqlUtil_1.createSparqlBasicGraphPattern)([{ subject, predicate, object: variable }]),
709
- (0, SparqlUtil_1.createSparqlGraphPattern)(variable, [(0, SparqlUtil_1.createSparqlBasicGraphPattern)([graphTriple])]),
710
+ (0, SparqlUtil_1.createSparqlGraphPattern)(variable, [(0, SparqlUtil_1.createSparqlBasicGraphPattern)([graphTriple])])
710
711
  ]);
711
712
  return {
712
713
  patterns: [...obj.patterns, relationPattern],
713
- selectionTriples: [...obj.selectionTriples, graphTriple],
714
+ selectionTriples: [...obj.selectionTriples, graphTriple]
714
715
  };
715
716
  }, { patterns: [], selectionTriples: [] });
716
717
  }
@@ -719,32 +720,32 @@ class SparqlQueryBuilder {
719
720
  const graphTriple = {
720
721
  subject: this.createVariable(),
721
722
  predicate: this.createVariable(),
722
- object: this.createVariable(),
723
+ object: this.createVariable()
723
724
  };
724
725
  const inverseRelationTriple = {
725
726
  subject,
726
727
  predicate: (0, SparqlUtil_1.createSparqlInversePredicate)([predicate]),
727
- object: variable,
728
+ object: variable
728
729
  };
729
730
  if (typeof relationsValue.value === 'object' && relationsValue.value.relations) {
730
731
  const subRelationsQueryData = this.createRelationsQueryData(variable, relationsValue.value.relations);
731
732
  const relationPattern = (0, SparqlUtil_1.createSparqlOptional)([
732
733
  (0, SparqlUtil_1.createSparqlBasicGraphPattern)([inverseRelationTriple]),
733
734
  (0, SparqlUtil_1.createSparqlGraphPattern)(variable, [(0, SparqlUtil_1.createSparqlBasicGraphPattern)([graphTriple])]),
734
- ...subRelationsQueryData.patterns,
735
+ ...subRelationsQueryData.patterns
735
736
  ]);
736
737
  return {
737
738
  patterns: [relationPattern],
738
- selectionTriples: [graphTriple, ...subRelationsQueryData.selectionTriples],
739
+ selectionTriples: [graphTriple, ...subRelationsQueryData.selectionTriples]
739
740
  };
740
741
  }
741
742
  const relationPattern = (0, SparqlUtil_1.createSparqlOptional)([
742
743
  (0, SparqlUtil_1.createSparqlBasicGraphPattern)([inverseRelationTriple]),
743
- (0, SparqlUtil_1.createSparqlGraphPattern)(variable, [(0, SparqlUtil_1.createSparqlBasicGraphPattern)([graphTriple])]),
744
+ (0, SparqlUtil_1.createSparqlGraphPattern)(variable, [(0, SparqlUtil_1.createSparqlBasicGraphPattern)([graphTriple])])
744
745
  ]);
745
746
  return {
746
747
  patterns: [relationPattern],
747
- selectionTriples: [graphTriple],
748
+ selectionTriples: [graphTriple]
748
749
  };
749
750
  }
750
751
  createRelationsQueryDataForNestedRelation(subject, predicate, relationsValue) {
@@ -752,18 +753,18 @@ class SparqlQueryBuilder {
752
753
  const graphTriple = {
753
754
  subject: this.createVariable(),
754
755
  predicate: this.createVariable(),
755
- object: this.createVariable(),
756
+ object: this.createVariable()
756
757
  };
757
758
  const relationTriple = { subject, predicate, object: variable };
758
759
  const subRelationsQueryData = this.createRelationsQueryData(variable, relationsValue);
759
760
  const relationPattern = (0, SparqlUtil_1.createSparqlOptional)([
760
761
  (0, SparqlUtil_1.createSparqlBasicGraphPattern)([relationTriple]),
761
762
  (0, SparqlUtil_1.createSparqlGraphPattern)(variable, [(0, SparqlUtil_1.createSparqlBasicGraphPattern)([graphTriple])]),
762
- ...subRelationsQueryData.patterns,
763
+ ...subRelationsQueryData.patterns
763
764
  ]);
764
765
  return {
765
766
  patterns: [relationPattern],
766
- selectionTriples: [graphTriple, ...subRelationsQueryData.selectionTriples],
767
+ selectionTriples: [graphTriple, ...subRelationsQueryData.selectionTriples]
767
768
  };
768
769
  }
769
770
  createVariable() {
@@ -774,7 +775,7 @@ class SparqlQueryBuilder {
774
775
  return select.map((selectPredicate) => ({
775
776
  subject,
776
777
  predicate: data_model_1.default.namedNode(selectPredicate),
777
- object: this.createVariable(),
778
+ object: this.createVariable()
778
779
  }));
779
780
  }
780
781
  return Object.entries(select).reduce((arr, [key, value]) => {
@@ -828,22 +829,22 @@ class SparqlQueryBuilder {
828
829
  {
829
830
  subject: currentSubject,
830
831
  predicate: data_model_1.default.namedNode(predicate),
831
- object,
832
- },
833
- ],
832
+ object
833
+ }
834
+ ]
834
835
  });
835
836
  currentSubject = object;
836
837
  });
837
838
  // Return the final variable (last object) and all patterns
838
839
  return {
839
840
  variable: currentSubject,
840
- patterns,
841
+ patterns
841
842
  };
842
843
  }
843
844
  async buildGroupByQuery(options) {
844
845
  const entityVariable = data_model_1.default.variable('entity');
845
846
  const queryData = this.buildEntitySelectPatternsFromOptions(entityVariable, {
846
- where: options.where || {},
847
+ where: options.where || {}
847
848
  });
848
849
  // Add group variables and patterns with mapping
849
850
  const groupVariables = [];
@@ -866,10 +867,10 @@ class SparqlQueryBuilder {
866
867
  triples: [
867
868
  {
868
869
  subject: entityVariable,
869
- predicate: data_model_1.default.namedNode('http://purl.org/dc/terms/created'),
870
- object: dateVar,
871
- },
872
- ],
870
+ predicate: data_model_1.default.namedNode(constants_1.EngineConstants.prop.dateCreated),
871
+ object: dateVar
872
+ }
873
+ ]
873
874
  };
874
875
  const dateFilter = {
875
876
  type: 'filter',
@@ -882,16 +883,16 @@ class SparqlQueryBuilder {
882
883
  operator: '>=',
883
884
  args: [
884
885
  dateVar,
885
- data_model_1.default.literal(options.dateRange.start, 'http://www.w3.org/2001/XMLSchema#dateTime'),
886
- ],
886
+ data_model_1.default.literal(options.dateRange.start, constants_1.XSD.dateTime)
887
+ ]
887
888
  },
888
889
  {
889
890
  type: 'operation',
890
891
  operator: '<=',
891
- args: [dateVar, data_model_1.default.literal(options.dateRange.end, 'http://www.w3.org/2001/XMLSchema#dateTime')],
892
- },
893
- ],
894
- },
892
+ args: [dateVar, data_model_1.default.literal(options.dateRange.end, constants_1.XSD.dateTime)]
893
+ }
894
+ ]
895
+ }
895
896
  };
896
897
  groupPatterns.push(datePattern, dateFilter);
897
898
  if (options.dateGrouping) {
@@ -917,9 +918,9 @@ class SparqlQueryBuilder {
917
918
  type: 'aggregate',
918
919
  aggregation: 'count',
919
920
  distinct: true,
920
- expression: entityVariable,
921
+ expression: entityVariable
921
922
  },
922
- variable: countVar,
923
+ variable: countVar
923
924
  },
924
925
  {
925
926
  expression: {
@@ -927,10 +928,10 @@ class SparqlQueryBuilder {
927
928
  aggregation: 'group_concat',
928
929
  distinct: true,
929
930
  separator: ' ',
930
- expression: entityVariable,
931
+ expression: entityVariable
931
932
  },
932
- variable: entityIdsVar,
933
- },
933
+ variable: entityIdsVar
934
+ }
934
935
  ], combinedWhere, [], // Orders
935
936
  groupVariables.length > 0 ? groupVariables : undefined, // Group by
936
937
  options.limit, options.offset);
@@ -947,10 +948,10 @@ class SparqlQueryBuilder {
947
948
  this.createYearExpression(dateVar),
948
949
  data_model_1.default.literal('-'),
949
950
  this.createMonthExpression(dateVar),
950
- ...this.createDayExpressionParts(dateVar, grouping),
951
- ],
951
+ ...this.createDayExpressionParts(dateVar, grouping)
952
+ ]
952
953
  },
953
- variable: dateGroupVar,
954
+ variable: dateGroupVar
954
955
  };
955
956
  }
956
957
  createYearExpression(dateVar) {
@@ -961,9 +962,9 @@ class SparqlQueryBuilder {
961
962
  {
962
963
  type: 'operation',
963
964
  operator: 'YEAR',
964
- args: [dateVar],
965
- },
966
- ],
965
+ args: [dateVar]
966
+ }
967
+ ]
967
968
  };
968
969
  }
969
970
  createMonthExpression(dateVar) {
@@ -973,15 +974,15 @@ class SparqlQueryBuilder {
973
974
  return this.createPaddedDatePartExpression(dateVar, 'DAY');
974
975
  }
975
976
  createPaddedDatePartExpression(dateVar, datePart) {
976
- const comparisonValue = data_model_1.default.literal('10', data_model_1.default.namedNode('http://www.w3.org/2001/XMLSchema#integer'));
977
+ const comparisonValue = data_model_1.default.literal('10', constants_1.XSD.integer);
977
978
  return {
978
979
  type: 'operation',
979
980
  operator: 'IF',
980
981
  args: [
981
982
  this.createLessThanComparison(dateVar, datePart, comparisonValue),
982
983
  this.createPaddedStringExpression(dateVar, datePart),
983
- this.createUnpaddedStringExpression(dateVar, datePart),
984
- ],
984
+ this.createUnpaddedStringExpression(dateVar, datePart)
985
+ ]
985
986
  };
986
987
  }
987
988
  createLessThanComparison(dateVar, datePart, comparisonValue) {
@@ -992,17 +993,17 @@ class SparqlQueryBuilder {
992
993
  {
993
994
  type: 'operation',
994
995
  operator: datePart,
995
- args: [dateVar],
996
+ args: [dateVar]
996
997
  },
997
- comparisonValue,
998
- ],
998
+ comparisonValue
999
+ ]
999
1000
  };
1000
1001
  }
1001
1002
  createPaddedStringExpression(dateVar, datePart) {
1002
1003
  return {
1003
1004
  type: 'operation',
1004
1005
  operator: 'CONCAT',
1005
- args: [data_model_1.default.literal('0'), this.createUnpaddedStringExpression(dateVar, datePart)],
1006
+ args: [data_model_1.default.literal('0'), this.createUnpaddedStringExpression(dateVar, datePart)]
1006
1007
  };
1007
1008
  }
1008
1009
  createUnpaddedStringExpression(dateVar, datePart) {
@@ -1013,9 +1014,9 @@ class SparqlQueryBuilder {
1013
1014
  {
1014
1015
  type: 'operation',
1015
1016
  operator: datePart,
1016
- args: [dateVar],
1017
- },
1018
- ],
1017
+ args: [dateVar]
1018
+ }
1019
+ ]
1019
1020
  };
1020
1021
  }
1021
1022
  createDayExpressionParts(dateVar, grouping) {