@stapel/search-react 0.24.0 → 0.26.0
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/CHANGELOG.md +73 -0
- package/MODULE.md +21 -9
- package/README.md +109 -15
- package/dist/api/generated/schema.d.ts +18 -3
- package/dist/api/generated/schema.d.ts.map +1 -1
- package/dist/api/types.d.ts +39 -4
- package/dist/api/types.d.ts.map +1 -1
- package/dist/api/types.js.map +1 -1
- package/dist/default/FacetGroupControl.d.ts +20 -13
- package/dist/default/FacetGroupControl.d.ts.map +1 -1
- package/dist/default/FacetGroupControl.js +29 -21
- package/dist/default/FacetGroupControl.js.map +1 -1
- package/dist/default/FacetPanelPane.d.ts +15 -4
- package/dist/default/FacetPanelPane.d.ts.map +1 -1
- package/dist/default/FacetPanelPane.js +10 -5
- package/dist/default/FacetPanelPane.js.map +1 -1
- package/dist/default/OtherCategoriesLine.d.ts +49 -0
- package/dist/default/OtherCategoriesLine.d.ts.map +1 -0
- package/dist/default/OtherCategoriesLine.js +127 -0
- package/dist/default/OtherCategoriesLine.js.map +1 -0
- package/dist/default/SearchPage.d.ts +36 -0
- package/dist/default/SearchPage.d.ts.map +1 -1
- package/dist/default/SearchPage.js +12 -4
- package/dist/default/SearchPage.js.map +1 -1
- package/dist/default/SearchResultsPane.d.ts +15 -0
- package/dist/default/SearchResultsPane.d.ts.map +1 -1
- package/dist/default/SearchResultsPane.js +4 -1
- package/dist/default/SearchResultsPane.js.map +1 -1
- package/dist/default/index.d.ts +2 -0
- package/dist/default/index.d.ts.map +1 -1
- package/dist/default/index.js +1 -0
- package/dist/default/index.js.map +1 -1
- package/dist/headless/SearchStateProvider.d.ts +12 -2
- package/dist/headless/SearchStateProvider.d.ts.map +1 -1
- package/dist/headless/SearchStateProvider.js +58 -6
- package/dist/headless/SearchStateProvider.js.map +1 -1
- package/dist/headless/useOtherCategories.d.ts +52 -0
- package/dist/headless/useOtherCategories.d.ts.map +1 -0
- package/dist/headless/useOtherCategories.js +92 -0
- package/dist/headless/useOtherCategories.js.map +1 -0
- package/dist/i18n/es.d.ts.map +1 -1
- package/dist/i18n/es.js +3 -0
- package/dist/i18n/es.js.map +1 -1
- package/dist/i18n/generated/errors.es.gen.d.ts.map +1 -1
- package/dist/i18n/generated/errors.es.gen.js +1 -0
- package/dist/i18n/generated/errors.es.gen.js.map +1 -1
- package/dist/i18n/generated/errors.gen.d.ts +6 -0
- package/dist/i18n/generated/errors.gen.d.ts.map +1 -1
- package/dist/i18n/generated/errors.gen.js +3 -0
- package/dist/i18n/generated/errors.gen.js.map +1 -1
- package/dist/i18n/generated/errors.ru.gen.d.ts.map +1 -1
- package/dist/i18n/generated/errors.ru.gen.js +1 -0
- package/dist/i18n/generated/errors.ru.gen.js.map +1 -1
- package/dist/i18n/keys.d.ts +25 -0
- package/dist/i18n/keys.d.ts.map +1 -1
- package/dist/i18n/keys.js +29 -0
- package/dist/i18n/keys.js.map +1 -1
- package/dist/i18n/ru.d.ts.map +1 -1
- package/dist/i18n/ru.js +4 -0
- package/dist/i18n/ru.js.map +1 -1
- package/dist/index.d.ts +6 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/model/queries.d.ts.map +1 -1
- package/dist/model/queries.js +9 -1
- package/dist/model/queries.js.map +1 -1
- package/dist/state/facets.d.ts +62 -11
- package/dist/state/facets.d.ts.map +1 -1
- package/dist/state/facets.js +141 -29
- package/dist/state/facets.js.map +1 -1
- package/dist/state/urlState.d.ts +77 -2
- package/dist/state/urlState.d.ts.map +1 -1
- package/dist/state/urlState.js +80 -6
- package/dist/state/urlState.js.map +1 -1
- package/llms.txt +4 -2
- package/manifest.json +45 -1
- package/nav-manifest.json +1 -1
- package/package.json +10 -10
- package/src/analytics/generated/events.json +1 -1
- package/src/api/generated/schema.ts +18 -3
- package/src/api/types.ts +42 -4
- package/src/default/FacetGroupControl.tsx +27 -23
- package/src/default/FacetPanelPane.tsx +30 -8
- package/src/default/OtherCategoriesLine.tsx +238 -0
- package/src/default/SearchPage.tsx +57 -1
- package/src/default/SearchResultsPane.tsx +28 -0
- package/src/default/index.ts +13 -0
- package/src/headless/SearchStateProvider.tsx +94 -4
- package/src/headless/useOtherCategories.ts +193 -0
- package/src/i18n/es.ts +4 -0
- package/src/i18n/generated/errors.es.gen.ts +1 -0
- package/src/i18n/generated/errors.gen.ts +3 -0
- package/src/i18n/generated/errors.json +9 -0
- package/src/i18n/generated/errors.ru.gen.ts +1 -0
- package/src/i18n/keys.ts +32 -0
- package/src/i18n/ru.ts +5 -0
- package/src/index.ts +23 -1
- package/src/model/queries.ts +11 -1
- package/src/state/facets.ts +173 -30
- package/src/state/urlState.ts +137 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"facets.d.ts","sourceRoot":"","sources":["../../src/state/facets.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"facets.d.ts","sourceRoot":"","sources":["../../src/state/facets.ts"],"names":[],"mappings":"AA2DA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAGnF;;;;;;;;GAQG;AACH,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;AAkFrE;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,uBAAuB,EAAE,SAAS,MAAM,EAKpD,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,UAAU,GAAG,SAAS,GAAG,OAAO,CAK3E;AAED,8BAA8B;AAC9B,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,8E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,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAC3E,MAAM,CAkCR;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,SAAS,UAAU,EAAE,CAwHpF"}
|
package/dist/state/facets.js
CHANGED
|
@@ -50,7 +50,22 @@
|
|
|
50
50
|
* chipped is therefore decided from the category's own feature defs, by
|
|
51
51
|
* value TYPE (see {@link FACETABLE_FEATURE_TYPES}), not by what came back.
|
|
52
52
|
*/
|
|
53
|
-
import { VOCABULARY_BACKED_TYPES, featureConfig, featureType, formatFeatureValue, } from "@stapel/attributes-react";
|
|
53
|
+
import { VOCABULARY_BACKED_TYPES, featureConfig, featureType, formatFeatureValue, optionsRefOf, } from "@stapel/attributes-react";
|
|
54
|
+
import { facetKeyMapFromLabels } from "./urlState.js";
|
|
55
|
+
/**
|
|
56
|
+
* Is this a DEVELOPMENT build — i.e. may this module talk to the console?
|
|
57
|
+
*
|
|
58
|
+
* Asked as "is it dev", never as "is it not production", because the second
|
|
59
|
+
* form fails open: a browser bundle with no `process` shim leaves `NODE_ENV`
|
|
60
|
+
* undefined, `undefined !== "production"` is true, and a buyer's console gets
|
|
61
|
+
* `facet group "complectation" has no values to draw` on every page load of a
|
|
62
|
+
* live board. A warning nobody who can fix it will ever read is noise in
|
|
63
|
+
* somebody else's browser.
|
|
64
|
+
*/
|
|
65
|
+
function inDevelopment() {
|
|
66
|
+
const env = typeof process === "undefined" ? undefined : process.env;
|
|
67
|
+
return env?.NODE_ENV === "development" || env?.NODE_ENV === "test";
|
|
68
|
+
}
|
|
54
69
|
/** Slugs already complained about — one warning per slug per page load, not
|
|
55
70
|
* one per render. */
|
|
56
71
|
const warnedSlugs = new Set();
|
|
@@ -64,8 +79,7 @@ const warnedSlugs = new Set();
|
|
|
64
79
|
* at all; `FacetGroup.labelSource` is how a surface marks it up for a test.
|
|
65
80
|
*/
|
|
66
81
|
function warnUnnamedGroup(slug) {
|
|
67
|
-
|
|
68
|
-
if (env?.NODE_ENV === "production")
|
|
82
|
+
if (!inDevelopment())
|
|
69
83
|
return;
|
|
70
84
|
if (warnedSlugs.has(slug))
|
|
71
85
|
return;
|
|
@@ -94,19 +108,19 @@ const warnedUndrawable = new Set();
|
|
|
94
108
|
* category's schema), and neither of them can see it from the page.
|
|
95
109
|
*/
|
|
96
110
|
function warnUndrawableGroup(group) {
|
|
97
|
-
|
|
98
|
-
if (env?.NODE_ENV === "production")
|
|
111
|
+
if (!inDevelopment())
|
|
99
112
|
return;
|
|
100
113
|
if (warnedUndrawable.has(group.slug))
|
|
101
114
|
return;
|
|
102
115
|
warnedUndrawable.add(group.slug);
|
|
103
|
-
console.warn(`[search-react] facet group "${group.slug}"
|
|
104
|
-
`answer
|
|
105
|
-
? " and
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
116
|
+
console.warn(`[search-react] facet group "${group.slug}" is not drawn: no candidate in ` +
|
|
117
|
+
`this answer carries any of its values${group.options.length === 0
|
|
118
|
+
? " and it has no options at all (the answer did not count it and " +
|
|
119
|
+
"the schema passed to this page enumerates nothing for it)"
|
|
120
|
+
: ` (${String(group.options.length)} options, every count zero or null)`}, and nothing is selected on it.` +
|
|
121
|
+
(group.feature?.mandatory === true && !facetGroupIsVocabularyBacked(group)
|
|
122
|
+
? " The schema marks this axis REQUIRED — a required axis with no" +
|
|
123
|
+
" evidence is a plan or a schema fault, not an empty shelf."
|
|
110
124
|
: ""));
|
|
111
125
|
}
|
|
112
126
|
/**
|
|
@@ -209,6 +223,45 @@ export function orderFacetGroups(groups) {
|
|
|
209
223
|
export function facetGroupHasEvidence(group) {
|
|
210
224
|
return group.options.some((option) => (option.count ?? 0) > 0);
|
|
211
225
|
}
|
|
226
|
+
/**
|
|
227
|
+
* Is this axis one a person can SEARCH even with no evidence behind it — an
|
|
228
|
+
* axis whose values live in a VOCABULARY?
|
|
229
|
+
*
|
|
230
|
+
* The one thing a zero-evidence group can still be. A `ref_select` whose
|
|
231
|
+
* config is a pointer into a vocabulary is a dictionary of hundreds; the
|
|
232
|
+
* control for it is a field with a search box, and that box searches the
|
|
233
|
+
* DICTIONARY, not the buckets — so it is worth opening on a leaf holding one
|
|
234
|
+
* listing exactly as it is on one holding thirty thousand. The stand being
|
|
235
|
+
* thin is a fact about the stand.
|
|
236
|
+
*
|
|
237
|
+
* `mandatory` is deliberately NOT asked. It was, for one round, and on the
|
|
238
|
+
* live laptops leaf not one of `vendor`, `model`, `screen_size` is marked
|
|
239
|
+
* required — so the rule that was meant to save the make picker deleted the
|
|
240
|
+
* vendor picker one category over. What makes the field usable is the
|
|
241
|
+
* dictionary behind it; whether the composer forces a seller to fill the
|
|
242
|
+
* field says nothing about that.
|
|
243
|
+
*/
|
|
244
|
+
function isSearchableVocabularyAxis(group) {
|
|
245
|
+
return facetGroupIsVocabularyBacked(group);
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Does this axis draw its values from a VOCABULARY rather than an inline
|
|
249
|
+
* option table?
|
|
250
|
+
*
|
|
251
|
+
* Asked of the schema first (`ref_select`/`ref_hierarchical_select` — the
|
|
252
|
+
* types whose whole config is an `optionsRef` pointer), and of the answer
|
|
253
|
+
* when there is no schema to ask: a host that threaded no feature list still
|
|
254
|
+
* gets the right control if the server named the vocabulary. A def of any
|
|
255
|
+
* other type is a NO however it is configured — a bounded `int` carrying an
|
|
256
|
+
* `optionsRef` (the live cars `year`) is a range, and a range is not a
|
|
257
|
+
* dictionary.
|
|
258
|
+
*/
|
|
259
|
+
export function facetGroupIsVocabularyBacked(group) {
|
|
260
|
+
const type = group.feature === undefined ? undefined : featureType(group.feature);
|
|
261
|
+
if (type !== undefined)
|
|
262
|
+
return VOCABULARY_BACKED_TYPES.includes(type);
|
|
263
|
+
return group.vocabulary !== undefined;
|
|
264
|
+
}
|
|
212
265
|
/**
|
|
213
266
|
* Is there anything for a surface to DRAW here?
|
|
214
267
|
*
|
|
@@ -216,22 +269,39 @@ export function facetGroupHasEvidence(group) {
|
|
|
216
269
|
* `options.length > 0` — one predicate, or the two surfaces drift into two
|
|
217
270
|
* opinions about what an empty group is.
|
|
218
271
|
*
|
|
219
|
-
*
|
|
220
|
-
*
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
*
|
|
226
|
-
*
|
|
227
|
-
*
|
|
228
|
-
*
|
|
229
|
-
*
|
|
272
|
+
* ── An axis with no evidence is not a filter, it is a heading ─────────────
|
|
273
|
+
*
|
|
274
|
+
* The predicate used to ask `options.length > 0`, and on a live laptops leaf
|
|
275
|
+
* (D249, `/c/noutbuki`) that drew six of six groups as accordions with
|
|
276
|
+
* nothing a person could narrow by: the answer counted every axis and gave
|
|
277
|
+
* every bucket a zero, and the axes the budget skipped kept their authored
|
|
278
|
+
* option tables with `count: null` on every row. Six headings, no filter, and
|
|
279
|
+
* the results below them unchanged whichever box was ticked.
|
|
280
|
+
*
|
|
281
|
+
* So the question is EVIDENCE, not option count: at least one value some
|
|
282
|
+
* candidate in this result set actually carries. Three exemptions, and they
|
|
283
|
+
* are the whole rule:
|
|
284
|
+
*
|
|
285
|
+
* - a group the reader has already FILTERED on, whatever its counts say —
|
|
286
|
+
* a constraint with no control to remove it is worse than a bare heading;
|
|
287
|
+
* - a vocabulary-backed axis (see {@link isSearchableVocabularyAxis}): its
|
|
288
|
+
* control is a FIELD, the field searches a dictionary the answer never
|
|
289
|
+
* enumerated, and it works with no buckets at all — this is the make on a
|
|
290
|
+
* cars leaf with three cars and the vendor on a laptops leaf with one;
|
|
291
|
+
* - nothing else. An authored `select` with no evidence is three checkboxes
|
|
292
|
+
* guaranteed to return nothing, and it costs a heading in a 280px rail and
|
|
293
|
+
* a chip on a 390px row to say so.
|
|
294
|
+
*
|
|
295
|
+
* A dropped axis is NAMED in development — a required axis disappearing out
|
|
296
|
+
* of a rail is a fault this pair spent a release chasing, and it must not
|
|
297
|
+
* disappear silently a second time.
|
|
230
298
|
*/
|
|
231
299
|
export function facetGroupIsDrawable(group) {
|
|
232
300
|
if (group.selected.length > 0)
|
|
233
301
|
return true;
|
|
234
|
-
if (group
|
|
302
|
+
if (facetGroupHasEvidence(group))
|
|
303
|
+
return true;
|
|
304
|
+
if (isSearchableVocabularyAxis(group))
|
|
235
305
|
return true;
|
|
236
306
|
warnUndrawableGroup(group);
|
|
237
307
|
return false;
|
|
@@ -381,6 +451,24 @@ function resolveLabel(input, feature, slug, value, labelOptions) {
|
|
|
381
451
|
* beats no heading, and it renders MARKED — `labelSource: "none"`, a warning
|
|
382
452
|
* in development, and a data attribute on the drawn group.
|
|
383
453
|
*/
|
|
454
|
+
/**
|
|
455
|
+
* Which vocabulary an axis draws from: the answer's word for it, then the
|
|
456
|
+
* schema's `optionsRef`. Neither invents one — `undefined` is "nobody said".
|
|
457
|
+
*/
|
|
458
|
+
/** `exactOptionalPropertyTypes` makes an absent key and an `undefined` one
|
|
459
|
+
* different types; this spreads to nothing when nobody named a vocabulary. */
|
|
460
|
+
function optionalVocabulary(vocabulary) {
|
|
461
|
+
return vocabulary === undefined ? {} : { vocabulary };
|
|
462
|
+
}
|
|
463
|
+
function resolveVocabulary(input, feature, slug) {
|
|
464
|
+
const stated = input.facetLabels?.[slug]?.vocabulary;
|
|
465
|
+
if (typeof stated === "string" && stated.length > 0)
|
|
466
|
+
return stated;
|
|
467
|
+
if (feature === undefined)
|
|
468
|
+
return undefined;
|
|
469
|
+
const ref = optionsRefOf(featureConfig(feature));
|
|
470
|
+
return ref === undefined || ref.vocabulary.length === 0 ? undefined : ref.vocabulary;
|
|
471
|
+
}
|
|
384
472
|
function resolveGroupLabel(input, feature, slug) {
|
|
385
473
|
const answer = input.facetLabels?.[slug]?.label;
|
|
386
474
|
if (typeof answer === "string" && answer.length > 0) {
|
|
@@ -462,13 +550,22 @@ export function buildFacetGroups(input) {
|
|
|
462
550
|
const bySlug = new Map();
|
|
463
551
|
for (const feature of input.categoryFeatures ?? [])
|
|
464
552
|
bySlug.set(feature.slug, feature);
|
|
553
|
+
// The answer's address keys, so a URL carrying `f.make` selects the group
|
|
554
|
+
// called `make_ref_select` instead of inventing a second one beside it.
|
|
555
|
+
// Both forms are read here whatever the codec did upstream: a cold link is
|
|
556
|
+
// parsed before any answer exists, so the state can legitimately hold the
|
|
557
|
+
// short key while the groups are keyed by slug.
|
|
558
|
+
const keys = facetKeyMapFromLabels(input.facetLabels);
|
|
559
|
+
const applied = (slug) => input.state.filters[slug] ??
|
|
560
|
+
input.state.filters[keys.write[slug] ?? slug] ??
|
|
561
|
+
[];
|
|
465
562
|
const skipped = new Set(input.meta.skipped);
|
|
466
563
|
const slugs = [];
|
|
467
564
|
const seen = new Set();
|
|
468
565
|
for (const slug of [
|
|
469
566
|
...Object.keys(input.facets),
|
|
470
567
|
...input.meta.skipped,
|
|
471
|
-
...Object.keys(input.state.filters),
|
|
568
|
+
...Object.keys(input.state.filters).map((key) => keys.read[key] ?? key),
|
|
472
569
|
]) {
|
|
473
570
|
if (seen.has(slug))
|
|
474
571
|
continue;
|
|
@@ -488,8 +585,7 @@ export function buildFacetGroups(input) {
|
|
|
488
585
|
// for a schema that says nothing about it. That is the live case; a
|
|
489
586
|
// wrong-schema case where some other category types `make_ref_select` as
|
|
490
587
|
// free text is not one this pair can tell apart from a real `imei`.
|
|
491
|
-
|
|
492
|
-
if (!applied && !isFacetableFeature(bySlug.get(slug)))
|
|
588
|
+
if (applied(slug).length === 0 && !isFacetableFeature(bySlug.get(slug)))
|
|
493
589
|
continue;
|
|
494
590
|
slugs.push(slug);
|
|
495
591
|
}
|
|
@@ -497,7 +593,7 @@ export function buildFacetGroups(input) {
|
|
|
497
593
|
const feature = bySlug.get(slug);
|
|
498
594
|
const counts = input.facets[slug] ?? {};
|
|
499
595
|
const counted = !skipped.has(slug) && slug in input.facets;
|
|
500
|
-
const selected =
|
|
596
|
+
const selected = applied(slug);
|
|
501
597
|
// The authored option order, from whichever copy of the category config
|
|
502
598
|
// this page has. An authored list reshuffled by count is a size chart
|
|
503
599
|
// that moves on every click, and until 0.11 a host that passed no schema
|
|
@@ -555,6 +651,8 @@ export function buildFacetGroups(input) {
|
|
|
555
651
|
};
|
|
556
652
|
return {
|
|
557
653
|
slug,
|
|
654
|
+
urlKey: keys.write[slug] ?? slug,
|
|
655
|
+
...optionalVocabulary(resolveVocabulary(input, feature, slug)),
|
|
558
656
|
...resolveGroupLabel(input, feature, slug),
|
|
559
657
|
feature,
|
|
560
658
|
counted,
|
|
@@ -613,6 +711,20 @@ function keepsAnAxisOpen(group) {
|
|
|
613
711
|
return true;
|
|
614
712
|
if (group.selected.length > 0)
|
|
615
713
|
return true;
|
|
616
|
-
|
|
714
|
+
// A vocabulary axis survives its own zero: its control is a field over a
|
|
715
|
+
// dictionary the answer never enumerated, so "this stand holds no Toyotas
|
|
716
|
+
// yet" is not a reason to take the make picker off the page. Same
|
|
717
|
+
// clause as `facetGroupIsDrawable`'s, or the rail would ask a question the
|
|
718
|
+
// builder had already answered by deleting the group.
|
|
719
|
+
if (isSearchableVocabularyAxis(group))
|
|
720
|
+
return true;
|
|
721
|
+
if (facetCoverage(group) > 0)
|
|
722
|
+
return true;
|
|
723
|
+
// Said here as well as in `facetGroupIsDrawable`, because a group withheld
|
|
724
|
+
// at BUILD time never reaches a surface to be named there — and a counted
|
|
725
|
+
// axis whose every bucket is zero is exactly the shape the laptops leaf
|
|
726
|
+
// arrived in. One warning per slug per page load either way.
|
|
727
|
+
warnUndrawableGroup(group);
|
|
728
|
+
return false;
|
|
617
729
|
}
|
|
618
730
|
//# sourceMappingURL=facets.js.map
|
package/dist/state/facets.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"facets.js","sourceRoot":"","sources":["../../src/state/facets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAK,EAAE,EAAE,CAAC,CAAC;gBAC9B,KAAK;gBACL,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI;gBAC5C,kEAAkE;gBAClE,6DAA6D;gBAC7D,2DAA2D;gBAC3D,GAAG,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,CAAC;gBAC1D,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC;aACnC,CAAC,CAAC;SACJ,CAAC;IACJ,CAAC,CAAC,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;AAC7B,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,SAAS,eAAe,CAAC,KAAiB;IACxC,IAAI,CAAC,KAAK,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC;IAChC,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IAC3C,yEAAyE;IACzE,0EAA0E;IAC1E,kEAAkE;IAClE,2EAA2E;IAC3E,sDAAsD;IACtD,IAAI,0BAA0B,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACnD,IAAI,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IAC1C,2EAA2E;IAC3E,0EAA0E;IAC1E,wEAAwE;IACxE,6DAA6D;IAC7D,mBAAmB,CAAC,KAAK,CAAC,CAAC;IAC3B,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/state/urlState.d.ts
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* subpath. Keeping the codec here is what makes the round trip testable in
|
|
20
20
|
* both directions without a DOM.
|
|
21
21
|
*/
|
|
22
|
-
import type { SearchQueryState, SearchRange } from "../api/types.js";
|
|
22
|
+
import type { FacetLabelsMap, SearchQueryState, SearchRange } from "../api/types.js";
|
|
23
23
|
/** Wire parameter names, in one place so a rename is one edit. */
|
|
24
24
|
export declare const SEARCH_PARAM: {
|
|
25
25
|
readonly type: "type";
|
|
@@ -41,6 +41,65 @@ export declare const SEARCH_PARAM: {
|
|
|
41
41
|
export declare const FILTER_PREFIX = "f.";
|
|
42
42
|
/** Prefix of a range filter parameter (`r.price=100..500`). */
|
|
43
43
|
export declare const RANGE_PREFIX = "r.";
|
|
44
|
+
/**
|
|
45
|
+
* THE SHORT KEY IN THE ADDRESS — `f.make`, not `f.make_ref_select`.
|
|
46
|
+
*
|
|
47
|
+
* A feature's identity is its slug and stays its slug: nothing is renamed,
|
|
48
|
+
* nothing is stored, and the request this pair sends carries whatever key the
|
|
49
|
+
* state holds because the server accepts both forms inside a category scope
|
|
50
|
+
* (`stapel-search` 0.14.4, `facets.resolve_url_key`). What changes is only
|
|
51
|
+
* what a PERSON reads in their own address bar: `f.make_ref_select=toyota`
|
|
52
|
+
* says "make" once and "how the importer typed it" once, and the second half
|
|
53
|
+
* is noise a reader cannot act on.
|
|
54
|
+
*
|
|
55
|
+
* The map is the ANSWER's — `facet_labels[slug].url_key`, derived per request
|
|
56
|
+
* against the queried category's own feature list. This module never derives
|
|
57
|
+
* one by chopping suffixes off slugs: the same audit that produced the rule
|
|
58
|
+
* counted 181 suffixed slugs of which every one collides with a differently
|
|
59
|
+
* typed sibling once stripped catalogue-wide, so shortening is only safe
|
|
60
|
+
* inside a scope the server knows and this codec does not.
|
|
61
|
+
*
|
|
62
|
+
* Two directions, both needed and neither symmetric:
|
|
63
|
+
*
|
|
64
|
+
* - {@link FacetKeyMap.write} is `slug → key`, applied by
|
|
65
|
+
* {@link writeSearchState} so a click produces the short address;
|
|
66
|
+
* - {@link FacetKeyMap.read} is `key → slug`, applied by
|
|
67
|
+
* {@link parseSearchState} so the short address and the full one both land
|
|
68
|
+
* on the same state, and a chip drawn from a group keyed by slug knows it
|
|
69
|
+
* is selected.
|
|
70
|
+
*/
|
|
71
|
+
export interface FacetKeyMap {
|
|
72
|
+
/** `{slug: key to write}`. A slug with no short form is absent. */
|
|
73
|
+
readonly write: Readonly<Record<string, string>>;
|
|
74
|
+
/** `{key off the address: the slug it names}`. */
|
|
75
|
+
readonly read: Readonly<Record<string, string>>;
|
|
76
|
+
}
|
|
77
|
+
/** No short keys — a pre-0.14.4 server, or a query with no category scope. */
|
|
78
|
+
export declare const EMPTY_FACET_KEYS: FacetKeyMap;
|
|
79
|
+
/**
|
|
80
|
+
* Normalize `{slug: url_key}` into the two directions, refusing anything
|
|
81
|
+
* ambiguous.
|
|
82
|
+
*
|
|
83
|
+
* The server already applies these rules; they are applied again here because
|
|
84
|
+
* this codec cannot verify which server answered, and the cost of getting it
|
|
85
|
+
* wrong is a filter that reads back as a different filter. A short form is
|
|
86
|
+
* used only when it is:
|
|
87
|
+
*
|
|
88
|
+
* - not a real slug of the same answer — `f.make` in a scope declaring both
|
|
89
|
+
* `make` and `make_ref_select` is the feature CALLED `make`, and the other
|
|
90
|
+
* one keeps its full slug (the server's own rule, stated the same way);
|
|
91
|
+
* - claimed by exactly one slug. Two slugs shortening to one key means
|
|
92
|
+
* neither may use it: a collision keeps the slug on both sides.
|
|
93
|
+
*/
|
|
94
|
+
export declare function buildFacetKeyMap(declared: Readonly<Record<string, string | null | undefined>>): FacetKeyMap;
|
|
95
|
+
/** {@link buildFacetKeyMap} over an answer's `facet_labels`. */
|
|
96
|
+
export declare function facetKeyMapFromLabels(labels: FacetLabelsMap | undefined): FacetKeyMap;
|
|
97
|
+
/** The slug an address key names. Unknown keys pass through unchanged — the
|
|
98
|
+
* server resolves what it recognises and 400s on what it does not, and a
|
|
99
|
+
* codec that dropped the key would lose a filter the answer can still honour. */
|
|
100
|
+
export declare function facetSlugForKey(key: string, keys: FacetKeyMap | undefined): string;
|
|
101
|
+
/** The address key a slug is written as. The slug itself when there is none. */
|
|
102
|
+
export declare function facetKeyForSlug(slug: string, keys: FacetKeyMap | undefined): string;
|
|
44
103
|
/**
|
|
45
104
|
* Something in the URL this codec could not make sense of.
|
|
46
105
|
*
|
|
@@ -114,6 +173,18 @@ export interface ParseSearchStateOptions {
|
|
|
114
173
|
readonly defaultCategory?: string;
|
|
115
174
|
/** Applied when the URL carries no `lang`. */
|
|
116
175
|
readonly defaultLang?: string;
|
|
176
|
+
/**
|
|
177
|
+
* The answer's short-key map (see {@link FacetKeyMap}), so `f.make` off the
|
|
178
|
+
* address becomes the state's `make_ref_select`.
|
|
179
|
+
*
|
|
180
|
+
* Optional and late by nature: the map is a property of the ANSWER, so the
|
|
181
|
+
* first parse of a cold link runs without it. That is not a failure — the
|
|
182
|
+
* short key goes to the server, which resolves it in the category scope and
|
|
183
|
+
* answers correctly — it only means the group's own selection is matched
|
|
184
|
+
* by key rather than by slug until the answer lands (`buildFacetGroups`
|
|
185
|
+
* matches both, so nothing flickers).
|
|
186
|
+
*/
|
|
187
|
+
readonly facetKeys?: FacetKeyMap;
|
|
117
188
|
}
|
|
118
189
|
/** URL → state. Never throws; anything unreadable lands in `issues`. */
|
|
119
190
|
export declare function parseSearchState(params: URLSearchParams, options: ParseSearchStateOptions): ParsedSearchState;
|
|
@@ -124,8 +195,12 @@ export declare function parseSearchState(params: URLSearchParams, options: Parse
|
|
|
124
195
|
* is copied through untouched, so a host's own `?ref=`/`utm_*` survives a
|
|
125
196
|
* facet click. Every parameter it DOES own is rewritten from the state, so a
|
|
126
197
|
* removed filter actually leaves the URL instead of lingering as a stale key.
|
|
198
|
+
*
|
|
199
|
+
* `keys` is the answer's short-key map: a filter is written as its
|
|
200
|
+
* `url_key` when the answer states one and as its slug otherwise, so the two
|
|
201
|
+
* halves of a round trip agree without either side chopping at a string.
|
|
127
202
|
*/
|
|
128
|
-
export declare function writeSearchState(state: SearchQueryState, base?: URLSearchParams): URLSearchParams;
|
|
203
|
+
export declare function writeSearchState(state: SearchQueryState, base?: URLSearchParams, keys?: FacetKeyMap): URLSearchParams;
|
|
129
204
|
/** Is this URL parameter owned by the search codec? */
|
|
130
205
|
export declare function ownsParam(key: string): boolean;
|
|
131
206
|
/** A patch over {@link SearchQueryState}; `null` clears an optional member. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"urlState.d.ts","sourceRoot":"","sources":["../../src/state/urlState.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"urlState.d.ts","sourceRoot":"","sources":["../../src/state/urlState.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,KAAK,EACV,cAAc,EAGd,gBAAgB,EAChB,WAAW,EACZ,MAAM,iBAAiB,CAAC;AAEzB,kEAAkE;AAClE,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;CAef,CAAC;AAEX,4DAA4D;AAC5D,eAAO,MAAM,aAAa,OAAO,CAAC;AAClC,+DAA+D;AAC/D,eAAO,MAAM,YAAY,OAAO,CAAC;AAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,WAAW,WAAW;IAC1B,mEAAmE;IACnE,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACjD,kDAAkD;IAClD,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACjD;AAED,8EAA8E;AAC9E,eAAO,MAAM,gBAAgB,EAAE,WAAqC,CAAC;AAErE;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC,GAC5D,WAAW,CA6Bb;AAED,gEAAgE;AAChE,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,cAAc,GAAG,SAAS,GACjC,WAAW,CA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G,gBAAgB,CAOtE;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,gBAAgB,GAAG,MAAM,CAKjE"}
|
package/dist/state/urlState.js
CHANGED
|
@@ -19,6 +19,72 @@ export const SEARCH_PARAM = {
|
|
|
19
19
|
export const FILTER_PREFIX = "f.";
|
|
20
20
|
/** Prefix of a range filter parameter (`r.price=100..500`). */
|
|
21
21
|
export const RANGE_PREFIX = "r.";
|
|
22
|
+
/** No short keys — a pre-0.14.4 server, or a query with no category scope. */
|
|
23
|
+
export const EMPTY_FACET_KEYS = { write: {}, read: {} };
|
|
24
|
+
/**
|
|
25
|
+
* Normalize `{slug: url_key}` into the two directions, refusing anything
|
|
26
|
+
* ambiguous.
|
|
27
|
+
*
|
|
28
|
+
* The server already applies these rules; they are applied again here because
|
|
29
|
+
* this codec cannot verify which server answered, and the cost of getting it
|
|
30
|
+
* wrong is a filter that reads back as a different filter. A short form is
|
|
31
|
+
* used only when it is:
|
|
32
|
+
*
|
|
33
|
+
* - not a real slug of the same answer — `f.make` in a scope declaring both
|
|
34
|
+
* `make` and `make_ref_select` is the feature CALLED `make`, and the other
|
|
35
|
+
* one keeps its full slug (the server's own rule, stated the same way);
|
|
36
|
+
* - claimed by exactly one slug. Two slugs shortening to one key means
|
|
37
|
+
* neither may use it: a collision keeps the slug on both sides.
|
|
38
|
+
*/
|
|
39
|
+
export function buildFacetKeyMap(declared) {
|
|
40
|
+
const slugs = Object.keys(declared);
|
|
41
|
+
const real = new Set(slugs);
|
|
42
|
+
const claims = new Map();
|
|
43
|
+
for (const slug of slugs) {
|
|
44
|
+
const key = declared[slug];
|
|
45
|
+
if (typeof key !== "string" || key.length === 0 || key === slug)
|
|
46
|
+
continue;
|
|
47
|
+
claims.set(key, (claims.get(key) ?? 0) + 1);
|
|
48
|
+
}
|
|
49
|
+
const write = {};
|
|
50
|
+
const read = {};
|
|
51
|
+
for (const slug of slugs) {
|
|
52
|
+
const key = declared[slug];
|
|
53
|
+
if (typeof key !== "string" ||
|
|
54
|
+
key.length === 0 ||
|
|
55
|
+
key === slug ||
|
|
56
|
+
real.has(key) ||
|
|
57
|
+
claims.get(key) !== 1) {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
write[slug] = key;
|
|
61
|
+
read[key] = slug;
|
|
62
|
+
}
|
|
63
|
+
// A real slug always wins, whatever some other group shortened to. Written
|
|
64
|
+
// last so it overwrites a short form that collided with it.
|
|
65
|
+
for (const slug of slugs)
|
|
66
|
+
read[slug] = slug;
|
|
67
|
+
return { write, read };
|
|
68
|
+
}
|
|
69
|
+
/** {@link buildFacetKeyMap} over an answer's `facet_labels`. */
|
|
70
|
+
export function facetKeyMapFromLabels(labels) {
|
|
71
|
+
if (labels === undefined)
|
|
72
|
+
return EMPTY_FACET_KEYS;
|
|
73
|
+
const declared = {};
|
|
74
|
+
for (const [slug, entry] of Object.entries(labels))
|
|
75
|
+
declared[slug] = entry.url_key;
|
|
76
|
+
return buildFacetKeyMap(declared);
|
|
77
|
+
}
|
|
78
|
+
/** The slug an address key names. Unknown keys pass through unchanged — the
|
|
79
|
+
* server resolves what it recognises and 400s on what it does not, and a
|
|
80
|
+
* codec that dropped the key would lose a filter the answer can still honour. */
|
|
81
|
+
export function facetSlugForKey(key, keys) {
|
|
82
|
+
return keys?.read[key] ?? key;
|
|
83
|
+
}
|
|
84
|
+
/** The address key a slug is written as. The slug itself when there is none. */
|
|
85
|
+
export function facetKeyForSlug(slug, keys) {
|
|
86
|
+
return keys?.write[slug] ?? slug;
|
|
87
|
+
}
|
|
22
88
|
const ISSUE_KEY = {
|
|
23
89
|
not_a_number: "search.url.issue.not_a_number",
|
|
24
90
|
geo_incomplete: "search.url.issue.geo_incomplete",
|
|
@@ -132,8 +198,11 @@ export function parseSearchState(params, options) {
|
|
|
132
198
|
if (key.startsWith(FILTER_PREFIX) && key.length > FILTER_PREFIX.length) {
|
|
133
199
|
// `getAll` is the whole point: a repeated key is OR within the slug.
|
|
134
200
|
const values = params.getAll(key).filter((v) => v.length > 0);
|
|
135
|
-
if (values.length
|
|
136
|
-
|
|
201
|
+
if (values.length === 0)
|
|
202
|
+
continue;
|
|
203
|
+
// Both forms read: `f.make` and `f.make_ref_select` land on one slug.
|
|
204
|
+
const slug = facetSlugForKey(key.slice(FILTER_PREFIX.length), options.facetKeys);
|
|
205
|
+
filters[slug] = [...(filters[slug] ?? []), ...values];
|
|
137
206
|
continue;
|
|
138
207
|
}
|
|
139
208
|
if (key.startsWith(RANGE_PREFIX) && key.length > RANGE_PREFIX.length) {
|
|
@@ -151,7 +220,7 @@ export function parseSearchState(params, options) {
|
|
|
151
220
|
const to = raw.slice(separator + 2);
|
|
152
221
|
if (from.length === 0 && to.length === 0)
|
|
153
222
|
continue;
|
|
154
|
-
ranges[key.slice(RANGE_PREFIX.length)] = {
|
|
223
|
+
ranges[facetSlugForKey(key.slice(RANGE_PREFIX.length), options.facetKeys)] = {
|
|
155
224
|
...(from.length > 0 ? { from } : {}),
|
|
156
225
|
...(to.length > 0 ? { to } : {}),
|
|
157
226
|
};
|
|
@@ -200,8 +269,12 @@ function optional(key, value) {
|
|
|
200
269
|
* is copied through untouched, so a host's own `?ref=`/`utm_*` survives a
|
|
201
270
|
* facet click. Every parameter it DOES own is rewritten from the state, so a
|
|
202
271
|
* removed filter actually leaves the URL instead of lingering as a stale key.
|
|
272
|
+
*
|
|
273
|
+
* `keys` is the answer's short-key map: a filter is written as its
|
|
274
|
+
* `url_key` when the answer states one and as its slug otherwise, so the two
|
|
275
|
+
* halves of a round trip agree without either side chopping at a string.
|
|
203
276
|
*/
|
|
204
|
-
export function writeSearchState(state, base) {
|
|
277
|
+
export function writeSearchState(state, base, keys) {
|
|
205
278
|
const next = new URLSearchParams();
|
|
206
279
|
if (base !== undefined) {
|
|
207
280
|
for (const key of new Set(base.keys())) {
|
|
@@ -221,8 +294,9 @@ export function writeSearchState(state, base) {
|
|
|
221
294
|
if (state.owner !== undefined)
|
|
222
295
|
next.set(SEARCH_PARAM.owner, state.owner);
|
|
223
296
|
for (const slug of Object.keys(state.filters).sort()) {
|
|
297
|
+
const key = facetKeyForSlug(slug, keys);
|
|
224
298
|
for (const value of state.filters[slug] ?? []) {
|
|
225
|
-
next.append(`${FILTER_PREFIX}${
|
|
299
|
+
next.append(`${FILTER_PREFIX}${key}`, value);
|
|
226
300
|
}
|
|
227
301
|
}
|
|
228
302
|
for (const slug of Object.keys(state.ranges).sort()) {
|
|
@@ -231,7 +305,7 @@ export function writeSearchState(state, base) {
|
|
|
231
305
|
continue;
|
|
232
306
|
if (range.from === undefined && range.to === undefined)
|
|
233
307
|
continue;
|
|
234
|
-
next.set(`${RANGE_PREFIX}${slug}`, `${range.from ?? ""}..${range.to ?? ""}`);
|
|
308
|
+
next.set(`${RANGE_PREFIX}${facetKeyForSlug(slug, keys)}`, `${range.from ?? ""}..${range.to ?? ""}`);
|
|
235
309
|
}
|
|
236
310
|
if (state.geo !== undefined) {
|
|
237
311
|
if (state.geo.kind === "bbox") {
|