@bitcobblers/wod-wiki-wql 0.37.2139 → 0.38.2141

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
@@ -31,7 +31,7 @@ var WQL_TAG_KEYS = [
31
31
  "result",
32
32
  "tags"
33
33
  ];
34
- var WQL_CONTENT_ONLY_KEYS = ["type", "text", "has", "source", "catalog"];
34
+ var WQL_CONTENT_ONLY_KEYS = ["type", "text", "has", "source", "catalog", "notebook"];
35
35
  var WQL_EFFORT_FILTER_KEYS = ["effort", "discipline", "intensity", "origin", "text"];
36
36
  var WQL_VIRTUAL_DIMS = ["day", "week", "session", "round"];
37
37
  var WQL_CALC_TARGETS = [
@@ -129,8 +129,8 @@ var AGGREGATE_TYPES = /* @__PURE__ */ new Set([
129
129
  "metric"
130
130
  ]);
131
131
  var TARGET_TYPES = {
132
- note: /* @__PURE__ */ new Set(["text", "catalog", "tag", "effort", ...WQL_TYPED_TAG_KEYS, "type", "page", "source", "note", "time", "groupby", "where"]),
133
- block: /* @__PURE__ */ new Set(["text", "catalog", "tag", "effort", "type", "source", "note", "time", "groupby", "where"]),
132
+ note: /* @__PURE__ */ new Set(["text", "catalog", "notebook", "tag", "effort", ...WQL_TYPED_TAG_KEYS, "type", "page", "source", "note", "time", "groupby", "where"]),
133
+ block: /* @__PURE__ */ new Set(["text", "catalog", "notebook", "tag", "effort", "type", "source", "note", "time", "groupby", "where"]),
134
134
  effort: /* @__PURE__ */ new Set([...WQL_EFFORT_FILTER_KEYS, "groupby"]),
135
135
  session: /* @__PURE__ */ new Set(["result", "block", "note", "plane", "time", "groupby"]),
136
136
  segment: /* @__PURE__ */ new Set([...TABLE_KEYS, "time", "groupby", "unit"]),
@@ -598,9 +598,12 @@ function parseQuery(raw) {
598
598
  }
599
599
  return parseSingleQuery(raw);
600
600
  }
601
+ function normalizeNotebookFilterText(raw) {
602
+ return raw.replace(/\bnotebook:notebook\/([a-zA-Z0-9_-]+)/g, 'notebook:"notebook/$1"');
603
+ }
601
604
  function normalizeWql(raw) {
602
605
  const advisories = [];
603
- let text = raw.trim();
606
+ let text = normalizeNotebookFilterText(raw.trim());
604
607
  const { primary, where } = splitAtWhere(text);
605
608
  const isFind = primary.startsWith("find:");
606
609
  if (isFind) {
@@ -870,7 +873,8 @@ function cannotParseFind(text) {
870
873
  return `Cannot parse "${text}". Expected :source{key:value, !key:value}; filters are optional. Optional suffixes include by {dimension}, last <n>d or last <n>w, from YYYY-MM-DD [to YYYY-MM-DD], where <aggregator>:<metric>{filters} <operator> <number>, and | order by <column> | limit <n>. Support depends on the target.`;
871
874
  }
872
875
  function parseFindQuery(raw, opts) {
873
- const { text: rawNoPipes, pipes } = extractPipes(raw);
876
+ const normalizedRaw = normalizeNotebookFilterText(raw);
877
+ const { text: rawNoPipes, pipes } = extractPipes(normalizedRaw);
874
878
  const suffixes = parseWqlSuffixes(rawNoPipes);
875
879
  const { where: whereText, window: windowSuffix, legacyScope, groupBy, displayUnit, primaryText: text } = suffixes;
876
880
  const win = toQueryWindow(windowSuffix);
@@ -2899,8 +2903,6 @@ function dedupeById(facts) {
2899
2903
  }
2900
2904
  return out;
2901
2905
  }
2902
-
2903
- // src/QueryService.ts
2904
2906
  var NOTE_UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
2905
2907
  function catalogOfItem(item) {
2906
2908
  if (item.catalog) return item.catalog;
@@ -2912,6 +2914,25 @@ function catalogOfItem(item) {
2912
2914
  if (!isCollectionOrFeed && !clean.includes("/")) return void 0;
2913
2915
  return clean.split("/")[0];
2914
2916
  }
2917
+ function notebookOfItem(item) {
2918
+ if (item.notebookId && item.notebookId.trim()) {
2919
+ return wodWikiCore.toNotebookId(item.notebookId);
2920
+ }
2921
+ if (item.tags) {
2922
+ for (const tag of item.tags) {
2923
+ if (tag.startsWith("notebook:") || tag.startsWith("notebook/")) {
2924
+ const slug = wodWikiCore.notebookSlugFromId(tag);
2925
+ if (slug) return wodWikiCore.toNotebookId(slug);
2926
+ }
2927
+ }
2928
+ }
2929
+ if (sourceMatches(item, "playground")) return "notebook/playground";
2930
+ if (sourceMatches(item, "guides")) return "notebook/guides";
2931
+ const cat = catalogOfItem(item);
2932
+ if (cat) return wodWikiCore.toNotebookId(cat);
2933
+ if (sourceMatches(item, "journal")) return "notebook/journal";
2934
+ return void 0;
2935
+ }
2915
2936
  function sourceMatches(item, kind) {
2916
2937
  const sourceId = item.sourceId;
2917
2938
  if (kind === "all") return !sourceId || WQL_SOURCE_VALUES.some((k) => sourceMatches(item, k));
@@ -2951,6 +2972,19 @@ function applySourceFilter(items, filters) {
2951
2972
  }
2952
2973
  return items;
2953
2974
  }
2975
+ function applyNotebookFilter(items, filters) {
2976
+ for (const filter of filters) {
2977
+ if (filter.key !== "notebook") continue;
2978
+ const wanted = new Set(filter.values.map((v) => wodWikiCore.toNotebookId(v.value)));
2979
+ items = items.filter((item) => {
2980
+ const nb = notebookOfItem(item);
2981
+ if (!nb) return filter.negate;
2982
+ const hit = wanted.has(nb);
2983
+ return filter.negate ? !hit : hit;
2984
+ });
2985
+ }
2986
+ return items;
2987
+ }
2954
2988
  var DOMAIN_SOURCE_KINDS = {
2955
2989
  feed: true,
2956
2990
  feeds: true,
@@ -3724,6 +3758,7 @@ var QueryService = class {
3724
3758
  });
3725
3759
  }
3726
3760
  }
3761
+ notes = applyNotebookFilter(notes, parsed.filters);
3727
3762
  for (const filter of parsed.filters) {
3728
3763
  if (filter.key === "note") {
3729
3764
  const wanted = new Set(filter.values.map((v) => v.value));
@@ -3862,6 +3897,7 @@ var QueryService = class {
3862
3897
  });
3863
3898
  }
3864
3899
  }
3900
+ blocks = applyNotebookFilter(blocks, parsed.filters);
3865
3901
  for (const filter of parsed.filters) {
3866
3902
  if (filter.key === "tags" && !filter.negate) {
3867
3903
  const matchingNoteIds = /* @__PURE__ */ new Set();
@@ -5221,15 +5257,19 @@ ${query}
5221
5257
  }
5222
5258
 
5223
5259
  // src/version.ts
5224
- var VERSION = "0.37.2139";
5225
- var GIT_SHA = "491ec71";
5226
- var BUILD_TIME = "2026-10-17T15:36:01.834Z";
5260
+ var VERSION = "0.38.2141";
5261
+ var GIT_SHA = "b9b40a7";
5262
+ var BUILD_TIME = "2026-10-19T12:09:48.802Z";
5227
5263
  var SEMVER = {
5228
- version: "0.37.2139",
5229
- gitSha: "491ec71",
5230
- buildTime: "2026-10-17T15:36:01.834Z"
5264
+ version: "0.38.2141",
5265
+ gitSha: "b9b40a7",
5266
+ buildTime: "2026-10-19T12:09:48.802Z"
5231
5267
  };
5232
5268
 
5269
+ Object.defineProperty(exports, "DEFAULT_NOTEBOOK_SLUGS", {
5270
+ enumerable: true,
5271
+ get: function () { return wodWikiCore.DEFAULT_NOTEBOOK_SLUGS; }
5272
+ });
5233
5273
  Object.defineProperty(exports, "SYSTEM_DEFAULT_OUTPUT_UNIT", {
5234
5274
  enumerable: true,
5235
5275
  get: function () { return wodWikiCore.SYSTEM_DEFAULT_OUTPUT_UNIT; }
@@ -5246,14 +5286,26 @@ Object.defineProperty(exports, "dimensionKeyOf", {
5246
5286
  enumerable: true,
5247
5287
  get: function () { return wodWikiCore.dimensionKeyOf; }
5248
5288
  });
5289
+ Object.defineProperty(exports, "isNoteEditable", {
5290
+ enumerable: true,
5291
+ get: function () { return wodWikiCore.isNoteEditable; }
5292
+ });
5249
5293
  Object.defineProperty(exports, "lookupUnit", {
5250
5294
  enumerable: true,
5251
5295
  get: function () { return wodWikiCore.lookupUnit; }
5252
5296
  });
5297
+ Object.defineProperty(exports, "notebookSlugFromId", {
5298
+ enumerable: true,
5299
+ get: function () { return wodWikiCore.notebookSlugFromId; }
5300
+ });
5253
5301
  Object.defineProperty(exports, "systemDefaultUnit", {
5254
5302
  enumerable: true,
5255
5303
  get: function () { return wodWikiCore.systemDefaultUnit; }
5256
5304
  });
5305
+ Object.defineProperty(exports, "toNotebookId", {
5306
+ enumerable: true,
5307
+ get: function () { return wodWikiCore.toNotebookId; }
5308
+ });
5257
5309
  exports.BUILD_TIME = BUILD_TIME;
5258
5310
  exports.CONTENT_GROUPING_DIMENSIONS = CONTENT_GROUPING_DIMENSIONS;
5259
5311
  exports.DASHBOARD_GRID_MAX_COLS = DASHBOARD_GRID_MAX_COLS;
@@ -5336,6 +5388,7 @@ exports.migrateLegacyDashboardBodies = migrateLegacyDashboardBodies;
5336
5388
  exports.moveWidget = moveWidget;
5337
5389
  exports.normalizeSummaryFacts = normalizeSummaryFacts;
5338
5390
  exports.normalizeWql = normalizeWql;
5391
+ exports.notebookOfItem = notebookOfItem;
5339
5392
  exports.parseDashboardNote = parseDashboardNote;
5340
5393
  exports.parseDocument = parseDocument;
5341
5394
  exports.parseFlatProperties = parseFlatProperties;