@bitcobblers/wod-wiki-wql 0.6.36 → 0.7.38

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.d.cts CHANGED
@@ -164,6 +164,8 @@ interface ParsedWqlSuffixes {
164
164
  last?: ParsedWqlLastSuffix;
165
165
  /** Content scope (`in journal` / `in all`). */
166
166
  scope?: string;
167
+ /** Duplicate-clause diagnostics (C3) — each names both conflicting spans. */
168
+ conflicts?: string[];
167
169
  /** Primary query text with suffixes removed. */
168
170
  primaryText: string;
169
171
  }
@@ -236,7 +238,12 @@ interface FindPredicate {
236
238
  unit: 'd' | 'w';
237
239
  };
238
240
  }
239
- interface ParsedQuery {
241
+ /**
242
+ * Result of parsing an analytics (aggregate) query — `agg:metric{filters} …`.
243
+ * Discriminated union member: `family === 'aggregate'` (C5).
244
+ */
245
+ interface ParsedAggregateQuery {
246
+ family: 'aggregate';
240
247
  raw: string;
241
248
  agg: Aggregator;
242
249
  /** Canonical Metric Key (fact row `metricKey`). */
@@ -256,6 +263,7 @@ interface ParsedQuery {
256
263
  }
257
264
  /** Result of parsing a content-discovery query (`find:target{filters} in scope`). */
258
265
  interface ParsedFindQuery {
266
+ family: 'find';
259
267
  raw: string;
260
268
  /** Content target: 'note' or 'block'. */
261
269
  target: string;
@@ -271,11 +279,13 @@ interface ParsedFindQuery {
271
279
  join?: MetricPredicate;
272
280
  error?: string;
273
281
  }
274
- type AnyParsedQuery = ParsedQuery | ParsedFindQuery | ParsedRowsQuery;
282
+ type AnyParsedQuery = ParsedAggregateQuery | ParsedFindQuery | ParsedRowsQuery;
275
283
  /** Type guard: true for content-discovery queries. */
276
284
  declare function isFindQuery(parsed: AnyParsedQuery): parsed is ParsedFindQuery;
277
285
  /** Type guard: true for rows queries. */
278
286
  declare function isRowsQuery(parsed: AnyParsedQuery): parsed is ParsedRowsQuery;
287
+ /** Type guard: true for analytics (aggregate) queries. */
288
+ declare function isAggregateQuery(parsed: AnyParsedQuery): parsed is ParsedAggregateQuery;
279
289
  interface SeriesPoint {
280
290
  ts: number;
281
291
  value: number;
@@ -288,7 +298,7 @@ interface SeriesPoint {
288
298
  */
289
299
  interface ParsedRowsQuery {
290
300
  raw: string;
291
- /** Family discriminator (the other families are told apart by 'target'/'agg'). */
301
+ /** Family discriminator shared by all three query ASTs (C5). */
292
302
  family: 'rows';
293
303
  /** Output-statement type narrowing from the optional target (`rows:segment{…}`); undefined = all types. */
294
304
  outputType?: string;
@@ -307,9 +317,10 @@ interface Series {
307
317
  unit?: string;
308
318
  }
309
319
  /**
310
- * Parse a WQL query string into either an analytics ParsedQuery or a content
311
- * ParsedFindQuery. Dispatch is textual: a leading `find:` routes to the
312
- * content path, everything else to analytics.
320
+ * Parse a WQL query string into one of the three query families —
321
+ * analytics aggregate, content find, or rows — discriminated by `family`
322
+ * (C5). Dispatch is textual: a leading `find:` routes to the content path,
323
+ * `rows` to the rows path, everything else to analytics.
313
324
  */
314
325
  declare function parseQuery(raw: string): AnyParsedQuery;
315
326
 
@@ -630,7 +641,7 @@ interface FindOptions {
630
641
  anchorNow?: number;
631
642
  }
632
643
  interface QueryResult {
633
- parsed: ParsedQuery;
644
+ parsed: ParsedAggregateQuery;
634
645
  series: Series[];
635
646
  stages: {
636
647
  selected: number;
@@ -691,7 +702,7 @@ declare class QueryService {
691
702
  * Execute a find:effort query against the effort registry.
692
703
  */
693
704
  runFindEffort(parsed: ParsedFindQuery): Promise<FindQueryResult>;
694
- run(parsed: ParsedQuery, options?: QueryOptions): Promise<QueryResult>;
705
+ run(parsed: ParsedAggregateQuery, options?: QueryOptions): Promise<QueryResult>;
695
706
  /**
696
707
  * Stages 2–4 — BUCKET → GROUP → AGGREGATE over an already-selected +
697
708
  * filtered `matched` set.
@@ -945,13 +956,13 @@ declare function parseFrontmatterProps(lines: string[]): Record<string, string>;
945
956
  * Auto-generated build version metadata.
946
957
  * Do not edit directly; updated by scripts/stamp-version.ts
947
958
  */
948
- declare const VERSION = "0.6.36";
949
- declare const GIT_SHA = "c5ad2b0";
950
- declare const BUILD_TIME = "2026-08-24T20:14:33.951Z";
959
+ declare const VERSION = "0.7.38";
960
+ declare const GIT_SHA = "172cc75";
961
+ declare const BUILD_TIME = "2026-08-25T23:00:14.937Z";
951
962
  declare const SEMVER: {
952
- readonly version: "0.6.36";
953
- readonly gitSha: "c5ad2b0";
954
- readonly buildTime: "2026-08-24T20:14:33.951Z";
963
+ readonly version: "0.7.38";
964
+ readonly gitSha: "172cc75";
965
+ readonly buildTime: "2026-08-25T23:00:14.937Z";
955
966
  };
956
967
 
957
- export { type Aggregator, type AnyParsedQuery, BUILD_TIME, type BlockQueryStore, type ComparisonOp, DASHBOARD_GRID_MAX_COLS, DASHBOARD_WIDGET_TYPES, DEFAULT_DASHBOARD_TITLE, DISCIPLINE_FACTORS, type DashboardDocument, type DashboardMeta, type DashboardParsedSection, type DashboardSectionInput, type DashboardToken, type DashboardWidget, type DashboardWidgetType, EFFORT_DISCIPLINES, type EffortDiscipline, type EffortQueryStore, type EventRowIdentity, type FindOptions, type FindPredicate, type FindQueryResult, GIT_SHA, type IEffort, KG_PER_LB, type LinkWidget, type MetricPredicate, type NoteQueryStore, PLANNED_WIDGET_TYPES, type ParsedFindQuery, type ParsedFrontmatter, type ParsedQuery, type ParsedRowsQuery, type ParsedWqlLastSuffix, type ParsedWqlRollupSuffix, type ParsedWqlSuffixes, type QueryOptions, type QueryResult, QueryService, type QueryServiceStores, type QueryWidgetSuffix, type RowsQueryResult, type RowsRun, SEMVER, type Series, type SeriesPoint, type SummaryFactIdentity, type SummaryFactSourceOutput, type TagFilter, type TagValue, UNIT_FAMILIES, type UnifiedEventStore, type UnitFamily, type UnitFamilyDef, VERSION, WQL_AGGREGATORS, WQL_CALC_TARGETS, WQL_COMPARISON_OPS, WQL_CONTENT_FILTER_KEYS, WQL_DISPLAY_UNITS, WQL_FIND_TARGETS, WQL_GRAINS, WQL_INTENSITY_TIERS, WQL_KEYWORDS, WQL_METRIC_AGGREGATES, WQL_METRIC_FAMILIES, WQL_ROLLUP_PERIODS, WQL_SCOPES, WQL_SOURCES, WQL_TAG_KEYS, WQL_VIRTUAL_DIMS, type WqlAggregator, type WqlCalcTarget, type WqlComparisonOp, type WqlCompletionOptions, type WqlContentFilterKey, type WqlDisplayUnit, type WqlFindTarget, type WqlGrain, type WqlIntensityTier, type WqlKeyword, type WqlMetricAggregate, type WqlMetricFamily, type WqlRollupPeriod, type WqlScope, type WqlSource, type WqlTagKey, type WqlVirtualDim, buildDashboardDocument, buildDashboardScaffold, convert, dashboardSlug, defaultTokenValues, disciplineFactorFor, extractDashboardTokens, extractFrontmatterTags, getList, getScalar, getUnitFamily, isDashboardMeta, isDashboardWidgetType, isEffortDiscipline, isFindQuery, isProposedMetric, isRowsQuery, normalizeSummaryFacts, parseDashboardNote, parseFlatProperties, parseFrontmatter, parseFrontmatterBody, parseFrontmatterCategories, parseFrontmatterProps, parseQuery, parseQueryWidgetSuffix, parseWqlSuffixes, projectEventToFacts, referencedTokens, resolveCanonicalMetricKey, resolveDisplayUnit, resolveWidgetType, serializeFrontmatter, setDashboardTokenValue, splitAtWhere, splitWidgetBody, staticNotesFromBlocks, staticTagIndexFromBlocks, stripFrontmatter, substituteTokens, toEventRows, toSummaryEventRows, unknownTokensMessage, unknownWidgetTypeMessage, wql, wqlCompletion, wqlCompletionSource, wqlHighlightStyle, wqlLanguage, parser as wqlParser, wql_parser_terms as wqlTerms };
968
+ export { type Aggregator, type AnyParsedQuery, BUILD_TIME, type BlockQueryStore, type ComparisonOp, DASHBOARD_GRID_MAX_COLS, DASHBOARD_WIDGET_TYPES, DEFAULT_DASHBOARD_TITLE, DISCIPLINE_FACTORS, type DashboardDocument, type DashboardMeta, type DashboardParsedSection, type DashboardSectionInput, type DashboardToken, type DashboardWidget, type DashboardWidgetType, EFFORT_DISCIPLINES, type EffortDiscipline, type EffortQueryStore, type EventRowIdentity, type FindOptions, type FindPredicate, type FindQueryResult, GIT_SHA, type IEffort, KG_PER_LB, type LinkWidget, type MetricPredicate, type NoteQueryStore, PLANNED_WIDGET_TYPES, type ParsedAggregateQuery, type ParsedFindQuery, type ParsedFrontmatter, type ParsedRowsQuery, type ParsedWqlLastSuffix, type ParsedWqlRollupSuffix, type ParsedWqlSuffixes, type QueryOptions, type QueryResult, QueryService, type QueryServiceStores, type QueryWidgetSuffix, type RowsQueryResult, type RowsRun, SEMVER, type Series, type SeriesPoint, type SummaryFactIdentity, type SummaryFactSourceOutput, type TagFilter, type TagValue, UNIT_FAMILIES, type UnifiedEventStore, type UnitFamily, type UnitFamilyDef, VERSION, WQL_AGGREGATORS, WQL_CALC_TARGETS, WQL_COMPARISON_OPS, WQL_CONTENT_FILTER_KEYS, WQL_DISPLAY_UNITS, WQL_FIND_TARGETS, WQL_GRAINS, WQL_INTENSITY_TIERS, WQL_KEYWORDS, WQL_METRIC_AGGREGATES, WQL_METRIC_FAMILIES, WQL_ROLLUP_PERIODS, WQL_SCOPES, WQL_SOURCES, WQL_TAG_KEYS, WQL_VIRTUAL_DIMS, type WqlAggregator, type WqlCalcTarget, type WqlComparisonOp, type WqlCompletionOptions, type WqlContentFilterKey, type WqlDisplayUnit, type WqlFindTarget, type WqlGrain, type WqlIntensityTier, type WqlKeyword, type WqlMetricAggregate, type WqlMetricFamily, type WqlRollupPeriod, type WqlScope, type WqlSource, type WqlTagKey, type WqlVirtualDim, buildDashboardDocument, buildDashboardScaffold, convert, dashboardSlug, defaultTokenValues, disciplineFactorFor, extractDashboardTokens, extractFrontmatterTags, getList, getScalar, getUnitFamily, isAggregateQuery, isDashboardMeta, isDashboardWidgetType, isEffortDiscipline, isFindQuery, isProposedMetric, isRowsQuery, normalizeSummaryFacts, parseDashboardNote, parseFlatProperties, parseFrontmatter, parseFrontmatterBody, parseFrontmatterCategories, parseFrontmatterProps, parseQuery, parseQueryWidgetSuffix, parseWqlSuffixes, projectEventToFacts, referencedTokens, resolveCanonicalMetricKey, resolveDisplayUnit, resolveWidgetType, serializeFrontmatter, setDashboardTokenValue, splitAtWhere, splitWidgetBody, staticNotesFromBlocks, staticTagIndexFromBlocks, stripFrontmatter, substituteTokens, toEventRows, toSummaryEventRows, unknownTokensMessage, unknownWidgetTypeMessage, wql, wqlCompletion, wqlCompletionSource, wqlHighlightStyle, wqlLanguage, parser as wqlParser, wql_parser_terms as wqlTerms };
package/dist/index.d.ts CHANGED
@@ -164,6 +164,8 @@ interface ParsedWqlSuffixes {
164
164
  last?: ParsedWqlLastSuffix;
165
165
  /** Content scope (`in journal` / `in all`). */
166
166
  scope?: string;
167
+ /** Duplicate-clause diagnostics (C3) — each names both conflicting spans. */
168
+ conflicts?: string[];
167
169
  /** Primary query text with suffixes removed. */
168
170
  primaryText: string;
169
171
  }
@@ -236,7 +238,12 @@ interface FindPredicate {
236
238
  unit: 'd' | 'w';
237
239
  };
238
240
  }
239
- interface ParsedQuery {
241
+ /**
242
+ * Result of parsing an analytics (aggregate) query — `agg:metric{filters} …`.
243
+ * Discriminated union member: `family === 'aggregate'` (C5).
244
+ */
245
+ interface ParsedAggregateQuery {
246
+ family: 'aggregate';
240
247
  raw: string;
241
248
  agg: Aggregator;
242
249
  /** Canonical Metric Key (fact row `metricKey`). */
@@ -256,6 +263,7 @@ interface ParsedQuery {
256
263
  }
257
264
  /** Result of parsing a content-discovery query (`find:target{filters} in scope`). */
258
265
  interface ParsedFindQuery {
266
+ family: 'find';
259
267
  raw: string;
260
268
  /** Content target: 'note' or 'block'. */
261
269
  target: string;
@@ -271,11 +279,13 @@ interface ParsedFindQuery {
271
279
  join?: MetricPredicate;
272
280
  error?: string;
273
281
  }
274
- type AnyParsedQuery = ParsedQuery | ParsedFindQuery | ParsedRowsQuery;
282
+ type AnyParsedQuery = ParsedAggregateQuery | ParsedFindQuery | ParsedRowsQuery;
275
283
  /** Type guard: true for content-discovery queries. */
276
284
  declare function isFindQuery(parsed: AnyParsedQuery): parsed is ParsedFindQuery;
277
285
  /** Type guard: true for rows queries. */
278
286
  declare function isRowsQuery(parsed: AnyParsedQuery): parsed is ParsedRowsQuery;
287
+ /** Type guard: true for analytics (aggregate) queries. */
288
+ declare function isAggregateQuery(parsed: AnyParsedQuery): parsed is ParsedAggregateQuery;
279
289
  interface SeriesPoint {
280
290
  ts: number;
281
291
  value: number;
@@ -288,7 +298,7 @@ interface SeriesPoint {
288
298
  */
289
299
  interface ParsedRowsQuery {
290
300
  raw: string;
291
- /** Family discriminator (the other families are told apart by 'target'/'agg'). */
301
+ /** Family discriminator shared by all three query ASTs (C5). */
292
302
  family: 'rows';
293
303
  /** Output-statement type narrowing from the optional target (`rows:segment{…}`); undefined = all types. */
294
304
  outputType?: string;
@@ -307,9 +317,10 @@ interface Series {
307
317
  unit?: string;
308
318
  }
309
319
  /**
310
- * Parse a WQL query string into either an analytics ParsedQuery or a content
311
- * ParsedFindQuery. Dispatch is textual: a leading `find:` routes to the
312
- * content path, everything else to analytics.
320
+ * Parse a WQL query string into one of the three query families —
321
+ * analytics aggregate, content find, or rows — discriminated by `family`
322
+ * (C5). Dispatch is textual: a leading `find:` routes to the content path,
323
+ * `rows` to the rows path, everything else to analytics.
313
324
  */
314
325
  declare function parseQuery(raw: string): AnyParsedQuery;
315
326
 
@@ -630,7 +641,7 @@ interface FindOptions {
630
641
  anchorNow?: number;
631
642
  }
632
643
  interface QueryResult {
633
- parsed: ParsedQuery;
644
+ parsed: ParsedAggregateQuery;
634
645
  series: Series[];
635
646
  stages: {
636
647
  selected: number;
@@ -691,7 +702,7 @@ declare class QueryService {
691
702
  * Execute a find:effort query against the effort registry.
692
703
  */
693
704
  runFindEffort(parsed: ParsedFindQuery): Promise<FindQueryResult>;
694
- run(parsed: ParsedQuery, options?: QueryOptions): Promise<QueryResult>;
705
+ run(parsed: ParsedAggregateQuery, options?: QueryOptions): Promise<QueryResult>;
695
706
  /**
696
707
  * Stages 2–4 — BUCKET → GROUP → AGGREGATE over an already-selected +
697
708
  * filtered `matched` set.
@@ -945,13 +956,13 @@ declare function parseFrontmatterProps(lines: string[]): Record<string, string>;
945
956
  * Auto-generated build version metadata.
946
957
  * Do not edit directly; updated by scripts/stamp-version.ts
947
958
  */
948
- declare const VERSION = "0.6.36";
949
- declare const GIT_SHA = "c5ad2b0";
950
- declare const BUILD_TIME = "2026-08-24T20:14:33.951Z";
959
+ declare const VERSION = "0.7.38";
960
+ declare const GIT_SHA = "172cc75";
961
+ declare const BUILD_TIME = "2026-08-25T23:00:14.937Z";
951
962
  declare const SEMVER: {
952
- readonly version: "0.6.36";
953
- readonly gitSha: "c5ad2b0";
954
- readonly buildTime: "2026-08-24T20:14:33.951Z";
963
+ readonly version: "0.7.38";
964
+ readonly gitSha: "172cc75";
965
+ readonly buildTime: "2026-08-25T23:00:14.937Z";
955
966
  };
956
967
 
957
- export { type Aggregator, type AnyParsedQuery, BUILD_TIME, type BlockQueryStore, type ComparisonOp, DASHBOARD_GRID_MAX_COLS, DASHBOARD_WIDGET_TYPES, DEFAULT_DASHBOARD_TITLE, DISCIPLINE_FACTORS, type DashboardDocument, type DashboardMeta, type DashboardParsedSection, type DashboardSectionInput, type DashboardToken, type DashboardWidget, type DashboardWidgetType, EFFORT_DISCIPLINES, type EffortDiscipline, type EffortQueryStore, type EventRowIdentity, type FindOptions, type FindPredicate, type FindQueryResult, GIT_SHA, type IEffort, KG_PER_LB, type LinkWidget, type MetricPredicate, type NoteQueryStore, PLANNED_WIDGET_TYPES, type ParsedFindQuery, type ParsedFrontmatter, type ParsedQuery, type ParsedRowsQuery, type ParsedWqlLastSuffix, type ParsedWqlRollupSuffix, type ParsedWqlSuffixes, type QueryOptions, type QueryResult, QueryService, type QueryServiceStores, type QueryWidgetSuffix, type RowsQueryResult, type RowsRun, SEMVER, type Series, type SeriesPoint, type SummaryFactIdentity, type SummaryFactSourceOutput, type TagFilter, type TagValue, UNIT_FAMILIES, type UnifiedEventStore, type UnitFamily, type UnitFamilyDef, VERSION, WQL_AGGREGATORS, WQL_CALC_TARGETS, WQL_COMPARISON_OPS, WQL_CONTENT_FILTER_KEYS, WQL_DISPLAY_UNITS, WQL_FIND_TARGETS, WQL_GRAINS, WQL_INTENSITY_TIERS, WQL_KEYWORDS, WQL_METRIC_AGGREGATES, WQL_METRIC_FAMILIES, WQL_ROLLUP_PERIODS, WQL_SCOPES, WQL_SOURCES, WQL_TAG_KEYS, WQL_VIRTUAL_DIMS, type WqlAggregator, type WqlCalcTarget, type WqlComparisonOp, type WqlCompletionOptions, type WqlContentFilterKey, type WqlDisplayUnit, type WqlFindTarget, type WqlGrain, type WqlIntensityTier, type WqlKeyword, type WqlMetricAggregate, type WqlMetricFamily, type WqlRollupPeriod, type WqlScope, type WqlSource, type WqlTagKey, type WqlVirtualDim, buildDashboardDocument, buildDashboardScaffold, convert, dashboardSlug, defaultTokenValues, disciplineFactorFor, extractDashboardTokens, extractFrontmatterTags, getList, getScalar, getUnitFamily, isDashboardMeta, isDashboardWidgetType, isEffortDiscipline, isFindQuery, isProposedMetric, isRowsQuery, normalizeSummaryFacts, parseDashboardNote, parseFlatProperties, parseFrontmatter, parseFrontmatterBody, parseFrontmatterCategories, parseFrontmatterProps, parseQuery, parseQueryWidgetSuffix, parseWqlSuffixes, projectEventToFacts, referencedTokens, resolveCanonicalMetricKey, resolveDisplayUnit, resolveWidgetType, serializeFrontmatter, setDashboardTokenValue, splitAtWhere, splitWidgetBody, staticNotesFromBlocks, staticTagIndexFromBlocks, stripFrontmatter, substituteTokens, toEventRows, toSummaryEventRows, unknownTokensMessage, unknownWidgetTypeMessage, wql, wqlCompletion, wqlCompletionSource, wqlHighlightStyle, wqlLanguage, parser as wqlParser, wql_parser_terms as wqlTerms };
968
+ export { type Aggregator, type AnyParsedQuery, BUILD_TIME, type BlockQueryStore, type ComparisonOp, DASHBOARD_GRID_MAX_COLS, DASHBOARD_WIDGET_TYPES, DEFAULT_DASHBOARD_TITLE, DISCIPLINE_FACTORS, type DashboardDocument, type DashboardMeta, type DashboardParsedSection, type DashboardSectionInput, type DashboardToken, type DashboardWidget, type DashboardWidgetType, EFFORT_DISCIPLINES, type EffortDiscipline, type EffortQueryStore, type EventRowIdentity, type FindOptions, type FindPredicate, type FindQueryResult, GIT_SHA, type IEffort, KG_PER_LB, type LinkWidget, type MetricPredicate, type NoteQueryStore, PLANNED_WIDGET_TYPES, type ParsedAggregateQuery, type ParsedFindQuery, type ParsedFrontmatter, type ParsedRowsQuery, type ParsedWqlLastSuffix, type ParsedWqlRollupSuffix, type ParsedWqlSuffixes, type QueryOptions, type QueryResult, QueryService, type QueryServiceStores, type QueryWidgetSuffix, type RowsQueryResult, type RowsRun, SEMVER, type Series, type SeriesPoint, type SummaryFactIdentity, type SummaryFactSourceOutput, type TagFilter, type TagValue, UNIT_FAMILIES, type UnifiedEventStore, type UnitFamily, type UnitFamilyDef, VERSION, WQL_AGGREGATORS, WQL_CALC_TARGETS, WQL_COMPARISON_OPS, WQL_CONTENT_FILTER_KEYS, WQL_DISPLAY_UNITS, WQL_FIND_TARGETS, WQL_GRAINS, WQL_INTENSITY_TIERS, WQL_KEYWORDS, WQL_METRIC_AGGREGATES, WQL_METRIC_FAMILIES, WQL_ROLLUP_PERIODS, WQL_SCOPES, WQL_SOURCES, WQL_TAG_KEYS, WQL_VIRTUAL_DIMS, type WqlAggregator, type WqlCalcTarget, type WqlComparisonOp, type WqlCompletionOptions, type WqlContentFilterKey, type WqlDisplayUnit, type WqlFindTarget, type WqlGrain, type WqlIntensityTier, type WqlKeyword, type WqlMetricAggregate, type WqlMetricFamily, type WqlRollupPeriod, type WqlScope, type WqlSource, type WqlTagKey, type WqlVirtualDim, buildDashboardDocument, buildDashboardScaffold, convert, dashboardSlug, defaultTokenValues, disciplineFactorFor, extractDashboardTokens, extractFrontmatterTags, getList, getScalar, getUnitFamily, isAggregateQuery, isDashboardMeta, isDashboardWidgetType, isEffortDiscipline, isFindQuery, isProposedMetric, isRowsQuery, normalizeSummaryFacts, parseDashboardNote, parseFlatProperties, parseFrontmatter, parseFrontmatterBody, parseFrontmatterCategories, parseFrontmatterProps, parseQuery, parseQueryWidgetSuffix, parseWqlSuffixes, projectEventToFacts, referencedTokens, resolveCanonicalMetricKey, resolveDisplayUnit, resolveWidgetType, serializeFrontmatter, setDashboardTokenValue, splitAtWhere, splitWidgetBody, staticNotesFromBlocks, staticTagIndexFromBlocks, stripFrontmatter, substituteTokens, toEventRows, toSummaryEventRows, unknownTokensMessage, unknownWidgetTypeMessage, wql, wqlCompletion, wqlCompletionSource, wqlHighlightStyle, wqlLanguage, parser as wqlParser, wql_parser_terms as wqlTerms };
package/dist/index.mjs CHANGED
@@ -160,55 +160,62 @@ function parseWqlSuffixes(raw) {
160
160
  let groupBy;
161
161
  let last;
162
162
  let scope;
163
+ const conflicts = [];
163
164
  const isFind = text.startsWith("find:");
164
165
  const isRows = /^rows(?=[:{]|\s|$)/.test(text);
166
+ const stripRepeated = (re) => {
167
+ const matches = [];
168
+ for (let m = re.exec(text); m; m = re.exec(text)) {
169
+ matches.unshift(m);
170
+ text = text.slice(0, m.index).trim();
171
+ }
172
+ return matches;
173
+ };
174
+ const conflictFrom = (label, ms) => {
175
+ if (ms.length > 1) {
176
+ conflicts.push(
177
+ `Duplicate '${label}' clause: '${ms[0][0].trim()}' conflicts with '${ms[ms.length - 1][0].trim()}'`
178
+ );
179
+ }
180
+ };
165
181
  if (isFind || isRows) {
166
- const lastMatch = LAST_RE.exec(text);
167
- if (lastMatch) {
168
- last = {
169
- size: parseInt(lastMatch[1], 10),
170
- unit: lastMatch[2].toLowerCase(),
171
- raw: lastMatch[0].trim()
172
- };
173
- text = text.slice(0, lastMatch.index).trim();
182
+ const lasts = stripRepeated(LAST_RE);
183
+ conflictFrom("window", lasts);
184
+ if (lasts.length) {
185
+ const m = lasts[lasts.length - 1];
186
+ last = { size: parseInt(m[1], 10), unit: m[2].toLowerCase(), raw: m[0].trim() };
174
187
  }
175
188
  if (isFind) {
176
- const scopeMatch = IN_SCOPE_RE.exec(text);
177
- if (scopeMatch) {
178
- scope = scopeMatch[1];
179
- text = text.slice(0, scopeMatch.index).trim();
180
- }
189
+ const scopes = stripRepeated(IN_SCOPE_RE);
190
+ conflictFrom("scope", scopes);
191
+ if (scopes.length) scope = scopes[scopes.length - 1][1];
181
192
  } else {
182
- const rollupMatch = ROLLUP_RE.exec(text);
183
- if (rollupMatch) {
184
- const rawRollup = rollupMatch[1] + rollupMatch[2];
185
- rollup = { size: rollupMatch[1] ? parseInt(rollupMatch[1], 10) : 1, unit: rollupMatch[2] || "", raw: rawRollup };
186
- text = text.slice(0, rollupMatch.index).trim();
193
+ const rollups = stripRepeated(ROLLUP_RE);
194
+ conflictFrom(".rollup", rollups);
195
+ if (rollups.length) {
196
+ const m = rollups[rollups.length - 1];
197
+ rollup = { size: m[1] ? parseInt(m[1], 10) : 1, unit: m[2] || "", raw: m[1] + m[2] };
187
198
  }
188
- const byMatch = BY_RE.exec(text);
189
- if (byMatch) {
190
- groupBy = byMatch[1].split(",").map((d) => d.trim()).filter(Boolean);
191
- text = text.slice(0, byMatch.index).trim();
199
+ const bys = stripRepeated(BY_RE);
200
+ conflictFrom("by", bys);
201
+ if (bys.length) {
202
+ groupBy = bys[bys.length - 1][1].split(",").map((d) => d.trim()).filter(Boolean);
192
203
  }
193
204
  }
194
205
  } else {
195
- const unitMatch = DISPLAY_UNIT_RE.exec(text);
196
- if (unitMatch) {
197
- displayUnit = unitMatch[1];
198
- text = text.slice(0, unitMatch.index).trim();
199
- }
200
- const rollupMatch = ROLLUP_RE.exec(text);
201
- if (rollupMatch) {
202
- const rawRollup = rollupMatch[1] + rollupMatch[2];
203
- const size = rollupMatch[1] ? parseInt(rollupMatch[1], 10) : 1;
204
- const unit = rollupMatch[2] || "";
205
- rollup = { size, unit, raw: rawRollup };
206
- text = text.slice(0, rollupMatch.index).trim();
206
+ const units = stripRepeated(DISPLAY_UNIT_RE);
207
+ conflictFrom("display-unit", units);
208
+ if (units.length) displayUnit = units[units.length - 1][1];
209
+ const rollups = stripRepeated(ROLLUP_RE);
210
+ conflictFrom(".rollup", rollups);
211
+ if (rollups.length) {
212
+ const m = rollups[rollups.length - 1];
213
+ rollup = { size: m[1] ? parseInt(m[1], 10) : 1, unit: m[2] || "", raw: m[1] + m[2] };
207
214
  }
208
- const byMatch = BY_RE.exec(text);
209
- if (byMatch) {
210
- groupBy = byMatch[1].split(",").map((d) => d.trim()).filter(Boolean);
211
- text = text.slice(0, byMatch.index).trim();
215
+ const bys = stripRepeated(BY_RE);
216
+ conflictFrom("by", bys);
217
+ if (bys.length) {
218
+ groupBy = bys[bys.length - 1][1].split(",").map((d) => d.trim()).filter(Boolean);
212
219
  }
213
220
  }
214
221
  return {
@@ -218,17 +225,21 @@ function parseWqlSuffixes(raw) {
218
225
  groupBy,
219
226
  last,
220
227
  scope,
228
+ conflicts: conflicts.length ? conflicts : void 0,
221
229
  primaryText: text
222
230
  };
223
231
  }
224
232
 
225
233
  // src/wql.ts
226
234
  function isFindQuery(parsed) {
227
- return "target" in parsed;
235
+ return parsed.family === "find";
228
236
  }
229
237
  function isRowsQuery(parsed) {
230
238
  return parsed.family === "rows";
231
239
  }
240
+ function isAggregateQuery(parsed) {
241
+ return parsed.family === "aggregate";
242
+ }
232
243
  var AGGS = WQL_AGGREGATORS;
233
244
  function cannotParse(text) {
234
245
  return `Cannot parse "${text}". Expected agg:metric{filters} by {dims} .rollup(period)`;
@@ -279,6 +290,10 @@ function parseRowsQuery(raw) {
279
290
  filters: [],
280
291
  last: last ? { size: last.size, unit: last.unit } : void 0
281
292
  };
293
+ if (suffixes.conflicts?.length) {
294
+ result.error = suffixes.conflicts.join("; ");
295
+ return result;
296
+ }
282
297
  if (whereText || groupBy || rollup) {
283
298
  result.error = `Rows queries return raw statements \u2014 no where / by / rollup. Got "${primaryText.trim()}"`;
284
299
  return result;
@@ -359,6 +374,7 @@ function parseAnalyticsQuery(raw) {
359
374
  const suffixes = parseWqlSuffixes(raw);
360
375
  const { where: whereText, displayUnit, groupBy, rollup, primaryText: text } = suffixes;
361
376
  const base = {
377
+ family: "aggregate",
362
378
  raw,
363
379
  agg: "sum",
364
380
  metric: "",
@@ -367,6 +383,10 @@ function parseAnalyticsQuery(raw) {
367
383
  displayUnit,
368
384
  rollup: rollup ? { size: rollup.size, unit: rollup.unit } : void 0
369
385
  };
386
+ if (suffixes.conflicts?.length) {
387
+ base.error = suffixes.conflicts.join("; ");
388
+ return base;
389
+ }
370
390
  if (rollup && rollup.unit !== "d" && rollup.unit !== "w") {
371
391
  base.error = cannotParse(text);
372
392
  return base;
@@ -422,12 +442,17 @@ function parseFindQuery(raw) {
422
442
  const suffixes = parseWqlSuffixes(raw);
423
443
  const { where: whereText, last, scope, primaryText: text } = suffixes;
424
444
  const result = {
445
+ family: "find",
425
446
  raw,
426
447
  target: "",
427
448
  filters: [],
428
449
  scope,
429
450
  last: last ? { size: last.size, unit: last.unit } : void 0
430
451
  };
452
+ if (suffixes.conflicts?.length) {
453
+ result.error = suffixes.conflicts.join("; ");
454
+ return result;
455
+ }
431
456
  const tree = parser.parse(text);
432
457
  let syntaxError = false;
433
458
  tree.iterate({ enter(node) {
@@ -1276,7 +1301,7 @@ var QueryService = class {
1276
1301
  const parsed = parseQuery(raw);
1277
1302
  if (isFindQuery(parsed)) {
1278
1303
  return {
1279
- parsed: { raw, agg: "count", metric: parsed.target, filters: [], groupBy: [] },
1304
+ parsed: { family: "aggregate", raw, agg: "count", metric: parsed.target, filters: [], groupBy: [] },
1280
1305
  series: [],
1281
1306
  stages: { selected: 0, buckets: 0, aggregated: 0, groups: 0 },
1282
1307
  matched: []
@@ -1284,7 +1309,7 @@ var QueryService = class {
1284
1309
  }
1285
1310
  if (isRowsQuery(parsed)) {
1286
1311
  return {
1287
- parsed: { raw, agg: "count", metric: "rows", filters: [], groupBy: [] },
1312
+ parsed: { family: "aggregate", raw, agg: "count", metric: "rows", filters: [], groupBy: [] },
1288
1313
  series: [],
1289
1314
  stages: { selected: 0, buckets: 0, aggregated: 0, groups: 0 },
1290
1315
  matched: []
@@ -1606,6 +1631,7 @@ var QueryService = class {
1606
1631
  };
1607
1632
  const join = parsed.join;
1608
1633
  const findResult = await this.runFind({
1634
+ family: "find",
1609
1635
  raw: "",
1610
1636
  target: join.target,
1611
1637
  filters: join.filters,
@@ -2024,15 +2050,15 @@ sum:$metric{} rollup:1w
2024
2050
  }
2025
2051
 
2026
2052
  // src/version.ts
2027
- var VERSION = "0.6.36";
2028
- var GIT_SHA = "c5ad2b0";
2029
- var BUILD_TIME = "2026-08-24T20:14:33.951Z";
2053
+ var VERSION = "0.7.38";
2054
+ var GIT_SHA = "172cc75";
2055
+ var BUILD_TIME = "2026-08-25T23:00:14.937Z";
2030
2056
  var SEMVER = {
2031
- version: "0.6.36",
2032
- gitSha: "c5ad2b0",
2033
- buildTime: "2026-08-24T20:14:33.951Z"
2057
+ version: "0.7.38",
2058
+ gitSha: "172cc75",
2059
+ buildTime: "2026-08-25T23:00:14.937Z"
2034
2060
  };
2035
2061
 
2036
- export { BUILD_TIME, DASHBOARD_GRID_MAX_COLS, DASHBOARD_WIDGET_TYPES, DEFAULT_DASHBOARD_TITLE, DISCIPLINE_FACTORS, EFFORT_DISCIPLINES, GIT_SHA, KG_PER_LB, PLANNED_WIDGET_TYPES, QueryService, SEMVER, UNIT_FAMILIES, VERSION, WQL_AGGREGATORS, WQL_CALC_TARGETS, WQL_COMPARISON_OPS, WQL_CONTENT_FILTER_KEYS, WQL_DISPLAY_UNITS, WQL_FIND_TARGETS, WQL_GRAINS, WQL_INTENSITY_TIERS, WQL_KEYWORDS, WQL_METRIC_AGGREGATES, WQL_METRIC_FAMILIES, WQL_ROLLUP_PERIODS, WQL_SCOPES, WQL_SOURCES, WQL_TAG_KEYS, WQL_VIRTUAL_DIMS, buildDashboardDocument, buildDashboardScaffold, convert, dashboardSlug, defaultTokenValues, disciplineFactorFor, extractDashboardTokens, extractFrontmatterTags, getList, getScalar, getUnitFamily, isDashboardMeta, isDashboardWidgetType, isEffortDiscipline, isFindQuery, isProposedMetric, isRowsQuery, normalizeSummaryFacts, parseDashboardNote, parseFlatProperties, parseFrontmatter, parseFrontmatterBody, parseFrontmatterCategories, parseFrontmatterProps, parseQuery, parseQueryWidgetSuffix, parseWqlSuffixes, projectEventToFacts, referencedTokens, resolveCanonicalMetricKey, resolveDisplayUnit, resolveWidgetType, serializeFrontmatter, setDashboardTokenValue, splitAtWhere, splitWidgetBody, staticNotesFromBlocks, staticTagIndexFromBlocks, stripFrontmatter, substituteTokens, toEventRows, toSummaryEventRows, unknownTokensMessage, unknownWidgetTypeMessage, wql, wqlCompletion, wqlCompletionSource, wqlHighlightStyle, wqlLanguage, parser as wqlParser, wql_parser_terms_exports as wqlTerms };
2062
+ export { BUILD_TIME, DASHBOARD_GRID_MAX_COLS, DASHBOARD_WIDGET_TYPES, DEFAULT_DASHBOARD_TITLE, DISCIPLINE_FACTORS, EFFORT_DISCIPLINES, GIT_SHA, KG_PER_LB, PLANNED_WIDGET_TYPES, QueryService, SEMVER, UNIT_FAMILIES, VERSION, WQL_AGGREGATORS, WQL_CALC_TARGETS, WQL_COMPARISON_OPS, WQL_CONTENT_FILTER_KEYS, WQL_DISPLAY_UNITS, WQL_FIND_TARGETS, WQL_GRAINS, WQL_INTENSITY_TIERS, WQL_KEYWORDS, WQL_METRIC_AGGREGATES, WQL_METRIC_FAMILIES, WQL_ROLLUP_PERIODS, WQL_SCOPES, WQL_SOURCES, WQL_TAG_KEYS, WQL_VIRTUAL_DIMS, buildDashboardDocument, buildDashboardScaffold, convert, dashboardSlug, defaultTokenValues, disciplineFactorFor, extractDashboardTokens, extractFrontmatterTags, getList, getScalar, getUnitFamily, isAggregateQuery, isDashboardMeta, isDashboardWidgetType, isEffortDiscipline, isFindQuery, isProposedMetric, isRowsQuery, normalizeSummaryFacts, parseDashboardNote, parseFlatProperties, parseFrontmatter, parseFrontmatterBody, parseFrontmatterCategories, parseFrontmatterProps, parseQuery, parseQueryWidgetSuffix, parseWqlSuffixes, projectEventToFacts, referencedTokens, resolveCanonicalMetricKey, resolveDisplayUnit, resolveWidgetType, serializeFrontmatter, setDashboardTokenValue, splitAtWhere, splitWidgetBody, staticNotesFromBlocks, staticTagIndexFromBlocks, stripFrontmatter, substituteTokens, toEventRows, toSummaryEventRows, unknownTokensMessage, unknownWidgetTypeMessage, wql, wqlCompletion, wqlCompletionSource, wqlHighlightStyle, wqlLanguage, parser as wqlParser, wql_parser_terms_exports as wqlTerms };
2037
2063
  //# sourceMappingURL=index.mjs.map
2038
2064
  //# sourceMappingURL=index.mjs.map