From 9bdcf0476f4b222cb806755510b1dc3d4d545e1e Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Fri, 23 Jan 2026 20:48:02 -0400 Subject: find, data, checks: dummy 'from' option in find() --- src/data/checks.js | 11 +++++++++++ src/data/composite/wiki-data/withResolvedReference.js | 7 ++++--- src/data/composite/wiki-data/withResolvedReferenceList.js | 7 ++++--- src/find.js | 2 ++ 4 files changed, 21 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/data/checks.js b/src/data/checks.js index ebf6aad4..2b660421 100644 --- a/src/data/checks.js +++ b/src/data/checks.js @@ -229,6 +229,16 @@ function decoSuppressFindErrors(findFn, {property}) { }, findFn); } +function decoFindThing(findFn, thing) { + return (ref, opts) => { + if (opts) { + return findFn(ref, {...opts, from: thing}); + } else { + return findFn(ref, {from: thing}); + } + }; +} + // Warn about references across data which don't match anything. This involves // using the find() functions on all references, setting it to 'error' mode, and // collecting everything in a structured logged (which gets logged if there are @@ -549,6 +559,7 @@ export function filterReferenceErrors(wikiData, { findFn = decoSuppressFindErrors(findFn, {property}); findFn = decoAnnotateFindErrors(findFn); + findFn = decoFindThing(findFn, thing); const fieldPropertyMessage = getFieldPropertyMessage( diff --git a/src/data/composite/wiki-data/withResolvedReference.js b/src/data/composite/wiki-data/withResolvedReference.js index d9a05367..58523a65 100644 --- a/src/data/composite/wiki-data/withResolvedReference.js +++ b/src/data/composite/wiki-data/withResolvedReference.js @@ -38,14 +38,15 @@ export default templateCompositeFrom({ }), { - dependencies: [input('findOptions')], + dependencies: [input('findOptions'), input.myself()], compute: (continuation, { [input('findOptions')]: findOptions, + [input.myself()]: myself, }) => continuation({ ['#findOptions']: (findOptions - ? {...findOptions, mode: 'quiet'} - : {mode: 'quiet'}), + ? {...findOptions, mode: 'quiet', from: myself} + : {mode: 'quiet', from: myself}), }), }, diff --git a/src/data/composite/wiki-data/withResolvedReferenceList.js b/src/data/composite/wiki-data/withResolvedReferenceList.js index 14ce6919..23f3c365 100644 --- a/src/data/composite/wiki-data/withResolvedReferenceList.js +++ b/src/data/composite/wiki-data/withResolvedReferenceList.js @@ -49,14 +49,15 @@ export default templateCompositeFrom({ }), { - dependencies: [input('findOptions')], + dependencies: [input('findOptions'), input.myself()], compute: (continuation, { [input('findOptions')]: findOptions, + [input.myself()]: myself, }) => continuation({ ['#findOptions']: (findOptions - ? {...findOptions, mode: 'quiet'} - : {mode: 'quiet'}), + ? {...findOptions, mode: 'quiet', from: myself} + : {mode: 'quiet', from: myself}), }), }, diff --git a/src/find.js b/src/find.js index 5740ebd4..7b2ea7e0 100644 --- a/src/find.js +++ b/src/find.js @@ -288,6 +288,8 @@ function findHelper({ // console. mode = 'warn', + from = null, + fuzz = { capitalization: false, kebab: false, -- cgit 1.3.0-6-gf8a5