@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 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 lastMatch = LAST_RE.exec(text);
169
- if (lastMatch) {
170
- last = {
171
- size: parseInt(lastMatch[1], 10),
172
- unit: lastMatch[2].toLowerCase(),
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 scopeMatch = IN_SCOPE_RE.exec(text);
179
- if (scopeMatch) {
180
- scope = scopeMatch[1];
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 rollupMatch = ROLLUP_RE.exec(text);
185
- if (rollupMatch) {
186
- const rawRollup = rollupMatch[1] + rollupMatch[2];
187
- rollup = { size: rollupMatch[1] ? parseInt(rollupMatch[1], 10) : 1, unit: rollupMatch[2] || "", raw: rawRollup };
188
- text = text.slice(0, rollupMatch.index).trim();
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 byMatch = BY_RE.exec(text);
191
- if (byMatch) {
192
- groupBy = byMatch[1].split(",").map((d) => d.trim()).filter(Boolean);
193
- text = text.slice(0, byMatch.index).trim();
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 unitMatch = DISPLAY_UNIT_RE.exec(text);
198
- if (unitMatch) {
199
- displayUnit = unitMatch[1];
200
- text = text.slice(0, unitMatch.index).trim();
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 rollupMatch = ROLLUP_RE.exec(text);
203
- if (rollupMatch) {
204
- const rawRollup = rollupMatch[1] + rollupMatch[2];
205
- const size = rollupMatch[1] ? parseInt(rollupMatch[1], 10) : 1;
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.6.36";
2030
- var GIT_SHA = "c5ad2b0";
2031
- var BUILD_TIME = "2026-08-24T20:14:33.951Z";
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.6.36",
2034
- gitSha: "c5ad2b0",
2035
- buildTime: "2026-08-24T20:14:33.951Z"
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;