@traqula/rules-sparql-1-1-adjust 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 +4 -4
package/lib/index.cjs
CHANGED
|
@@ -9765,58 +9765,115 @@ function createToken2(config) {
|
|
|
9765
9765
|
return createToken(config);
|
|
9766
9766
|
}
|
|
9767
9767
|
|
|
9768
|
-
// ../core/lib/
|
|
9769
|
-
var
|
|
9770
|
-
|
|
9771
|
-
|
|
9772
|
-
|
|
9773
|
-
|
|
9774
|
-
|
|
9775
|
-
|
|
9776
|
-
return patch(copy3);
|
|
9768
|
+
// ../core/lib/Transformers.ts
|
|
9769
|
+
var TransformerType = class {
|
|
9770
|
+
safeObjectVisit(value, mapper) {
|
|
9771
|
+
if (value && typeof value === "object") {
|
|
9772
|
+
if (Array.isArray(value)) {
|
|
9773
|
+
return value.map((x) => this.safeObjectVisit(x, mapper));
|
|
9774
|
+
}
|
|
9775
|
+
return mapper(value);
|
|
9777
9776
|
}
|
|
9778
|
-
return
|
|
9777
|
+
return value;
|
|
9779
9778
|
}
|
|
9780
|
-
|
|
9779
|
+
transformNode(curObject, nodeCallBacks) {
|
|
9780
|
+
let continueCheck;
|
|
9781
|
+
let transformation;
|
|
9782
|
+
const casted = curObject;
|
|
9783
|
+
if (casted.type) {
|
|
9784
|
+
continueCheck = nodeCallBacks[casted.type]?.continue;
|
|
9785
|
+
transformation = nodeCallBacks[casted.type]?.transform;
|
|
9786
|
+
}
|
|
9787
|
+
let shouldContinue = true;
|
|
9788
|
+
if (continueCheck) {
|
|
9789
|
+
shouldContinue = continueCheck(curObject);
|
|
9790
|
+
}
|
|
9791
|
+
if (!shouldContinue) {
|
|
9792
|
+
return curObject;
|
|
9793
|
+
}
|
|
9781
9794
|
const copy3 = { ...curObject };
|
|
9782
9795
|
for (const [key, value] of Object.entries(copy3)) {
|
|
9783
|
-
copy3[key] = this.safeObjectVisit(value, (obj) => this.
|
|
9796
|
+
copy3[key] = this.safeObjectVisit(value, (obj) => this.transformNode(obj, nodeCallBacks));
|
|
9784
9797
|
}
|
|
9785
|
-
if (
|
|
9786
|
-
return
|
|
9798
|
+
if (transformation) {
|
|
9799
|
+
return transformation(copy3);
|
|
9787
9800
|
}
|
|
9788
9801
|
return copy3;
|
|
9789
9802
|
}
|
|
9790
|
-
|
|
9791
|
-
|
|
9792
|
-
|
|
9803
|
+
visitNode(curObject, nodeCallBacks) {
|
|
9804
|
+
let callback;
|
|
9805
|
+
const casted = curObject;
|
|
9806
|
+
if (casted.type) {
|
|
9807
|
+
callback = nodeCallBacks[casted.type];
|
|
9793
9808
|
}
|
|
9794
|
-
|
|
9795
|
-
|
|
9796
|
-
|
|
9797
|
-
this.safeObjectVisit(value, (obj) => this.visitNode(obj, searchType, visitor));
|
|
9809
|
+
let shouldIterate = true;
|
|
9810
|
+
if (callback) {
|
|
9811
|
+
shouldIterate = callback(curObject);
|
|
9798
9812
|
}
|
|
9799
|
-
if (
|
|
9800
|
-
|
|
9813
|
+
if (shouldIterate) {
|
|
9814
|
+
for (const value of Object.values(curObject)) {
|
|
9815
|
+
this.safeObjectVisit(value, (obj) => this.visitNode(obj, nodeCallBacks));
|
|
9816
|
+
}
|
|
9801
9817
|
}
|
|
9802
9818
|
}
|
|
9803
|
-
|
|
9804
|
-
|
|
9805
|
-
|
|
9819
|
+
};
|
|
9820
|
+
var TransformerSubType = class extends TransformerType {
|
|
9821
|
+
// Public visitObjects(curObject: object, visitor: (current: object) => void): void {
|
|
9822
|
+
// for (const value of Object.values(curObject)) {
|
|
9823
|
+
// this.safeObjectVisit(value, obj => this.visitObjects(obj, visitor));
|
|
9824
|
+
// }
|
|
9825
|
+
// }
|
|
9826
|
+
transformNodeSpecific(curObject, nodeCallBacks, nodeSpecificCallBacks = {}) {
|
|
9827
|
+
let continueCheck;
|
|
9828
|
+
let transformation;
|
|
9829
|
+
const casted = curObject;
|
|
9830
|
+
if (casted.type && casted.subType) {
|
|
9831
|
+
const specific = nodeSpecificCallBacks[casted.type];
|
|
9832
|
+
if (specific) {
|
|
9833
|
+
continueCheck = specific[casted.subType]?.continue;
|
|
9834
|
+
transformation = specific[casted.subType]?.transform;
|
|
9835
|
+
}
|
|
9806
9836
|
}
|
|
9807
|
-
|
|
9808
|
-
if (
|
|
9809
|
-
|
|
9837
|
+
let shouldContinue = true;
|
|
9838
|
+
if (continueCheck) {
|
|
9839
|
+
shouldContinue = continueCheck(curObject);
|
|
9810
9840
|
}
|
|
9841
|
+
if (!shouldContinue) {
|
|
9842
|
+
return curObject;
|
|
9843
|
+
}
|
|
9844
|
+
const copy3 = { ...curObject };
|
|
9845
|
+
for (const [key, value] of Object.entries(copy3)) {
|
|
9846
|
+
copy3[key] = this.safeObjectVisit(value, (obj) => this.transformNodeSpecific(obj, nodeCallBacks, nodeSpecificCallBacks));
|
|
9847
|
+
}
|
|
9848
|
+
if (transformation) {
|
|
9849
|
+
return transformation(copy3);
|
|
9850
|
+
}
|
|
9851
|
+
return copy3;
|
|
9811
9852
|
}
|
|
9812
|
-
|
|
9813
|
-
|
|
9814
|
-
|
|
9815
|
-
|
|
9853
|
+
/**
|
|
9854
|
+
* When both nodeCallBack and NodeSpecific callBack are matched, will only look at nodeSpecifCallback
|
|
9855
|
+
*/
|
|
9856
|
+
visitNodeSpecific(curObject, nodeCallBacks, nodeSpecificCallBacks = {}) {
|
|
9857
|
+
let callback;
|
|
9858
|
+
const casted = curObject;
|
|
9859
|
+
if (casted.type && casted.subType) {
|
|
9860
|
+
const specific = nodeSpecificCallBacks[casted.type];
|
|
9861
|
+
if (specific) {
|
|
9862
|
+
callback = specific[casted.subType];
|
|
9863
|
+
}
|
|
9864
|
+
}
|
|
9865
|
+
if (!callback && casted.type) {
|
|
9866
|
+
callback = nodeCallBacks[curObject.type];
|
|
9867
|
+
}
|
|
9868
|
+
let shouldIterate = true;
|
|
9869
|
+
if (callback) {
|
|
9870
|
+
shouldIterate = callback(curObject) ?? true;
|
|
9871
|
+
}
|
|
9872
|
+
if (shouldIterate) {
|
|
9873
|
+
for (const value of Object.values(curObject)) {
|
|
9874
|
+
this.safeObjectVisit(value, (obj) => this.visitNodeSpecific(obj, nodeCallBacks, nodeSpecificCallBacks));
|
|
9816
9875
|
}
|
|
9817
|
-
return mapper(value);
|
|
9818
9876
|
}
|
|
9819
|
-
return value;
|
|
9820
9877
|
}
|
|
9821
9878
|
};
|
|
9822
9879
|
|
|
@@ -11119,9 +11176,13 @@ var Factory = class extends asArg(CoreFactory).call(ContextFactoryMixin).call(Ex
|
|
|
11119
11176
|
}
|
|
11120
11177
|
};
|
|
11121
11178
|
|
|
11179
|
+
// ../rules-sparql-1-1/lib/utils.ts
|
|
11180
|
+
var TransformerSparql11 = class extends TransformerSubType {
|
|
11181
|
+
};
|
|
11182
|
+
|
|
11122
11183
|
// ../rules-sparql-1-1/lib/validation/validators.ts
|
|
11123
11184
|
var F = new Factory();
|
|
11124
|
-
var transformer = new
|
|
11185
|
+
var transformer = new TransformerSparql11();
|
|
11125
11186
|
function getAggregatesOfExpression(expression2) {
|
|
11126
11187
|
if (F.isExpressionAggregate(expression2)) {
|
|
11127
11188
|
return [expression2];
|
|
@@ -11270,7 +11331,9 @@ function checkNote13(patterns) {
|
|
|
11270
11331
|
if (F.isPatternBind(pattern) && index > 0 && F.isPatternBgp(patterns[index - 1])) {
|
|
11271
11332
|
const bgp = patterns[index - 1];
|
|
11272
11333
|
const variables = [];
|
|
11273
|
-
transformer.visitNodeSpecific(bgp,
|
|
11334
|
+
transformer.visitNodeSpecific(bgp, {}, { term: { variable: (var_2) => {
|
|
11335
|
+
variables.push(var_2);
|
|
11336
|
+
} } });
|
|
11274
11337
|
if (variables.some((var_2) => var_2.value === pattern.variable.value)) {
|
|
11275
11338
|
throw new Error(`Variable used to bind is already bound (?${pattern.variable.value})`);
|
|
11276
11339
|
}
|
|
@@ -11296,12 +11359,12 @@ function updateNoReuseBlankNodeLabels(updateQuery) {
|
|
|
11296
11359
|
const operation = update2.operation;
|
|
11297
11360
|
if (operation.subType === "insertdata") {
|
|
11298
11361
|
const blankNodesHere = /* @__PURE__ */ new Set();
|
|
11299
|
-
transformer.visitNodeSpecific(operation,
|
|
11362
|
+
transformer.visitNodeSpecific(operation, {}, { term: { blankNode: (blankNode2) => {
|
|
11300
11363
|
blankNodesHere.add(blankNode2.label);
|
|
11301
11364
|
if (blankLabelsUsedInInsertData.has(blankNode2.label)) {
|
|
11302
11365
|
throw new Error("Detected reuse blank node across different INSERT DATA clauses");
|
|
11303
11366
|
}
|
|
11304
|
-
});
|
|
11367
|
+
} } });
|
|
11305
11368
|
for (const blankNode2 of blankNodesHere) {
|
|
11306
11369
|
blankLabelsUsedInInsertData.add(blankNode2);
|
|
11307
11370
|
}
|
|
@@ -12136,7 +12199,7 @@ var aggregate = {
|
|
|
12136
12199
|
},
|
|
12137
12200
|
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
|
|
12138
12201
|
F2.printFilter(ast, () => {
|
|
12139
|
-
PRINT_WORD(ast.aggregation, "(");
|
|
12202
|
+
PRINT_WORD(ast.aggregation.toUpperCase(), "(");
|
|
12140
12203
|
if (ast.distinct) {
|
|
12141
12204
|
PRINT_WORD("DISTINCT");
|
|
12142
12205
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@traqula/rules-sparql-1-1-adjust",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.12",
|
|
5
5
|
"description": "Traqula Lexer and Grammar Rules for sparql 1.1-ADJUST",
|
|
6
6
|
"lsd:module": true,
|
|
7
7
|
"license": "MIT",
|
|
@@ -41,8 +41,8 @@
|
|
|
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
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "3517d5a5223c64dc61184b5f603f6d98c12bd166"
|
|
48
48
|
}
|