@traqula/generator-sparql-1-1 0.0.9 → 0.0.12
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.
- package/lib/index.cjs +103 -40
- package/package.json +6 -6
package/lib/index.cjs
CHANGED
|
@@ -9675,58 +9675,115 @@ function createToken2(config) {
|
|
|
9675
9675
|
return createToken(config);
|
|
9676
9676
|
}
|
|
9677
9677
|
|
|
9678
|
-
// ../../packages/core/lib/
|
|
9679
|
-
var
|
|
9680
|
-
|
|
9681
|
-
|
|
9682
|
-
|
|
9683
|
-
|
|
9684
|
-
|
|
9685
|
-
|
|
9686
|
-
return patch(copy3);
|
|
9678
|
+
// ../../packages/core/lib/Transformers.ts
|
|
9679
|
+
var TransformerType = class {
|
|
9680
|
+
safeObjectVisit(value, mapper) {
|
|
9681
|
+
if (value && typeof value === "object") {
|
|
9682
|
+
if (Array.isArray(value)) {
|
|
9683
|
+
return value.map((x) => this.safeObjectVisit(x, mapper));
|
|
9684
|
+
}
|
|
9685
|
+
return mapper(value);
|
|
9687
9686
|
}
|
|
9688
|
-
return
|
|
9687
|
+
return value;
|
|
9689
9688
|
}
|
|
9690
|
-
|
|
9689
|
+
transformNode(curObject, nodeCallBacks) {
|
|
9690
|
+
let continueCheck;
|
|
9691
|
+
let transformation;
|
|
9692
|
+
const casted = curObject;
|
|
9693
|
+
if (casted.type) {
|
|
9694
|
+
continueCheck = nodeCallBacks[casted.type]?.continue;
|
|
9695
|
+
transformation = nodeCallBacks[casted.type]?.transform;
|
|
9696
|
+
}
|
|
9697
|
+
let shouldContinue = true;
|
|
9698
|
+
if (continueCheck) {
|
|
9699
|
+
shouldContinue = continueCheck(curObject);
|
|
9700
|
+
}
|
|
9701
|
+
if (!shouldContinue) {
|
|
9702
|
+
return curObject;
|
|
9703
|
+
}
|
|
9691
9704
|
const copy3 = { ...curObject };
|
|
9692
9705
|
for (const [key, value] of Object.entries(copy3)) {
|
|
9693
|
-
copy3[key] = this.safeObjectVisit(value, (obj) => this.
|
|
9706
|
+
copy3[key] = this.safeObjectVisit(value, (obj) => this.transformNode(obj, nodeCallBacks));
|
|
9694
9707
|
}
|
|
9695
|
-
if (
|
|
9696
|
-
return
|
|
9708
|
+
if (transformation) {
|
|
9709
|
+
return transformation(copy3);
|
|
9697
9710
|
}
|
|
9698
9711
|
return copy3;
|
|
9699
9712
|
}
|
|
9700
|
-
|
|
9701
|
-
|
|
9702
|
-
|
|
9713
|
+
visitNode(curObject, nodeCallBacks) {
|
|
9714
|
+
let callback;
|
|
9715
|
+
const casted = curObject;
|
|
9716
|
+
if (casted.type) {
|
|
9717
|
+
callback = nodeCallBacks[casted.type];
|
|
9703
9718
|
}
|
|
9704
|
-
|
|
9705
|
-
|
|
9706
|
-
|
|
9707
|
-
this.safeObjectVisit(value, (obj) => this.visitNode(obj, searchType, visitor));
|
|
9719
|
+
let shouldIterate = true;
|
|
9720
|
+
if (callback) {
|
|
9721
|
+
shouldIterate = callback(curObject);
|
|
9708
9722
|
}
|
|
9709
|
-
if (
|
|
9710
|
-
|
|
9723
|
+
if (shouldIterate) {
|
|
9724
|
+
for (const value of Object.values(curObject)) {
|
|
9725
|
+
this.safeObjectVisit(value, (obj) => this.visitNode(obj, nodeCallBacks));
|
|
9726
|
+
}
|
|
9711
9727
|
}
|
|
9712
9728
|
}
|
|
9713
|
-
|
|
9714
|
-
|
|
9715
|
-
|
|
9729
|
+
};
|
|
9730
|
+
var TransformerSubType = class extends TransformerType {
|
|
9731
|
+
// Public visitObjects(curObject: object, visitor: (current: object) => void): void {
|
|
9732
|
+
// for (const value of Object.values(curObject)) {
|
|
9733
|
+
// this.safeObjectVisit(value, obj => this.visitObjects(obj, visitor));
|
|
9734
|
+
// }
|
|
9735
|
+
// }
|
|
9736
|
+
transformNodeSpecific(curObject, nodeCallBacks, nodeSpecificCallBacks = {}) {
|
|
9737
|
+
let continueCheck;
|
|
9738
|
+
let transformation;
|
|
9739
|
+
const casted = curObject;
|
|
9740
|
+
if (casted.type && casted.subType) {
|
|
9741
|
+
const specific = nodeSpecificCallBacks[casted.type];
|
|
9742
|
+
if (specific) {
|
|
9743
|
+
continueCheck = specific[casted.subType]?.continue;
|
|
9744
|
+
transformation = specific[casted.subType]?.transform;
|
|
9745
|
+
}
|
|
9716
9746
|
}
|
|
9717
|
-
|
|
9718
|
-
if (
|
|
9719
|
-
|
|
9747
|
+
let shouldContinue = true;
|
|
9748
|
+
if (continueCheck) {
|
|
9749
|
+
shouldContinue = continueCheck(curObject);
|
|
9720
9750
|
}
|
|
9751
|
+
if (!shouldContinue) {
|
|
9752
|
+
return curObject;
|
|
9753
|
+
}
|
|
9754
|
+
const copy3 = { ...curObject };
|
|
9755
|
+
for (const [key, value] of Object.entries(copy3)) {
|
|
9756
|
+
copy3[key] = this.safeObjectVisit(value, (obj) => this.transformNodeSpecific(obj, nodeCallBacks, nodeSpecificCallBacks));
|
|
9757
|
+
}
|
|
9758
|
+
if (transformation) {
|
|
9759
|
+
return transformation(copy3);
|
|
9760
|
+
}
|
|
9761
|
+
return copy3;
|
|
9721
9762
|
}
|
|
9722
|
-
|
|
9723
|
-
|
|
9724
|
-
|
|
9725
|
-
|
|
9763
|
+
/**
|
|
9764
|
+
* When both nodeCallBack and NodeSpecific callBack are matched, will only look at nodeSpecifCallback
|
|
9765
|
+
*/
|
|
9766
|
+
visitNodeSpecific(curObject, nodeCallBacks, nodeSpecificCallBacks = {}) {
|
|
9767
|
+
let callback;
|
|
9768
|
+
const casted = curObject;
|
|
9769
|
+
if (casted.type && casted.subType) {
|
|
9770
|
+
const specific = nodeSpecificCallBacks[casted.type];
|
|
9771
|
+
if (specific) {
|
|
9772
|
+
callback = specific[casted.subType];
|
|
9773
|
+
}
|
|
9774
|
+
}
|
|
9775
|
+
if (!callback && casted.type) {
|
|
9776
|
+
callback = nodeCallBacks[curObject.type];
|
|
9777
|
+
}
|
|
9778
|
+
let shouldIterate = true;
|
|
9779
|
+
if (callback) {
|
|
9780
|
+
shouldIterate = callback(curObject) ?? true;
|
|
9781
|
+
}
|
|
9782
|
+
if (shouldIterate) {
|
|
9783
|
+
for (const value of Object.values(curObject)) {
|
|
9784
|
+
this.safeObjectVisit(value, (obj) => this.visitNodeSpecific(obj, nodeCallBacks, nodeSpecificCallBacks));
|
|
9726
9785
|
}
|
|
9727
|
-
return mapper(value);
|
|
9728
9786
|
}
|
|
9729
|
-
return value;
|
|
9730
9787
|
}
|
|
9731
9788
|
};
|
|
9732
9789
|
|
|
@@ -11317,9 +11374,13 @@ var Factory = class extends asArg(CoreFactory).call(ContextFactoryMixin).call(Ex
|
|
|
11317
11374
|
}
|
|
11318
11375
|
};
|
|
11319
11376
|
|
|
11377
|
+
// ../../packages/rules-sparql-1-1/lib/utils.ts
|
|
11378
|
+
var TransformerSparql11 = class extends TransformerSubType {
|
|
11379
|
+
};
|
|
11380
|
+
|
|
11320
11381
|
// ../../packages/rules-sparql-1-1/lib/validation/validators.ts
|
|
11321
11382
|
var F = new Factory();
|
|
11322
|
-
var transformer = new
|
|
11383
|
+
var transformer = new TransformerSparql11();
|
|
11323
11384
|
function getAggregatesOfExpression(expression2) {
|
|
11324
11385
|
if (F.isExpressionAggregate(expression2)) {
|
|
11325
11386
|
return [expression2];
|
|
@@ -11468,7 +11529,9 @@ function checkNote13(patterns) {
|
|
|
11468
11529
|
if (F.isPatternBind(pattern) && index > 0 && F.isPatternBgp(patterns[index - 1])) {
|
|
11469
11530
|
const bgp = patterns[index - 1];
|
|
11470
11531
|
const variables = [];
|
|
11471
|
-
transformer.visitNodeSpecific(bgp,
|
|
11532
|
+
transformer.visitNodeSpecific(bgp, {}, { term: { variable: (var_2) => {
|
|
11533
|
+
variables.push(var_2);
|
|
11534
|
+
} } });
|
|
11472
11535
|
if (variables.some((var_2) => var_2.value === pattern.variable.value)) {
|
|
11473
11536
|
throw new Error(`Variable used to bind is already bound (?${pattern.variable.value})`);
|
|
11474
11537
|
}
|
|
@@ -11494,12 +11557,12 @@ function updateNoReuseBlankNodeLabels(updateQuery) {
|
|
|
11494
11557
|
const operation = update2.operation;
|
|
11495
11558
|
if (operation.subType === "insertdata") {
|
|
11496
11559
|
const blankNodesHere = /* @__PURE__ */ new Set();
|
|
11497
|
-
transformer.visitNodeSpecific(operation,
|
|
11560
|
+
transformer.visitNodeSpecific(operation, {}, { term: { blankNode: (blankNode2) => {
|
|
11498
11561
|
blankNodesHere.add(blankNode2.label);
|
|
11499
11562
|
if (blankLabelsUsedInInsertData.has(blankNode2.label)) {
|
|
11500
11563
|
throw new Error("Detected reuse blank node across different INSERT DATA clauses");
|
|
11501
11564
|
}
|
|
11502
|
-
});
|
|
11565
|
+
} } });
|
|
11503
11566
|
for (const blankNode2 of blankNodesHere) {
|
|
11504
11567
|
blankLabelsUsedInInsertData.add(blankNode2);
|
|
11505
11568
|
}
|
|
@@ -12334,7 +12397,7 @@ var aggregate = {
|
|
|
12334
12397
|
},
|
|
12335
12398
|
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
|
|
12336
12399
|
F2.printFilter(ast, () => {
|
|
12337
|
-
PRINT_WORD(ast.aggregation, "(");
|
|
12400
|
+
PRINT_WORD(ast.aggregation.toUpperCase(), "(");
|
|
12338
12401
|
if (ast.distinct) {
|
|
12339
12402
|
PRINT_WORD("DISTINCT");
|
|
12340
12403
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@traqula/generator-sparql-1-1",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.12",
|
|
5
5
|
"description": "SPARQL 1.1 generator",
|
|
6
6
|
"lsd:module": true,
|
|
7
7
|
"license": "MIT",
|
|
@@ -41,13 +41,13 @@
|
|
|
41
41
|
"build:transpile": " node \"../../node_modules/esbuild/bin/esbuild\" --format=cjs --bundle --log-level=error --outfile=lib/index.cjs lib/index.ts"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@traqula/core": "^0.0.
|
|
45
|
-
"@traqula/rules-sparql-1-1": "^0.0.
|
|
44
|
+
"@traqula/core": "^0.0.12",
|
|
45
|
+
"@traqula/rules-sparql-1-1": "^0.0.12"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@traqula/parser-sparql-1-1": "^0.0.
|
|
48
|
+
"@traqula/parser-sparql-1-1": "^0.0.12",
|
|
49
49
|
"@traqula/rules-sparql-1-1": "^0.0.1",
|
|
50
|
-
"@traqula/test-utils": "^0.0.
|
|
50
|
+
"@traqula/test-utils": "^0.0.12"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "3517d5a5223c64dc61184b5f603f6d98c12bd166"
|
|
53
53
|
}
|