@bitcobblers/wod-wiki-wql 0.6.36 → 0.7.37
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/dist/index.cjs +64 -44
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -6
- package/dist/index.d.ts +8 -6
- package/dist/index.mjs +64 -44
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -162,55 +162,62 @@ function parseWqlSuffixes(raw) {
|
|
|
162
162
|
let groupBy;
|
|
163
163
|
let last;
|
|
164
164
|
let scope;
|
|
165
|
+
const conflicts = [];
|
|
165
166
|
const isFind = text.startsWith("find:");
|
|
166
167
|
const isRows = /^rows(?=[:{]|\s|$)/.test(text);
|
|
168
|
+
const stripRepeated = (re) => {
|
|
169
|
+
const matches = [];
|
|
170
|
+
for (let m = re.exec(text); m; m = re.exec(text)) {
|
|
171
|
+
matches.unshift(m);
|
|
172
|
+
text = text.slice(0, m.index).trim();
|
|
173
|
+
}
|
|
174
|
+
return matches;
|
|
175
|
+
};
|
|
176
|
+
const conflictFrom = (label, ms) => {
|
|
177
|
+
if (ms.length > 1) {
|
|
178
|
+
conflicts.push(
|
|
179
|
+
`Duplicate '${label}' clause: '${ms[0][0].trim()}' conflicts with '${ms[ms.length - 1][0].trim()}'`
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
};
|
|
167
183
|
if (isFind || isRows) {
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
raw: lastMatch[0].trim()
|
|
174
|
-
};
|
|
175
|
-
text = text.slice(0, lastMatch.index).trim();
|
|
184
|
+
const lasts = stripRepeated(LAST_RE);
|
|
185
|
+
conflictFrom("window", lasts);
|
|
186
|
+
if (lasts.length) {
|
|
187
|
+
const m = lasts[lasts.length - 1];
|
|
188
|
+
last = { size: parseInt(m[1], 10), unit: m[2].toLowerCase(), raw: m[0].trim() };
|
|
176
189
|
}
|
|
177
190
|
if (isFind) {
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
text = text.slice(0, scopeMatch.index).trim();
|
|
182
|
-
}
|
|
191
|
+
const scopes = stripRepeated(IN_SCOPE_RE);
|
|
192
|
+
conflictFrom("scope", scopes);
|
|
193
|
+
if (scopes.length) scope = scopes[scopes.length - 1][1];
|
|
183
194
|
} else {
|
|
184
|
-
const
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
195
|
+
const rollups = stripRepeated(ROLLUP_RE);
|
|
196
|
+
conflictFrom(".rollup", rollups);
|
|
197
|
+
if (rollups.length) {
|
|
198
|
+
const m = rollups[rollups.length - 1];
|
|
199
|
+
rollup = { size: m[1] ? parseInt(m[1], 10) : 1, unit: m[2] || "", raw: m[1] + m[2] };
|
|
189
200
|
}
|
|
190
|
-
const
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
201
|
+
const bys = stripRepeated(BY_RE);
|
|
202
|
+
conflictFrom("by", bys);
|
|
203
|
+
if (bys.length) {
|
|
204
|
+
groupBy = bys[bys.length - 1][1].split(",").map((d) => d.trim()).filter(Boolean);
|
|
194
205
|
}
|
|
195
206
|
}
|
|
196
207
|
} else {
|
|
197
|
-
const
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
208
|
+
const units = stripRepeated(DISPLAY_UNIT_RE);
|
|
209
|
+
conflictFrom("display-unit", units);
|
|
210
|
+
if (units.length) displayUnit = units[units.length - 1][1];
|
|
211
|
+
const rollups = stripRepeated(ROLLUP_RE);
|
|
212
|
+
conflictFrom(".rollup", rollups);
|
|
213
|
+
if (rollups.length) {
|
|
214
|
+
const m = rollups[rollups.length - 1];
|
|
215
|
+
rollup = { size: m[1] ? parseInt(m[1], 10) : 1, unit: m[2] || "", raw: m[1] + m[2] };
|
|
201
216
|
}
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
const unit = rollupMatch[2] || "";
|
|
207
|
-
rollup = { size, unit, raw: rawRollup };
|
|
208
|
-
text = text.slice(0, rollupMatch.index).trim();
|
|
209
|
-
}
|
|
210
|
-
const byMatch = BY_RE.exec(text);
|
|
211
|
-
if (byMatch) {
|
|
212
|
-
groupBy = byMatch[1].split(",").map((d) => d.trim()).filter(Boolean);
|
|
213
|
-
text = text.slice(0, byMatch.index).trim();
|
|
217
|
+
const bys = stripRepeated(BY_RE);
|
|
218
|
+
conflictFrom("by", bys);
|
|
219
|
+
if (bys.length) {
|
|
220
|
+
groupBy = bys[bys.length - 1][1].split(",").map((d) => d.trim()).filter(Boolean);
|
|
214
221
|
}
|
|
215
222
|
}
|
|
216
223
|
return {
|
|
@@ -220,6 +227,7 @@ function parseWqlSuffixes(raw) {
|
|
|
220
227
|
groupBy,
|
|
221
228
|
last,
|
|
222
229
|
scope,
|
|
230
|
+
conflicts: conflicts.length ? conflicts : void 0,
|
|
223
231
|
primaryText: text
|
|
224
232
|
};
|
|
225
233
|
}
|
|
@@ -281,6 +289,10 @@ function parseRowsQuery(raw) {
|
|
|
281
289
|
filters: [],
|
|
282
290
|
last: last ? { size: last.size, unit: last.unit } : void 0
|
|
283
291
|
};
|
|
292
|
+
if (suffixes.conflicts?.length) {
|
|
293
|
+
result.error = suffixes.conflicts.join("; ");
|
|
294
|
+
return result;
|
|
295
|
+
}
|
|
284
296
|
if (whereText || groupBy || rollup) {
|
|
285
297
|
result.error = `Rows queries return raw statements \u2014 no where / by / rollup. Got "${primaryText.trim()}"`;
|
|
286
298
|
return result;
|
|
@@ -369,6 +381,10 @@ function parseAnalyticsQuery(raw) {
|
|
|
369
381
|
displayUnit,
|
|
370
382
|
rollup: rollup ? { size: rollup.size, unit: rollup.unit } : void 0
|
|
371
383
|
};
|
|
384
|
+
if (suffixes.conflicts?.length) {
|
|
385
|
+
base.error = suffixes.conflicts.join("; ");
|
|
386
|
+
return base;
|
|
387
|
+
}
|
|
372
388
|
if (rollup && rollup.unit !== "d" && rollup.unit !== "w") {
|
|
373
389
|
base.error = cannotParse(text);
|
|
374
390
|
return base;
|
|
@@ -430,6 +446,10 @@ function parseFindQuery(raw) {
|
|
|
430
446
|
scope,
|
|
431
447
|
last: last ? { size: last.size, unit: last.unit } : void 0
|
|
432
448
|
};
|
|
449
|
+
if (suffixes.conflicts?.length) {
|
|
450
|
+
result.error = suffixes.conflicts.join("; ");
|
|
451
|
+
return result;
|
|
452
|
+
}
|
|
433
453
|
const tree = parser.parse(text);
|
|
434
454
|
let syntaxError = false;
|
|
435
455
|
tree.iterate({ enter(node) {
|
|
@@ -2026,13 +2046,13 @@ sum:$metric{} rollup:1w
|
|
|
2026
2046
|
}
|
|
2027
2047
|
|
|
2028
2048
|
// src/version.ts
|
|
2029
|
-
var VERSION = "0.
|
|
2030
|
-
var GIT_SHA = "
|
|
2031
|
-
var BUILD_TIME = "2026-08-
|
|
2049
|
+
var VERSION = "0.7.37";
|
|
2050
|
+
var GIT_SHA = "713c593";
|
|
2051
|
+
var BUILD_TIME = "2026-08-25T00:18:25.714Z";
|
|
2032
2052
|
var SEMVER = {
|
|
2033
|
-
version: "0.
|
|
2034
|
-
gitSha: "
|
|
2035
|
-
buildTime: "2026-08-
|
|
2053
|
+
version: "0.7.37",
|
|
2054
|
+
gitSha: "713c593",
|
|
2055
|
+
buildTime: "2026-08-25T00:18:25.714Z"
|
|
2036
2056
|
};
|
|
2037
2057
|
|
|
2038
2058
|
exports.BUILD_TIME = BUILD_TIME;
|