@jskit-ai/http-web 0.2.26 → 0.2.28

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 CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ - The CRUD list screen, form lookups and list-filter lookups no longer pass `search: { mode: "query" }`: a list's search runs on the server only, so they leave the mode out, as the guide says to. They search on the server as before.
6
+ - **Breaking.** `useList`'s search runs on the server only: `search: { mode: "local" }`, which filtered the page the list had loaded in the browser and so missed every row past it, throws naming the server search, and so does `search.fields`, which only that mode read: the resource's `searchSchema.q` names the fields a search reads. Upgrading: drop the mode and give the resource `searchSchema.q`, which the list's search sends as `q`.
7
+ - `CrudListFilterControls` applies a typed record id or number-range bound when the person pauses (400 ms), presses Enter or leaves the field, instead of on every key, so typing `1500` asks for one list rather than four; clearing a field applies at once.
8
+ - A list filter's lookup (`useCrudListFilterLookups`) no longer shows one 20-row page as if it were the complete list: while more rows remain its options keep the server's order and it exposes `hasMore`, `isLoadingMore` and `loadMore()`; the options are sorted by label only once every row is loaded. A selected value past the loaded page is read by id, every such value in one request, so its chip shows its label instead of its raw id. A lookup's options load once something reads them or searches, not with every list page. `createCrudLookupFieldRuntime` takes `requestQueryParams` per field key (an object, a ref or a function of the request context), so a form lookup narrows its options on the server by another field, for example a room by the building the form names, and follows it.
9
+ - `SelectField` imports `VSelect` and `VAutocomplete` from their own paths, `vuetify/components/VSelect` and `vuetify/components/VAutocomplete`, instead of the `vuetify/components` barrel, so a test that mocks Vuetify's per-component paths renders it too. The crud-screen-set pattern names the lint rule `jskit/selection-field` (`@jskit-ai/config-eslint`), which reports a raw `v-select`, `v-autocomplete` or `v-combobox` whose items are not fixed and a `SelectField` over loaded items without `loading`.
5
10
  - `jskit.metadata.ui.removedProps` lists `CrudViewScreen`'s `resourcePluralTitle`, removed in this release, so `jskit check` fails an app that still passes it (`ui/removed-prop`) instead of Vue passing it on as an attribute.
6
11
  - `CrudAddEditScreen`'s field rows are 16px apart, below each field's supporting-text line, which fields keep now that `@jskit-ai/material-web` no longer sets `hideDetails: "auto"`: a server's field error appears in that line instead of pushing the rest of the form down. Two text fields are 38px apart (16px plus the line), where they were 24px; a field without the line (`hide-details`, a switch or checkbox, a section heading) has 16px below it. Columns side by side stay 24px apart. Upgrading: a form that set its own margins between fields drops them.
7
12
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/http-web",
3
- "version": "0.2.26",
3
+ "version": "0.2.28",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "test": "jskit test"
@@ -47,13 +47,13 @@
47
47
  "./locales/en.json": "./locales/en.json"
48
48
  },
49
49
  "dependencies": {
50
- "@jskit-ai/resource-crud-core": "0.1.208"
50
+ "@jskit-ai/resource-crud-core": "0.1.210"
51
51
  },
52
52
  "peerDependencies": {
53
- "@jskit-ai/http-runtime": "0.2.17",
54
- "@jskit-ai/kernel": "0.2.17",
55
- "@jskit-ai/realtime": "0.2.24",
56
- "@jskit-ai/shell-web": "0.2.21",
53
+ "@jskit-ai/http-runtime": "0.2.18",
54
+ "@jskit-ai/kernel": "0.2.18",
55
+ "@jskit-ai/realtime": "0.2.26",
56
+ "@jskit-ai/shell-web": "0.2.23",
57
57
  "@tanstack/vue-query": "^5.90.5",
58
58
  "vue": "^3.5.13",
59
59
  "vue-router": "^5.0.4",
@@ -134,6 +134,15 @@ A form field whose `relation` is a `lookup` takes its options from
134
134
  lookup label for a selected value missing from the current options, that option
135
135
  is listed first; a selected value without a label is not listed.
136
136
 
137
+ A lookup whose options depend on another field of the form (the rooms of the
138
+ chosen building, only bookable ones) narrows them on the server: pass
139
+ `requestQueryParams` keyed by the field, `createCrudLookupFieldRuntime({
140
+ formFields, requestQueryParams: { roomId: () => ({ buildingId:
141
+ formState.buildingId, bookable: true }) } })`. The function runs again when what
142
+ it reads changes, so the options follow the building. Each value is a filter the lookup's list accepts
143
+ (its `searchSchema` and list filter validator), never a page of every row
144
+ narrowed in the browser.
145
+
137
146
  Render selection fields whose options load from the server, or whose value is a
138
147
  record id, with `SelectField` from
139
148
  `@jskit-ai/http-web/client/components/SelectField`, not a raw `v-select`,
@@ -143,7 +152,9 @@ arrive. `SelectField` hides an unresolved value while `loading` is true, shows
143
152
  "Unavailable option" once the options settle, and remembers titles it has seen
144
153
  so a narrowing search does not blank a chosen value. Display never changes the
145
154
  stored value. `searchable` renders an autocomplete; other props and slots pass
146
- through to Vuetify.
155
+ through to Vuetify. The lint rule `jskit/selection-field` reports a raw
156
+ selection whose items are not fixed, and a `SelectField` over loaded items
157
+ without `loading`.
147
158
 
148
159
  ```vue
149
160
  <CrudAddEditScreen :screen="screen" v-bind="lookups">
@@ -1,6 +1,7 @@
1
1
  <script setup>
2
- import { computed } from "vue";
2
+ import { computed, onBeforeUnmount } from "vue";
3
3
  import CrudListDateFilterControl from "./CrudListDateFilterControl.vue";
4
+ import { createFilterTyping } from "../composables/support/filterTypingSupport.js";
4
5
  import { useJskitText } from "../i18n.js";
5
6
 
6
7
  const props = defineProps({
@@ -21,6 +22,24 @@ const props = defineProps({
21
22
  const { t, text } = useJskitText();
22
23
  const runtimeValues = computed(() => props.runtime.values);
23
24
 
25
+ // An id or a number range's bound reaches the list when the person pauses, presses Enter or leaves the field: each
26
+ // key would otherwise ask for a list. A key is the filter's, or "filter:min" and "filter:max" for a range's bounds.
27
+ const typing = createFilterTyping({
28
+ read(key) {
29
+ const [filterKey, bound] = key.split(":");
30
+ return bound ? runtimeValues.value[filterKey]?.[bound] : runtimeValues.value[filterKey];
31
+ },
32
+ write(key, value) {
33
+ const [filterKey, bound] = key.split(":");
34
+ if (bound) {
35
+ runtimeValues.value[filterKey][bound] = value;
36
+ } else {
37
+ runtimeValues.value[filterKey] = value;
38
+ }
39
+ }
40
+ });
41
+ onBeforeUnmount(typing.applyAll);
42
+
24
43
  // Option labels may be message keys, such as the presence filter's.
25
44
  function optionItems(filter = {}) {
26
45
  return Array.isArray(filter.options)
@@ -53,6 +72,7 @@ function placeholder(filter = {}, fallbackKey = "") {
53
72
  hide-details
54
73
  class="crud-list-filter-surface__control"
55
74
  />
75
+ <!-- readable-check: allow selection-field - data: an enum or presence filter lists its options in its definition, so nothing loads -->
56
76
  <v-select
57
77
  v-else-if="filter.type === 'enum' || filter.type === 'enumMany' || filter.type === 'presence'"
58
78
  v-model="runtimeValues[filter.key]"
@@ -82,12 +102,15 @@ function placeholder(filter = {}, fallbackKey = "") {
82
102
  />
83
103
  <v-text-field
84
104
  v-else-if="filter.type === 'recordId'"
85
- v-model="runtimeValues[filter.key]"
105
+ :model-value="typing.value(filter.key)"
86
106
  :label="filterLabel(filter)"
87
107
  :placeholder="placeholder(filter, 'jskit.http.crud.filters.enterId')"
88
108
  clearable
89
109
  hide-details="auto"
90
110
  class="crud-list-filter-surface__control"
111
+ @update:model-value="typing.type(filter.key, $event)"
112
+ @blur="typing.apply(filter.key)"
113
+ @keydown.enter="typing.apply(filter.key)"
91
114
  />
92
115
  <div
93
116
  v-else-if="filter.type === 'dateRange'"
@@ -112,16 +135,15 @@ function placeholder(filter = {}, fallbackKey = "") {
112
135
  </div>
113
136
  <div v-else-if="filter.type === 'numberRange'" class="crud-list-filter-surface__range">
114
137
  <v-text-field
115
- v-model="runtimeValues[filter.key].min"
116
- :label="filterLabel(filter, 'jskit.http.crud.filters.rangeMin')"
117
- type="number"
118
- hide-details="auto"
119
- />
120
- <v-text-field
121
- v-model="runtimeValues[filter.key].max"
122
- :label="filterLabel(filter, 'jskit.http.crud.filters.rangeMax')"
138
+ v-for="bound in ['min', 'max']"
139
+ :key="bound"
140
+ :model-value="typing.value(`${filter.key}:${bound}`)"
141
+ :label="filterLabel(filter, bound === 'min' ? 'jskit.http.crud.filters.rangeMin' : 'jskit.http.crud.filters.rangeMax')"
123
142
  type="number"
124
143
  hide-details="auto"
144
+ @update:model-value="typing.type(`${filter.key}:${bound}`, $event)"
145
+ @blur="typing.apply(`${filter.key}:${bound}`)"
146
+ @keydown.enter="typing.apply(`${filter.key}:${bound}`)"
125
147
  />
126
148
  </div>
127
149
  <CrudListDateFilterControl
@@ -1,6 +1,7 @@
1
1
  <script setup>
2
2
  import { computed, ref } from "vue";
3
- import { VAutocomplete, VSelect } from "vuetify/components";
3
+ import { VAutocomplete } from "vuetify/components/VAutocomplete";
4
+ import { VSelect } from "vuetify/components/VSelect";
4
5
  import { optionTitle, optionValue, selectionFieldState } from "../support/selectFieldSupport.js";
5
6
 
6
7
  // A v-select / v-autocomplete that never shows a stored id as text (see selectFieldSupport.js).
@@ -10,6 +10,7 @@ import { useList } from "../records/useList.js";
10
10
  import { resolveLookupItemLabel } from "./crudLookupFieldLabelSupport.js";
11
11
  import { inferCrudLookupJsonApiTransport } from "./crudJsonApiTransportSupport.js";
12
12
  import { asPlainObject } from "../support/scopeHelpers.js";
13
+ import { normalizeLookupRequestQueryParamsMap } from "../internal/crudListFilterLookupSupport.js";
13
14
  import { useJskitText } from "../../i18n.js";
14
15
 
15
16
  const { t } = useJskitText();
@@ -59,14 +60,23 @@ function createSelectedLookupItem(selectedValue, selectedRecord = {}, entry = {}
59
60
  };
60
61
  }
61
62
 
63
+ /**
64
+ * The options of a form's lookup fields, one server-searched page each. `requestQueryParams` narrows a field's options
65
+ * on the server by its key: `{ roomId: () => ({ buildingId: formState.buildingId, bookable: true }) }` lists only the
66
+ * chosen building's bookable rooms, and follows the building as it changes. Each entry is an object (its values may be refs), a ref, or
67
+ * a function of `{ surfaceId, scopeParamValue, ownershipFilter }`, as useList's requestQueryParams.
68
+ * @param {object} [options]
69
+ */
62
70
  function createCrudLookupFieldRuntime({
63
71
  formFields = [],
64
72
  recordIdParam = "recordId",
65
73
  queryKeyPrefix = [],
66
74
  placementSourcePrefix = "",
67
- lookupContainerKey = "lookups"
75
+ lookupContainerKey = "lookups",
76
+ requestQueryParams = {}
68
77
  } = {}) {
69
78
  const runtimes = new Map();
79
+ const normalizedRequestQueryParams = normalizeLookupRequestQueryParamsMap(requestQueryParams);
70
80
  const normalizedRecordIdParam = normalizeText(recordIdParam) || "recordId";
71
81
  const normalizedPlacementSourcePrefix = normalizeText(placementSourcePrefix);
72
82
  const normalizedQueryKeyPrefix = normalizeQueryKeyPrefix(queryKeyPrefix);
@@ -117,9 +127,11 @@ function createCrudLookupFieldRuntime({
117
127
  ],
118
128
  search: {
119
129
  enabled: true,
120
- mode: "query",
121
130
  queryParam: "q"
122
131
  },
132
+ ...(Object.hasOwn(normalizedRequestQueryParams, key)
133
+ ? { requestQueryParams: normalizedRequestQueryParams[key] }
134
+ : {}),
123
135
  placementSource: normalizedPlacementSourcePrefix
124
136
  ? `${normalizedPlacementSourcePrefix}.${key}`
125
137
  : `lookup.${key}`,
@@ -109,29 +109,40 @@ function createLookupOptionsFromItems(items = [], filter = {}, labelResolver = n
109
109
  return Object.freeze([...optionMap.values()]);
110
110
  }
111
111
 
112
- function mergeSelectedLookupOptions(options = [], selectedValues = [], cachedOptions = new Map()) {
113
- const optionMap = new Map(
114
- (Array.isArray(options) ? options : []).map((option) => [normalizeText(option?.value), option])
115
- );
112
+ // The options a lookup shows: selected values its loaded rows lack (from the cache or their own read) first, then the
113
+ // loaded rows. A complete list (no page left to load) is sorted by label; a partial one keeps the server's order, so
114
+ // its first page never looks like a complete A to Z list.
115
+ function mergeSelectedLookupOptions(options = [], selectedValues = [], cachedOptions = new Map(), { complete = true } = {}) {
116
+ const loaded = Array.isArray(options) ? options : [];
117
+ const loadedValues = new Set(loaded.map((option) => normalizeText(option?.value)));
116
118
  const normalizedCache = cachedOptions instanceof Map ? cachedOptions : new Map();
119
+ const selected = [];
117
120
 
118
121
  for (const value of Array.isArray(selectedValues) ? selectedValues : []) {
119
122
  const normalizedValue = normalizeText(value);
120
- if (!normalizedValue || optionMap.has(normalizedValue)) {
123
+ if (!normalizedValue || loadedValues.has(normalizedValue) || selected.some((option) => option.value === normalizedValue)) {
121
124
  continue;
122
125
  }
123
126
 
124
127
  const cachedOption = normalizedCache.get(normalizedValue);
125
128
  if (cachedOption) {
126
- optionMap.set(normalizedValue, cachedOption);
129
+ selected.push(cachedOption);
127
130
  }
128
131
  }
129
132
 
130
- return Object.freeze(
131
- [...optionMap.values()].sort((left, right) => {
132
- return String(left?.label || "").localeCompare(String(right?.label || ""));
133
- })
134
- );
133
+ const merged = [...selected, ...loaded];
134
+ return Object.freeze(complete
135
+ ? merged.sort((left, right) => String(left?.label || "").localeCompare(String(right?.label || "")))
136
+ : merged);
137
+ }
138
+
139
+ // The selected values neither the loaded rows nor the cache can label: the lookup reads these by id.
140
+ function resolveUnlabeledLookupValues(selectedValues = [], options = [], cachedOptions = new Map()) {
141
+ const loadedValues = new Set((Array.isArray(options) ? options : []).map((option) => normalizeText(option?.value)));
142
+ const normalizedCache = cachedOptions instanceof Map ? cachedOptions : new Map();
143
+ return Object.freeze((Array.isArray(selectedValues) ? selectedValues : [])
144
+ .map((value) => normalizeText(value))
145
+ .filter((value) => value && !loadedValues.has(value) && !normalizedCache.has(value)));
135
146
  }
136
147
 
137
148
  function resolveLookupOptionLabel(options = [], cachedOptions = new Map(), value = "", fallback = "") {
@@ -163,5 +174,6 @@ export {
163
174
  resolveLookupSelectedValues,
164
175
  createLookupOptionsFromItems,
165
176
  mergeSelectedLookupOptions,
177
+ resolveUnlabeledLookupValues,
166
178
  resolveLookupOptionLabel
167
179
  };
@@ -16,8 +16,7 @@ import {
16
16
  createRequestQueryRuntime
17
17
  } from "../support/requestQueryRuntimeSupport.js";
18
18
  import {
19
- normalizeListSearchConfig,
20
- matchesLocalSearch
19
+ normalizeListSearchConfig
21
20
  } from "../support/listSearchSupport.js";
22
21
  import {
23
22
  normalizeListSyncToRouteConfig,
@@ -187,7 +186,7 @@ function useList({
187
186
  }
188
187
  return normalized;
189
188
  });
190
- const querySearchEnabled = computed(() => searchConfig.enabled === true && searchConfig.mode === "query");
189
+ const querySearchEnabled = computed(() => searchConfig.enabled === true);
191
190
  const listPath = computed(() => {
192
191
  return normalizeText(operationScope.apiPath.value);
193
192
  });
@@ -426,19 +425,7 @@ function useList({
426
425
  list.trimToFirstPage();
427
426
  }
428
427
  );
429
- const filteredItems = computed(() => {
430
- const sourceItems = Array.isArray(list.items.value) ? list.items.value : [];
431
- if (searchConfig.enabled !== true || searchConfig.mode !== "local") {
432
- return sourceItems;
433
- }
434
-
435
- const queryValue = activeSearchQuery.value;
436
- if (!queryValue) {
437
- return sourceItems;
438
- }
439
-
440
- return sourceItems.filter((item) => matchesLocalSearch(item, queryValue, searchConfig.fields));
441
- });
428
+ const listItems = computed(() => (Array.isArray(list.items.value) ? list.items.value : []));
442
429
 
443
430
  const isInitialLoading = operationScope.isLoading(list.isInitialLoading);
444
431
  const isFetching = operationScope.isLoading(list.isFetching);
@@ -446,7 +433,7 @@ function useList({
446
433
  const loadError = operationScope.loadError(list.loadError);
447
434
  const isLoading = operationScope.isLoading(list.isLoading);
448
435
  const listUiRuntime = createListUiRuntime({
449
- items: filteredItems,
436
+ items: listItems,
450
437
  isInitialLoading,
451
438
  recordIdParam,
452
439
  recordIdSelector,
@@ -479,7 +466,7 @@ function useList({
479
466
  hasMore: list.hasMore,
480
467
  loadError,
481
468
  pages: list.pages,
482
- items: filteredItems,
469
+ items: listItems,
483
470
  reload: list.reload,
484
471
  loadMore: list.loadMore,
485
472
  hasViewUrl: listUiRuntime.hasViewUrl,
@@ -0,0 +1,55 @@
1
+ import { shallowReactive } from "vue";
2
+
3
+ // A typed filter value (a record id, a number range's bound) reaches the list once the person pauses, presses Enter or
4
+ // leaves the field, not with every key: typing "1500" asks for one list, not four. Clearing applies at once.
5
+ const FILTER_TYPING_DELAY_MS = 400;
6
+
7
+ /**
8
+ * Typing over a filter value that `read(key)` answers and `write(key, value)` sets. The field shows `value(key)`, the
9
+ * typed text while it waits, and sends each change to `type(key, value)`; `apply(key)` sends it on Enter or blur.
10
+ * @param {{ read: (key: string) => unknown, write: (key: string, value: unknown) => void, delayMs?: number }} options
11
+ */
12
+ function createFilterTyping({ read, write, delayMs = FILTER_TYPING_DELAY_MS }) {
13
+ const drafts = shallowReactive(new Map());
14
+ const timers = new Map();
15
+
16
+ function value(key) {
17
+ return drafts.has(key) ? drafts.get(key) : read(key);
18
+ }
19
+
20
+ function apply(key) {
21
+ clearTimeout(timers.get(key));
22
+ timers.delete(key);
23
+ if (!drafts.has(key)) {
24
+ return;
25
+ }
26
+ const typed = drafts.get(key);
27
+ drafts.delete(key);
28
+ write(key, typed);
29
+ }
30
+
31
+ function type(key, typed) {
32
+ drafts.set(key, typed);
33
+ clearTimeout(timers.get(key));
34
+ if (typed === null || typed === undefined || typed === "") {
35
+ apply(key);
36
+ return;
37
+ }
38
+ timers.set(key, setTimeout(() => apply(key), delayMs));
39
+ }
40
+
41
+ function applyAll() {
42
+ for (const key of [...drafts.keys()]) {
43
+ apply(key);
44
+ }
45
+ }
46
+
47
+ return Object.freeze({
48
+ value,
49
+ type,
50
+ apply,
51
+ applyAll
52
+ });
53
+ }
54
+
55
+ export { FILTER_TYPING_DELAY_MS, createFilterTyping };
@@ -457,6 +457,7 @@ function resolveRouteSyncManagedKeys({
457
457
 
458
458
  export {
459
459
  normalizeListSyncToRouteConfig,
460
+ resolveQueryParamsInput,
460
461
  resolveQueryParamDescriptors,
461
462
  resolveActiveQueryParamEntries,
462
463
  resolveWritableQueryParamBindings,
@@ -1,7 +1,6 @@
1
1
  import {
2
2
  normalizeInteger,
3
- normalizeText,
4
- normalizeUniqueTextList
3
+ normalizeText
5
4
  } from "@jskit-ai/kernel/shared/support/normalize";
6
5
  import { asPlainObject } from "./scopeHelpers.js";
7
6
  import { useJskitText } from "../../i18n.js";
@@ -10,15 +9,24 @@ const { t, text } = useJskitText();
10
9
 
11
10
  const DEFAULT_LIST_SEARCH_DEBOUNCE_MS = 250;
12
11
  const DEFAULT_LIST_SEARCH_MIN_LENGTH = 1;
13
- const LIST_SEARCH_MODE_LOCAL = "local";
14
12
  const LIST_SEARCH_MODE_QUERY = "query";
15
13
 
14
+ // A list holds the page it loaded, so a search runs on the server: it sends the typed text as `queryParam` (q), and the
15
+ // resource's searchSchema.q searches every row. No mode searches the loaded page in the browser.
16
16
  function normalizeListSearchConfig(value = {}) {
17
17
  const source = asPlainObject(value);
18
- const modeRaw = normalizeText(source.mode).toLowerCase();
19
- const mode = modeRaw === LIST_SEARCH_MODE_LOCAL
20
- ? LIST_SEARCH_MODE_LOCAL
21
- : LIST_SEARCH_MODE_QUERY;
18
+ const mode = normalizeText(source.mode).toLowerCase() || LIST_SEARCH_MODE_QUERY;
19
+ if (mode !== LIST_SEARCH_MODE_QUERY) {
20
+ throw new TypeError(
21
+ `List search runs on the server and takes no mode "${mode}": drop the mode, and give the resource searchSchema.q, ` +
22
+ "which the list's search sends as q. A search of the loaded page misses every row past it."
23
+ );
24
+ }
25
+ if (Object.hasOwn(source, "fields")) {
26
+ throw new TypeError(
27
+ "List search takes no fields: the resource's searchSchema.q names the fields a search reads, on the server."
28
+ );
29
+ }
22
30
 
23
31
  return Object.freeze({
24
32
  enabled: source.enabled === true,
@@ -34,40 +42,10 @@ function normalizeListSearchConfig(value = {}) {
34
42
  minLength: normalizeInteger(source.minLength, {
35
43
  fallback: DEFAULT_LIST_SEARCH_MIN_LENGTH,
36
44
  min: DEFAULT_LIST_SEARCH_MIN_LENGTH
37
- }),
38
- fields: Object.freeze(normalizeUniqueTextList(source.fields))
45
+ })
39
46
  });
40
47
  }
41
48
 
42
- function normalizeSearchableValue(value) {
43
- if (value == null) {
44
- return "";
45
- }
46
- if (typeof value === "string") {
47
- return normalizeText(value).toLowerCase();
48
- }
49
- if (typeof value === "number" || typeof value === "boolean") {
50
- return String(value).toLowerCase();
51
- }
52
- return "";
53
- }
54
-
55
- function matchesLocalSearch(item = {}, query = "", searchFields = []) {
56
- const source = asPlainObject(item);
57
- const normalizedQuery = normalizeText(query).toLowerCase();
58
- if (!normalizedQuery) {
59
- return true;
60
- }
61
-
62
- const fields = Array.isArray(searchFields) ? searchFields : [];
63
- if (fields.length > 0) {
64
- return fields.some((field) => normalizeSearchableValue(source[field]).includes(normalizedQuery));
65
- }
66
-
67
- return Object.values(source).some((value) => normalizeSearchableValue(value).includes(normalizedQuery));
68
- }
69
-
70
49
  export {
71
- normalizeListSearchConfig,
72
- matchesLocalSearch
50
+ normalizeListSearchConfig
73
51
  };
@@ -13,9 +13,11 @@ import {
13
13
  resolveLookupSelectedValues,
14
14
  createLookupOptionsFromItems,
15
15
  mergeSelectedLookupOptions,
16
+ resolveUnlabeledLookupValues,
16
17
  resolveLookupOptionLabel
17
18
  } from "./internal/crudListFilterLookupSupport.js";
18
19
  import { inferCrudLookupJsonApiTransport } from "./crud/crudJsonApiTransportSupport.js";
20
+ import { resolveQueryParamsInput } from "./support/listQueryParamSupport.js";
19
21
  import { useJskitText } from "../i18n.js";
20
22
 
21
23
  const { t, text } = useJskitText();
@@ -56,23 +58,34 @@ function useCrudListFilterLookups(
56
58
  const transport = inferCrudLookupJsonApiTransport({
57
59
  apiPath: filter.lookup.apiSuffix
58
60
  });
61
+ const requestQueryParams = Object.hasOwn(normalizedRequestQueryParams, filter.key)
62
+ ? normalizedRequestQueryParams[filter.key]
63
+ : null;
64
+ const queryKeyFactory = (part) => (surfaceId = "", scopeParamValue = "") => [
65
+ ...normalizedQueryKeyPrefix,
66
+ filter.key,
67
+ ...(part ? [part] : []),
68
+ String(surfaceId || ""),
69
+ String(scopeParamValue || "")
70
+ ];
71
+ // The options load once something shows them (the open filter sheet's control, or a search), not with every list
72
+ // page: the control sits in a closed sheet until the person opens it.
73
+ const optionsWanted = ref(false);
74
+ const wantOptions = () => {
75
+ if (!optionsWanted.value) {
76
+ optionsWanted.value = true;
77
+ }
78
+ };
59
79
 
60
80
  const runtime = useList({
61
81
  apiSuffix: filter.lookup.apiSuffix,
62
82
  ...(transport ? { transport } : {}),
63
- queryKeyFactory: (surfaceId = "", scopeParamValue = "") => [
64
- ...normalizedQueryKeyPrefix,
65
- filter.key,
66
- String(surfaceId || ""),
67
- String(scopeParamValue || "")
68
- ],
83
+ readEnabled: optionsWanted,
84
+ queryKeyFactory: queryKeyFactory(""),
69
85
  search: {
70
- enabled: true,
71
- mode: "query"
86
+ enabled: true
72
87
  },
73
- ...(Object.hasOwn(normalizedRequestQueryParams, filter.key)
74
- ? { requestQueryParams: normalizedRequestQueryParams[filter.key] }
75
- : {}),
88
+ ...(requestQueryParams ? { requestQueryParams } : {}),
76
89
  placementSource: normalizedPlacementSourcePrefix
77
90
  ? `${normalizedPlacementSourcePrefix}.${filter.key}`
78
91
  : `crud.list-filter.lookup.${filter.key}`,
@@ -90,17 +103,50 @@ function useCrudListFilterLookups(
90
103
  filter,
91
104
  normalizedLabelResolvers[filter.key]
92
105
  ));
106
+ // A selected value past the loaded page (from the URL or a bookmark) is read by id, all of them in one request, so
107
+ // its chip and option show its label instead of its raw id.
108
+ const unlabeledValues = computed(() => resolveUnlabeledLookupValues(
109
+ selectedValues.value,
110
+ currentOptions.value,
111
+ cachedOptions.value
112
+ ));
113
+ const selectedRuntime = (filter.lookup.valueKey || "id") === "id"
114
+ ? useList({
115
+ apiSuffix: filter.lookup.apiSuffix,
116
+ ...(transport ? { transport } : {}),
117
+ readEnabled: computed(() => unlabeledValues.value.length > 0),
118
+ queryKeyFactory: queryKeyFactory("__selected__"),
119
+ requestQueryParams: (context) => ({
120
+ ...resolveQueryParamsInput(requestQueryParams, context),
121
+ id: [...unlabeledValues.value]
122
+ }),
123
+ placementSource: normalizedPlacementSourcePrefix
124
+ ? `${normalizedPlacementSourcePrefix}.${filter.key}.selected`
125
+ : `crud.list-filter.lookup.${filter.key}.selected`,
126
+ fallbackLoadError: t("jskit.http.crud.filters.optionsLoadFailed", { path: filter.lookup.apiSuffix }),
127
+ recordIdParam,
128
+ recordIdSelector: (item = {}) => item.id,
129
+ viewUrlTemplate: "",
130
+ editUrlTemplate: ""
131
+ })
132
+ : null;
133
+ const selectedOptions = computed(() => createLookupOptionsFromItems(
134
+ Array.isArray(selectedRuntime?.items) ? selectedRuntime.items : [],
135
+ filter,
136
+ normalizedLabelResolvers[filter.key]
137
+ ));
93
138
  const options = computed(() => {
94
139
  return mergeSelectedLookupOptions(
95
140
  currentOptions.value,
96
141
  selectedValues.value,
97
- cachedOptions.value
142
+ cachedOptions.value,
143
+ { complete: runtime.hasMore !== true }
98
144
  );
99
145
  });
100
146
 
101
- watch(currentOptions, (nextOptions) => {
147
+ watch([currentOptions, selectedOptions], ([nextOptions, nextSelectedOptions]) => {
102
148
  const nextCache = new Map(cachedOptions.value);
103
- for (const option of nextOptions) {
149
+ for (const option of [...nextOptions, ...nextSelectedOptions]) {
104
150
  nextCache.set(option.value, option);
105
151
  }
106
152
  cachedOptions.value = nextCache;
@@ -108,15 +154,26 @@ function useCrudListFilterLookups(
108
154
 
109
155
  lookups[filter.key] = proxyRefs({
110
156
  filter,
111
- options,
157
+ get options() {
158
+ wantOptions();
159
+ return options.value;
160
+ },
112
161
  searchQuery: computed(() => String(runtime.searchQuery || "")),
113
162
  isLoading: computed(() => {
114
163
  return Boolean(runtime.isInitialLoading || runtime.isFetching || runtime.isSearchDebouncing);
115
164
  }),
165
+ // The options are one page; the rest load on request, or narrow with a search.
166
+ hasMore: computed(() => runtime.hasMore === true),
167
+ isLoadingMore: computed(() => runtime.isLoadingMore === true),
168
+ loadMore() {
169
+ wantOptions();
170
+ return runtime.loadMore();
171
+ },
116
172
  resolveLabel(value, fallback = text(filter.label) || t("jskit.http.crud.filters.option")) {
117
173
  return resolveLookupOptionLabel(options.value, cachedOptions.value, value, fallback);
118
174
  },
119
175
  setSearch(value = "") {
176
+ wantOptions();
120
177
  runtime.searchQuery = normalizeText(value);
121
178
  }
122
179
  });
@@ -138,6 +195,15 @@ function useCrudListFilterLookups(
138
195
  resolveLookupSearch(filterKey = "") {
139
196
  return String(resolveLookup(filterKey)?.searchQuery || "");
140
197
  },
198
+ resolveLookupHasMore(filterKey = "") {
199
+ return Boolean(resolveLookup(filterKey)?.hasMore);
200
+ },
201
+ resolveLookupLoadingMore(filterKey = "") {
202
+ return Boolean(resolveLookup(filterKey)?.isLoadingMore);
203
+ },
204
+ loadMoreLookup(filterKey = "") {
205
+ return resolveLookup(filterKey)?.loadMore();
206
+ },
141
207
  setLookupSearch(filterKey = "", value = "") {
142
208
  resolveLookup(filterKey)?.setSearch(value);
143
209
  },
@@ -155,8 +155,7 @@ function useCrudListScreen({
155
155
  String(workspaceSlug || "")
156
156
  ],
157
157
  search: {
158
- enabled: true,
159
- mode: "query"
158
+ enabled: true
160
159
  },
161
160
  queryParams: filterRuntime.queryParams,
162
161
  routeQueryValueResolvers: filterRuntime.routeQueryValueResolvers,
@@ -59,6 +59,15 @@ test("CrudListFilterSurface is one Material 3 chip row over a filter sheet, with
59
59
  assert.doesNotMatch(source, /apiSuffix|server|repository/);
60
60
  });
61
61
 
62
+ test("CrudListFilterControls sends a typed id or range bound through the typing delay, not with every key", async () => {
63
+ const controlsSource = await readFile(path.join(PACKAGE_DIR, "src", "client", "components", "CrudListFilterControls.vue"), "utf8");
64
+
65
+ assert.match(controlsSource, /createFilterTyping/);
66
+ assert.match(controlsSource, /filter\.type === 'recordId'"\s*:model-value="typing\.value\(filter\.key\)"/u);
67
+ assert.match(controlsSource, /:model-value="typing\.value\(`\$\{filter\.key\}:\$\{bound\}`\)"/u);
68
+ assert.doesNotMatch(controlsSource, /v-model="runtimeValues\[filter\.key\]\.(min|max)"/u);
69
+ });
70
+
62
71
  test("CrudListDateFilterControl composes stable Vuetify picker components accessibly", async () => {
63
72
  const componentPath = path.join(
64
73
  PACKAGE_DIR,
@@ -0,0 +1,93 @@
1
+ import assert from "node:assert/strict";
2
+ import test from "node:test";
3
+ import { QueryClient, VueQueryPlugin } from "@tanstack/vue-query";
4
+ import { createRenderer, h, reactive } from "vue";
5
+ import { createMemoryHistory, createRouter } from "vue-router";
6
+ import { configureHttpWebClient } from "../src/client/lib/httpClient.js";
7
+ import { createCrudLookupFieldRuntime } from "../src/client/composables/crud/crudLookupFieldRuntime.js";
8
+
9
+ // Rooms of every building, 20 per page in id order: building 2's rooms are past the first page of all rooms.
10
+ const ROOMS = [
11
+ ...Array.from({ length: 30 }, (_, index) => ({ id: String(index + 1), name: `North ${index + 1}`, buildingId: "1", bookable: true })),
12
+ { id: "31", name: "South 1", buildingId: "2", bookable: true },
13
+ { id: "32", name: "South 2", buildingId: "2", bookable: false }
14
+ ];
15
+
16
+ function roomClient(calls) {
17
+ return {
18
+ async request(path, options = {}) {
19
+ const query = { ...(options.query || {}) };
20
+ calls.push({ path, query });
21
+ const matching = ROOMS.filter((room) =>
22
+ (query.buildingId === undefined || room.buildingId === query.buildingId) &&
23
+ (query.bookable === undefined || room.bookable === (query.bookable === "1"))
24
+ );
25
+ return { items: matching.slice(0, Number(query.limit) || 20), nextCursor: null };
26
+ }
27
+ };
28
+ }
29
+
30
+ async function settle(check) {
31
+ for (let attempt = 0; attempt < 200 && !check(); attempt += 1) {
32
+ await new Promise((resolve) => setTimeout(resolve, 0));
33
+ }
34
+ }
35
+
36
+ test("a form lookup narrows its options on the server by the parent record the form names, and follows it", async (t) => {
37
+ const calls = [];
38
+ configureHttpWebClient(roomClient(calls));
39
+ const router = createRouter({ history: createMemoryHistory(), routes: [{ path: "/bookings/new", component: { render: () => h("div") } }] });
40
+ await router.push("/bookings/new");
41
+ const queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } });
42
+ const node = (type) => ({ type, props: {}, children: [], parent: null });
43
+ const renderer = createRenderer({
44
+ createElement: node,
45
+ createText: () => node("text"),
46
+ createComment: () => node("comment"),
47
+ setText() {},
48
+ setElementText() {},
49
+ patchProp: (item, key, _previous, value) => { item.props[key] = value; },
50
+ parentNode: (item) => item.parent,
51
+ nextSibling: (item) => item.parent?.children[item.parent.children.indexOf(item) + 1] ?? null,
52
+ insert(item, parent) {
53
+ item.parent = parent;
54
+ parent.children.push(item);
55
+ },
56
+ remove(item) {
57
+ if (item.parent) item.parent.children.splice(item.parent.children.indexOf(item), 1);
58
+ }
59
+ });
60
+ const formState = reactive({ buildingId: "2", roomId: "" });
61
+ let lookups;
62
+ const app = renderer.createApp({
63
+ setup() {
64
+ lookups = createCrudLookupFieldRuntime({
65
+ formFields: [{
66
+ key: "roomId",
67
+ relation: { kind: "lookup", apiPath: "/rooms", valueKey: "id", labelKey: "name" }
68
+ }],
69
+ requestQueryParams: {
70
+ roomId: () => ({ buildingId: formState.buildingId, bookable: true })
71
+ }
72
+ });
73
+ return () => h("div");
74
+ }
75
+ });
76
+ app.use(router);
77
+ app.use(VueQueryPlugin, { queryClient });
78
+ app.mount(node("root"));
79
+ t.after(() => {
80
+ app.unmount();
81
+ queryClient.clear();
82
+ configureHttpWebClient({});
83
+ });
84
+
85
+ await settle(() => lookups.resolveLookupItems("roomId").length > 0);
86
+ assert.deepEqual(calls[0].query, { buildingId: "2", bookable: "1", limit: 20 });
87
+ assert.deepEqual(lookups.resolveLookupItems("roomId").map((item) => item.label), ["South 1"]);
88
+
89
+ formState.buildingId = "1";
90
+ await settle(() => lookups.resolveLookupItems("roomId")[0]?.label === "North 1");
91
+ assert.deepEqual(calls.at(-1).query, { buildingId: "1", bookable: "1", limit: 20 });
92
+ assert.equal(lookups.resolveLookupItems("roomId").length, 20);
93
+ });
@@ -0,0 +1,52 @@
1
+ import assert from "node:assert/strict";
2
+ import test from "node:test";
3
+ import { createFilterTyping, FILTER_TYPING_DELAY_MS } from "../src/client/composables/support/filterTypingSupport.js";
4
+
5
+ function typingOver(values) {
6
+ const writes = [];
7
+ const typing = createFilterTyping({
8
+ read: (key) => values[key],
9
+ write(key, value) {
10
+ writes.push([key, value]);
11
+ values[key] = value;
12
+ }
13
+ });
14
+ return { typing, writes };
15
+ }
16
+
17
+ test("a typed filter value reaches the filter once the person pauses, not with every key", (t) => {
18
+ t.mock.timers.enable({ apis: ["setTimeout"] });
19
+ const values = { weight: "" };
20
+ const { typing, writes } = typingOver(values);
21
+
22
+ for (const typed of ["1", "15", "150", "1500"]) {
23
+ typing.type("weight", typed);
24
+ t.mock.timers.tick(FILTER_TYPING_DELAY_MS - 1);
25
+ }
26
+ // The field shows what was typed while the filter still holds its value.
27
+ assert.equal(typing.value("weight"), "1500");
28
+ assert.deepEqual(writes, []);
29
+
30
+ t.mock.timers.tick(1);
31
+ assert.deepEqual(writes, [["weight", "1500"]]);
32
+ assert.equal(typing.value("weight"), "1500");
33
+ });
34
+
35
+ test("Enter or leaving the field applies a typed value at once, and clearing applies at once", (t) => {
36
+ t.mock.timers.enable({ apis: ["setTimeout"] });
37
+ const values = { supplierId: "4" };
38
+ const { typing, writes } = typingOver(values);
39
+
40
+ typing.type("supplierId", "42");
41
+ typing.apply("supplierId");
42
+ assert.deepEqual(writes, [["supplierId", "42"]]);
43
+ t.mock.timers.tick(FILTER_TYPING_DELAY_MS);
44
+ assert.deepEqual(writes, [["supplierId", "42"]]);
45
+
46
+ typing.type("supplierId", null);
47
+ assert.deepEqual(writes, [["supplierId", "42"], ["supplierId", null]]);
48
+
49
+ typing.type("supplierId", "7");
50
+ typing.applyAll();
51
+ assert.deepEqual(writes.at(-1), ["supplierId", "7"]);
52
+ });
@@ -1,5 +1,10 @@
1
1
  import assert from "node:assert/strict";
2
2
  import test from "node:test";
3
+ import { QueryClient, VueQueryPlugin } from "@tanstack/vue-query";
4
+ import { createRenderer, h, reactive } from "vue";
5
+ import { createMemoryHistory, createRouter } from "vue-router";
6
+ import { configureHttpWebClient } from "../src/client/lib/httpClient.js";
7
+ import { useCrudListFilterLookups } from "../src/client/composables/useCrudListFilterLookups.js";
3
8
  import {
4
9
  resolveLookupSelectedValues,
5
10
  createLookupOptionsFromItems,
@@ -112,3 +117,118 @@ test("lookup filter support merges cached selected labels and resolves fallback
112
117
  assert.equal(resolveLookupOptionLabel(mergedOptions, cachedOptions, "12", "Storage"), "North Shed");
113
118
  assert.equal(resolveLookupOptionLabel(mergedOptions, cachedOptions, "55", "Storage"), "Storage 55");
114
119
  });
120
+
121
+ test("a partial page of options keeps the server's order; a complete list is sorted by label", () => {
122
+ const page = [
123
+ { value: "3", label: "Zephyr Farms" },
124
+ { value: "1", label: "Acme Supplies" }
125
+ ];
126
+
127
+ assert.deepEqual(
128
+ mergeSelectedLookupOptions(page, [], new Map(), { complete: false }).map((option) => option.label),
129
+ ["Zephyr Farms", "Acme Supplies"]
130
+ );
131
+ assert.deepEqual(
132
+ mergeSelectedLookupOptions(page, [], new Map()).map((option) => option.label),
133
+ ["Acme Supplies", "Zephyr Farms"]
134
+ );
135
+ // A selected value the page lacks comes first, before the page in its order.
136
+ const cached = new Map([["90", { value: "90", label: "Bright Hives" }]]);
137
+ assert.deepEqual(
138
+ mergeSelectedLookupOptions(page, ["90"], cached, { complete: false }).map((option) => option.value),
139
+ ["90", "3", "1"]
140
+ );
141
+ });
142
+
143
+ // 45 suppliers on the server, 20 per page in id order: the selected supplier 44 is past the first page.
144
+ const SUPPLIERS = Array.from({ length: 45 }, (_, index) => ({ id: String(index + 1), name: `Farm ${String(index + 1).padStart(2, "0")}` }));
145
+
146
+ function supplierClient(calls) {
147
+ return {
148
+ async request(path, options = {}) {
149
+ calls.push({ path, query: { ...(options.query || {}) } });
150
+ const query = options.query || {};
151
+ const ids = query.id === undefined ? null : [query.id].flat().map(String);
152
+ const matching = ids ? SUPPLIERS.filter((supplier) => ids.includes(supplier.id)) : SUPPLIERS;
153
+ const start = query.cursor ? Number(query.cursor) : 0;
154
+ const limit = Number(query.limit) || 20;
155
+ const items = matching.slice(start, start + limit);
156
+ return { items, nextCursor: start + limit < matching.length ? String(start + limit) : null };
157
+ }
158
+ };
159
+ }
160
+
161
+ async function settle(check) {
162
+ for (let attempt = 0; attempt < 200 && !check(); attempt += 1) {
163
+ await new Promise((resolve) => setTimeout(resolve, 0));
164
+ }
165
+ }
166
+
167
+ async function mountSupplierLookup(values) {
168
+ const calls = [];
169
+ configureHttpWebClient(supplierClient(calls));
170
+ const router = createRouter({ history: createMemoryHistory(), routes: [{ path: "/receivals", component: { render: () => h("div") } }] });
171
+ await router.push("/receivals");
172
+ const queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } });
173
+ let filterLookups;
174
+ const node = (type) => ({ type, props: {}, children: [], parent: null });
175
+ const renderer = createRenderer({
176
+ createElement: node,
177
+ createText: () => node("text"),
178
+ createComment: () => node("comment"),
179
+ setText() {},
180
+ setElementText() {},
181
+ patchProp: (item, key, _previous, value) => { item.props[key] = value; },
182
+ parentNode: (item) => item.parent,
183
+ nextSibling: (item) => item.parent?.children[item.parent.children.indexOf(item) + 1] ?? null,
184
+ insert(item, parent) {
185
+ item.parent = parent;
186
+ parent.children.push(item);
187
+ },
188
+ remove(item) {
189
+ if (item.parent) item.parent.children.splice(item.parent.children.indexOf(item), 1);
190
+ }
191
+ });
192
+ const app = renderer.createApp({
193
+ setup() {
194
+ filterLookups = useCrudListFilterLookups({ supplierContactId: supplierFilter }, { values });
195
+ return () => h("div");
196
+ }
197
+ });
198
+ app.use(router);
199
+ app.use(VueQueryPlugin, { queryClient });
200
+ app.mount(node("root"));
201
+ return { app, calls, filterLookups, queryClient };
202
+ }
203
+
204
+ test("a lookup filter reads nothing until its options are shown, and labels a selected value past the first page by id", async (t) => {
205
+ const values = reactive({ supplierContactId: ["44"] });
206
+ const { app, calls, filterLookups, queryClient } = await mountSupplierLookup(values);
207
+ t.after(() => {
208
+ app.unmount();
209
+ queryClient.clear();
210
+ configureHttpWebClient({});
211
+ });
212
+
213
+ await settle(() => filterLookups.resolveLookupLabel("supplierContactId", "44", "Supplier") === "Farm 44");
214
+ // One request, for the selected value alone; the closed sheet's options were not read.
215
+ assert.deepEqual(calls.map((call) => call.query.id ?? null), ["44"]);
216
+ assert.equal(filterLookups.resolveLookupLabel("supplierContactId", "44", "Supplier"), "Farm 44");
217
+
218
+ const lookup = filterLookups.resolveLookup("supplierContactId");
219
+ assert.deepEqual(lookup.options.map((option) => option.label), ["Farm 44"]);
220
+ await settle(() => lookup.options.length > 1);
221
+ // The first page keeps the server's order after the selected value, and says more rows remain.
222
+ assert.deepEqual(lookup.options.slice(0, 3).map((option) => option.label), ["Farm 44", "Farm 01", "Farm 02"]);
223
+ assert.equal(lookup.options.length, 21);
224
+ assert.equal(filterLookups.resolveLookupHasMore("supplierContactId"), true);
225
+
226
+ await filterLookups.loadMoreLookup("supplierContactId");
227
+ await settle(() => lookup.options.length > 21);
228
+ await filterLookups.loadMoreLookup("supplierContactId");
229
+ await settle(() => filterLookups.resolveLookupHasMore("supplierContactId") === false);
230
+ // Every row loaded: the list is complete, so it is sorted by label.
231
+ assert.equal(lookup.options.length, 45);
232
+ assert.equal(lookup.options[0].label, "Farm 01");
233
+ assert.equal(lookup.options[44].label, "Farm 45");
234
+ });
@@ -1,9 +1,6 @@
1
1
  import assert from "node:assert/strict";
2
2
  import test from "node:test";
3
- import {
4
- normalizeListSearchConfig,
5
- matchesLocalSearch
6
- } from "../src/client/composables/support/listSearchSupport.js";
3
+ import { normalizeListSearchConfig } from "../src/client/composables/support/listSearchSupport.js";
7
4
 
8
5
  test("normalizeListSearchConfig defaults to disabled query search", () => {
9
6
  const config = normalizeListSearchConfig();
@@ -14,48 +11,27 @@ test("normalizeListSearchConfig defaults to disabled query search", () => {
14
11
  assert.equal(config.minLength, 1);
15
12
  });
16
13
 
17
- test("normalizeListSearchConfig accepts query mode and fields", () => {
14
+ test("normalizeListSearchConfig accepts query mode and its query parameter", () => {
18
15
  const config = normalizeListSearchConfig({
19
16
  enabled: true,
20
17
  mode: "query",
21
- queryParam: "search",
22
- fields: ["name", "name", "email"]
18
+ queryParam: "search"
23
19
  });
24
20
  assert.equal(config.enabled, true);
25
21
  assert.equal(config.mode, "query");
26
22
  assert.equal(config.queryParam, "search");
27
- assert.deepEqual(config.fields, ["name", "email"]);
28
23
  });
29
24
 
30
- test("normalizeListSearchConfig accepts explicit local mode", () => {
31
- const config = normalizeListSearchConfig({
32
- enabled: true,
33
- mode: "local"
34
- });
35
- assert.equal(config.mode, "local");
36
- });
37
-
38
- test("matchesLocalSearch checks configured fields", () => {
39
- const result = matchesLocalSearch(
40
- {
41
- firstName: "Ana",
42
- surname: "Marin",
43
- phone: "0400"
44
- },
45
- "mar",
46
- ["surname"]
25
+ test("normalizeListSearchConfig refuses a search of the loaded page, naming the server search", () => {
26
+ assert.throws(
27
+ () => normalizeListSearchConfig({ enabled: true, mode: "local" }),
28
+ (error) => error instanceof TypeError && /runs on the server/u.test(error.message) && /searchSchema\.q/u.test(error.message)
47
29
  );
48
- assert.equal(result, true);
49
30
  });
50
31
 
51
- test("matchesLocalSearch scans scalar values when fields are not configured", () => {
52
- const result = matchesLocalSearch(
53
- {
54
- firstName: "Ana",
55
- surname: "Marin",
56
- count: 42
57
- },
58
- "42"
32
+ test("normalizeListSearchConfig refuses fields, which the resource's searchSchema.q names on the server", () => {
33
+ assert.throws(
34
+ () => normalizeListSearchConfig({ enabled: true, fields: ["name"] }),
35
+ (error) => error instanceof TypeError && /takes no fields/u.test(error.message) && /searchSchema\.q/u.test(error.message)
59
36
  );
60
- assert.equal(result, true);
61
37
  });