@wix/himalaya-cli 0.1693.0 → 0.1694.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/dist/cli.mjs +1 -1
- package/package.json +2 -2
- package/templates/beauty-salon/l10n/en.json +3 -5
- package/templates/branded-lite/dev/index.ts +955 -13
- package/templates/branded-lite/l10n/en.json +49 -9
- package/templates/branded-lite/l10n/he.json +40 -0
- package/templates/branded-lite/tier5-src/_shared/himi-cms.ts +2 -1
- package/templates/branded-lite/tier5-src/himi-branded-lite-cms-collection/index.ts +175 -12
- package/templates/community-club/dev/index.ts +471 -0
- package/templates/community-club/l10n/en.json +49 -9
- package/templates/community-club/l10n/he.json +40 -0
- package/templates/community-club/tier5-src/_shared/himi-cms.ts +2 -1
- package/templates/community-club/tier5-src/himi-branded-lite-cms-collection/index.ts +175 -12
- package/templates/events-meetups/l10n/en.json +5 -9
- package/templates/gym-fitness/l10n/en.json +4 -7
- package/templates/nonprofit-cause/l10n/en.json +5 -9
- package/templates/podcast-creator/l10n/en.json +5 -9
- package/templates/portfolio-creative/l10n/en.json +5 -9
- package/templates/restaurant/l10n/en.json +5 -9
- package/templates/retail-store/l10n/en.json +3 -5
- package/templates/yoga-studio/l10n/en.json +5 -9
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
queryDataItems as queryWixDataItems,
|
|
3
3
|
countDataItems,
|
|
4
|
+
queryDistinctValues,
|
|
4
5
|
insertDataItem,
|
|
5
6
|
updateDataItem,
|
|
6
7
|
removeDataItem,
|
|
@@ -10,7 +11,7 @@ import {
|
|
|
10
11
|
} from "@himalaya/wix-data";
|
|
11
12
|
|
|
12
13
|
export type { WixDataItem, WixQueryDataItemsResponse };
|
|
13
|
-
export { countDataItems, insertDataItem, updateDataItem, removeDataItem };
|
|
14
|
+
export { countDataItems, queryDistinctValues, insertDataItem, updateDataItem, removeDataItem };
|
|
14
15
|
|
|
15
16
|
export interface CmsFieldDefinition {
|
|
16
17
|
key: string;
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
collectionArg,
|
|
4
4
|
collectionDefinitions,
|
|
5
5
|
countDataItems,
|
|
6
|
+
queryDistinctValues,
|
|
6
7
|
queryDataItems,
|
|
7
8
|
type CmsCollectionDefinition,
|
|
8
9
|
type CmsFieldDefinition,
|
|
@@ -101,6 +102,40 @@ const PAGE_SIZE = 20;
|
|
|
101
102
|
const META_FIELD_MAX_CHARS = 24;
|
|
102
103
|
/** The newest-first default: Wix's own created date, present on every collection. */
|
|
103
104
|
const DEFAULT_SORT = [{ fieldName: "_createdDate", order: "DESC" as const }];
|
|
105
|
+
const SORT_IDS = ["newest", "oldest", "az", "za"] as const;
|
|
106
|
+
type SortId = typeof SORT_IDS[number];
|
|
107
|
+
interface Criteria { query: string; sort: string; category: string; categoryField: string }
|
|
108
|
+
let categoryCatalog: { collectionId: string; field: string; name: string; values: string[]; done: boolean; retryable?: boolean } | undefined;
|
|
109
|
+
let discoveryGeneration = 0;
|
|
110
|
+
|
|
111
|
+
function criteria(state: Criteria): Criteria { return { query: state.query, sort: state.sort, category: state.category, categoryField: state.categoryField }; }
|
|
112
|
+
function criteriaKey(state: Criteria): string { return JSON.stringify([state.query.trim(), state.sort, state.category, state.categoryField]); }
|
|
113
|
+
function defaultView(state: Criteria): boolean { return !state.query.trim() && !state.category && state.sort === "newest"; }
|
|
114
|
+
// Wix contains accepts string/reference values, not dates, numbers or objects.
|
|
115
|
+
// These CMS field types store scalar strings; media values are their URLs/ids.
|
|
116
|
+
const SEARCHABLE_DISPLAY_TYPES = new Set(["TEXT", "RICH_TEXT", "URL", "EMAIL", "IMAGE", "DOCUMENT", "VIDEO", "AUDIO", "TIME", "REFERENCE", "PAGE_LINK"]);
|
|
117
|
+
function supportsSearch(collection: CmsCollectionDefinition): boolean {
|
|
118
|
+
return collection.fields.some(field => field.key === collection.displayField && SEARCHABLE_DISPLAY_TYPES.has(field.type));
|
|
119
|
+
}
|
|
120
|
+
function queryFilter(state: Criteria, collection: CmsCollectionDefinition): Record<string, unknown> | undefined {
|
|
121
|
+
const filter: Record<string, unknown> = {};
|
|
122
|
+
if (state.query.trim() && supportsSearch(collection)) filter[collection.displayField] = { $contains: state.query.trim() };
|
|
123
|
+
if (state.category && state.categoryField) filter[state.categoryField] = state.category;
|
|
124
|
+
return Object.keys(filter).length ? filter : undefined;
|
|
125
|
+
}
|
|
126
|
+
function querySort(state: Criteria, collection: CmsCollectionDefinition) {
|
|
127
|
+
return state.sort === "oldest" ? [{ fieldName: "_createdDate", order: "ASC" as const }]
|
|
128
|
+
: state.sort === "az" || state.sort === "za" ? [{ fieldName: collection.displayField, order: state.sort === "az" ? "ASC" as const : "DESC" as const }]
|
|
129
|
+
: DEFAULT_SORT;
|
|
130
|
+
}
|
|
131
|
+
function sortLabel(id: string): string {
|
|
132
|
+
const labels: Record<string, [string, string]> = {
|
|
133
|
+
newest: ["cmsCollection.sortNewest", "Newest first"], oldest: ["cmsCollection.sortOldest", "Oldest first"],
|
|
134
|
+
az: ["cmsCollection.sortAz", "A to Z"], za: ["cmsCollection.sortZa", "Z to A"],
|
|
135
|
+
};
|
|
136
|
+
const [key, fallback] = labels[id] ?? labels.newest;
|
|
137
|
+
return copyParam(key, fallback);
|
|
138
|
+
}
|
|
104
139
|
|
|
105
140
|
interface ItemRow {
|
|
106
141
|
id: string;
|
|
@@ -160,13 +195,36 @@ interface Facts {
|
|
|
160
195
|
refreshFailed: boolean;
|
|
161
196
|
refreshing: boolean;
|
|
162
197
|
errorKind: ErrorKind;
|
|
163
|
-
//
|
|
198
|
+
// Server query criteria. A new view never inherits another view’s rows or caption.
|
|
199
|
+
searchable: boolean;
|
|
164
200
|
query: string;
|
|
165
201
|
sort: string;
|
|
166
202
|
category: string;
|
|
203
|
+
categoryField: string;
|
|
204
|
+
sortOpen: boolean;
|
|
205
|
+
categoryOpen: boolean;
|
|
167
206
|
}
|
|
168
207
|
|
|
169
208
|
interface State extends Facts {
|
|
209
|
+
hideSearch: boolean;
|
|
210
|
+
sortLabel: string;
|
|
211
|
+
sortSelected: boolean;
|
|
212
|
+
noSortSelected: boolean;
|
|
213
|
+
noCategorySelected: boolean;
|
|
214
|
+
hideSortSheet: boolean;
|
|
215
|
+
hideCategorySheet: boolean;
|
|
216
|
+
sortOptions: Array<{ id: string; label: string; notSelected: boolean }>;
|
|
217
|
+
sortChips: Array<{ id: string; label: string }>;
|
|
218
|
+
categoryChips: Array<{ id: string; label: string }>;
|
|
219
|
+
categoryLabel: string;
|
|
220
|
+
categoryName: string;
|
|
221
|
+
categorySelected: boolean;
|
|
222
|
+
categoryOptions: Array<{ id: string; value: string; label: string; notSelected: boolean }>;
|
|
223
|
+
hideCategory: boolean;
|
|
224
|
+
hideCategorySkeleton: boolean;
|
|
225
|
+
noMatchTitle: string;
|
|
226
|
+
showNoMatch: boolean;
|
|
227
|
+
hideNoMatch: boolean;
|
|
170
228
|
/** Shared collection projection; its preferences have their own scoped store. */
|
|
171
229
|
collection?: unknown;
|
|
172
230
|
noCount: boolean;
|
|
@@ -200,10 +258,13 @@ function derive(f: Facts): State {
|
|
|
200
258
|
const countText = typeof f.countTotal === "number" ? countLine(f.countTotal) : f.countText;
|
|
201
259
|
const hasRows = f.rows.length > 0;
|
|
202
260
|
const failed = f.status === "error";
|
|
261
|
+
const narrowed = !!(f.query.trim() || f.category);
|
|
262
|
+
const catalog = categoryCatalog?.collectionId === f.collectionId ? categoryCatalog : undefined;
|
|
203
263
|
const show = {
|
|
204
264
|
showLoading: f.status === "loading",
|
|
205
265
|
showRows: f.status === "ready" && hasRows,
|
|
206
|
-
showEmpty: f.status === "ready" && !hasRows,
|
|
266
|
+
showEmpty: f.status === "ready" && !hasRows && !narrowed,
|
|
267
|
+
showNoMatch: f.status === "ready" && !hasRows && narrowed,
|
|
207
268
|
showRetryableError: failed && (f.errorKind === "offline" || f.errorKind === "server"),
|
|
208
269
|
showSignInError: failed && f.errorKind === "signIn",
|
|
209
270
|
showPermissionError: failed && f.errorKind === "permission",
|
|
@@ -212,11 +273,29 @@ function derive(f: Facts): State {
|
|
|
212
273
|
};
|
|
213
274
|
return {
|
|
214
275
|
...f,
|
|
276
|
+
hideSearch: !f.searchable,
|
|
277
|
+
sortLabel: f.sort === "newest" ? copyParam("cmsCollection.sortChip", "Sort") : sortLabel(f.sort),
|
|
278
|
+
sortSelected: f.sort !== "newest",
|
|
279
|
+
noSortSelected: f.sort === "newest",
|
|
280
|
+
noCategorySelected: !f.category,
|
|
281
|
+
hideSortSheet: !f.sortOpen,
|
|
282
|
+
hideCategorySheet: !f.categoryOpen,
|
|
283
|
+
sortOptions: SORT_IDS.map(id => ({ id, label: sortLabel(id), notSelected: id !== f.sort })),
|
|
284
|
+
sortChips: [{ id: "sort", label: sortLabel(f.sort) }],
|
|
285
|
+
categoryChips: [{ id: "category", label: f.category || catalog?.name || copyParam("cmsCollection.categoryChip", "Category") }],
|
|
286
|
+
categoryName: catalog?.name || copyParam("cmsCollection.categoryChip", "Category"),
|
|
287
|
+
categoryLabel: f.category || catalog?.name || copyParam("cmsCollection.categoryChip", "Category"),
|
|
288
|
+
categorySelected: !!f.category,
|
|
289
|
+
categoryOptions: [{ id: "category-all", value: "", label: copyParam("cmsCollection.allCategories", "All"), notSelected: !!f.category }, ...(catalog?.values ?? []).map(value => ({ id: `category:${value}`, value, label: value, notSelected: value !== f.category }))],
|
|
290
|
+
hideCategory: !catalog?.field,
|
|
291
|
+
hideCategorySkeleton: !f.collectionId || failed || !!catalog?.done,
|
|
292
|
+
noMatchTitle: f.query.trim() ? copyTemplate("cmsCollection.noMatchQuery", "No results for “{query}”", { query: f.query.trim() }) : copyParam("cmsCollection.noMatchTitle", "No matching items"),
|
|
215
293
|
countText,
|
|
216
294
|
...show,
|
|
217
295
|
hideLoading: !show.showLoading,
|
|
218
296
|
hideRows: !show.showRows,
|
|
219
297
|
hideEmpty: !show.showEmpty,
|
|
298
|
+
hideNoMatch: !show.showNoMatch,
|
|
220
299
|
hideRetryableError: !show.showRetryableError,
|
|
221
300
|
hideSignInError: !show.showSignInError,
|
|
222
301
|
hidePermissionError: !show.showPermissionError,
|
|
@@ -249,9 +328,13 @@ function facts(collection: CmsCollectionDefinition | undefined, over: Partial<Fa
|
|
|
249
328
|
refreshFailed: false,
|
|
250
329
|
refreshing: false,
|
|
251
330
|
errorKind: "",
|
|
331
|
+
searchable: collection ? supportsSearch(collection) : false,
|
|
252
332
|
query: "",
|
|
253
333
|
sort: "newest",
|
|
254
334
|
category: "",
|
|
335
|
+
categoryField: "",
|
|
336
|
+
sortOpen: false,
|
|
337
|
+
categoryOpen: false,
|
|
255
338
|
...over,
|
|
256
339
|
};
|
|
257
340
|
}
|
|
@@ -451,17 +534,72 @@ function countLine(total: number): string {
|
|
|
451
534
|
}
|
|
452
535
|
|
|
453
536
|
let current: CmsCollectionDefinition | undefined;
|
|
454
|
-
let firstPageFlight: { collectionId: string; promise: Promise<State> } | undefined;
|
|
537
|
+
let firstPageFlight: { collectionId: string; criteriaKey: string; promise: Promise<State> } | undefined;
|
|
455
538
|
const WARM_FRESH_MS = 30_000;
|
|
456
539
|
let loadingMoreFlight: { cursor: string; generation: number } | undefined;
|
|
457
540
|
let firstPageGeneration = 0;
|
|
458
541
|
/** The latest state, so a read in flight can repaint (the load-more spinner) before its action returns. */
|
|
459
542
|
let published: State | undefined;
|
|
460
543
|
|
|
544
|
+
/** Nine values suffice to reject a high-cardinality field. Never infer categories
|
|
545
|
+
* from page one, nor accept a truncated response as the entire distinct set. */
|
|
546
|
+
function discoverCategories(collection: CmsCollectionDefinition, retry = false): void {
|
|
547
|
+
if (categoryCatalog?.collectionId === collection.id && !(retry && categoryCatalog.done && categoryCatalog.retryable)) return;
|
|
548
|
+
const revision = ++discoveryGeneration;
|
|
549
|
+
categoryCatalog = { collectionId: collection.id, field: "", name: "", values: [], done: false };
|
|
550
|
+
void (async () => {
|
|
551
|
+
const fields = collection.fields.filter(field => field.key !== collection.displayField && field.type === "TEXT" && !field.key.startsWith("_"));
|
|
552
|
+
let match = { field: "", name: "", values: [] as string[] };
|
|
553
|
+
let failed = false;
|
|
554
|
+
for (const field of fields) {
|
|
555
|
+
if (revision !== discoveryGeneration) return;
|
|
556
|
+
try {
|
|
557
|
+
const response = await queryDistinctValues(collection.id, field.key, { paging: { limit: 9 } });
|
|
558
|
+
if (revision !== discoveryGeneration) return;
|
|
559
|
+
const raw = response.distinctValues ?? [];
|
|
560
|
+
const values = [...new Set(raw.filter((value): value is string => typeof value === "string" && !!value.trim()))];
|
|
561
|
+
if (response.pagingMetadata?.hasNext || response.pagingMetadata?.cursors?.next || raw.length >= 9 || raw.some(value => typeof value !== "string" && value != null)) continue;
|
|
562
|
+
if (values.length >= 2 && values.length <= 8) { match = { field: field.key, name: field.displayName, values }; break; }
|
|
563
|
+
} catch { failed = true; /* Optional discovery must never fail the collection read. */ }
|
|
564
|
+
}
|
|
565
|
+
if (revision !== discoveryGeneration) return;
|
|
566
|
+
categoryCatalog = { collectionId: collection.id, ...match, done: true, retryable: failed && !match.field };
|
|
567
|
+
if (published?.collectionId === collection.id) {
|
|
568
|
+
published = derive(published);
|
|
569
|
+
void svc.publish();
|
|
570
|
+
}
|
|
571
|
+
})();
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
/** Criteria changes retire rows, cursors and captions synchronously, before any
|
|
575
|
+
* storage read can revive an unrelated view. Presentation-only actions
|
|
576
|
+
* keep the latest projection rather than an action's queued snapshot. */
|
|
577
|
+
function changeCriteria(state: State, update: Partial<Criteria>): State | Promise<State> {
|
|
578
|
+
if (!current || state.collectionId !== current.id) return published ?? state;
|
|
579
|
+
const active = published ?? state;
|
|
580
|
+
const next = { ...criteria(active), ...update };
|
|
581
|
+
if (!active.searchable) next.query = "";
|
|
582
|
+
if (criteriaKey(next) === criteriaKey(active)) {
|
|
583
|
+
published = derive({ ...active, ...next, sortOpen: false, categoryOpen: false });
|
|
584
|
+
// Native fields flush onChange before onSubmit. Joining the same read lets
|
|
585
|
+
// the newer decorator action commit its result; returning a loading snapshot
|
|
586
|
+
// would supersede the original reducer and strand the host on its skeleton.
|
|
587
|
+
return firstPageFlight?.collectionId === current.id && firstPageFlight.criteriaKey === criteriaKey(next)
|
|
588
|
+
? firstPageFlight.promise : published;
|
|
589
|
+
}
|
|
590
|
+
++firstPageGeneration;
|
|
591
|
+
firstPageFlight = undefined;
|
|
592
|
+
published = derive(facts(current, { ...next, cacheAccessFence: active.cacheAccessFence }));
|
|
593
|
+
void svc.publish();
|
|
594
|
+
return loadFirstPage(published, { collection: JSON.stringify(current), force: "1" });
|
|
595
|
+
}
|
|
596
|
+
|
|
461
597
|
async function denyAccess(collection: CmsCollectionDefinition, errorKind: ErrorKind): Promise<State> {
|
|
462
598
|
// Access denial supersedes both in-memory rows and their offline snapshot.
|
|
463
599
|
// Retire pending pages/counts before awaiting native storage acknowledgements.
|
|
464
600
|
++firstPageGeneration;
|
|
601
|
+
++discoveryGeneration;
|
|
602
|
+
categoryCatalog = undefined;
|
|
465
603
|
const fence = `${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
466
604
|
// Dispatch the durable fence before publishing denial, independently of an old
|
|
467
605
|
// snapshot acknowledgement. Other workers never trust a snapshot with an older fence.
|
|
@@ -470,7 +608,7 @@ async function denyAccess(collection: CmsCollectionDefinition, errorKind: ErrorK
|
|
|
470
608
|
// acknowledgement: that older callback must not erase a newer authorized worker.
|
|
471
609
|
const cleared = upsert(ENTITY, { id: pageCacheKey(collection.id), cachePageKind: "cms-first-page", cachePageVersion: 1, cacheAccessFence: fence, rowsJson: "[]" }).catch(() => {});
|
|
472
610
|
cacheWriteTail = Promise.all([cacheWriteTail, fenced, cleared]).then(() => {});
|
|
473
|
-
const denied = derive(facts(collection, { status: "error", errorKind, countPending: false, cacheAccessFence: fence }));
|
|
611
|
+
const denied = derive(facts(collection, { ...(published ? criteria(published) : {}), status: "error", errorKind, countPending: false, cacheAccessFence: fence }));
|
|
474
612
|
published = denied;
|
|
475
613
|
void svc.publish();
|
|
476
614
|
await cacheWriteTail;
|
|
@@ -483,7 +621,8 @@ const boot = resolveCollection(undefined);
|
|
|
483
621
|
function loadFirstPage(state: State, arg?: unknown): Promise<State> {
|
|
484
622
|
stashCopy(arg);
|
|
485
623
|
const collection = resolveCollection(arg);
|
|
486
|
-
|
|
624
|
+
const active = published && published.collectionId === collection?.id ? published : state;
|
|
625
|
+
if (argValue(arg, "force") !== "1" && collection && firstPageFlight?.collectionId === collection.id && firstPageFlight.criteriaKey === criteriaKey(active)) {
|
|
487
626
|
if (published?.collectionId === collection.id) {
|
|
488
627
|
published = localizeState(published);
|
|
489
628
|
void svc.publish();
|
|
@@ -491,7 +630,7 @@ function loadFirstPage(state: State, arg?: unknown): Promise<State> {
|
|
|
491
630
|
return firstPageFlight.promise;
|
|
492
631
|
}
|
|
493
632
|
const promise = readFirstPage(state, arg).then(localizeState);
|
|
494
|
-
const flight = { collectionId: collection?.id ?? "", promise };
|
|
633
|
+
const flight = { collectionId: collection?.id ?? "", criteriaKey: criteriaKey(active), promise };
|
|
495
634
|
firstPageFlight = flight;
|
|
496
635
|
void promise.finally(() => { if (firstPageFlight === flight) firstPageFlight = undefined; });
|
|
497
636
|
return promise;
|
|
@@ -511,6 +650,7 @@ async function readFirstPage(state: State, arg?: unknown): Promise<State> {
|
|
|
511
650
|
// A cold-restored ready state skips the first read but still needs its paging definition.
|
|
512
651
|
current = collection;
|
|
513
652
|
const force = argValue(arg, "force") === "1";
|
|
653
|
+
discoverCategories(collection, force);
|
|
514
654
|
const fresh = !force && state.collectionId === collection.id && state.status === "ready" && Date.now() - state.lastSuccessAt < WARM_FRESH_MS;
|
|
515
655
|
// A forced/stale refresh retires old pages before the asynchronous fence read.
|
|
516
656
|
const refreshGeneration = fresh ? undefined : ++firstPageGeneration;
|
|
@@ -532,15 +672,17 @@ async function readFirstPage(state: State, arg?: unknown): Promise<State> {
|
|
|
532
672
|
// A different collection owns a different cursor and row actions. Retire the
|
|
533
673
|
// previous presentation before even the asynchronous local-cache read.
|
|
534
674
|
if (state.collectionId !== collection.id || revoked) {
|
|
535
|
-
published = derive(facts(collection));
|
|
675
|
+
state = published = derive(facts(collection, state.collectionId === collection.id ? criteria(state) : {}));
|
|
536
676
|
void svc.publish();
|
|
537
677
|
}
|
|
538
678
|
const keptRows = state.collectionId === collection.id && state.status === "ready" ? state.rows : [];
|
|
539
679
|
// Last-synced items for THIS collection (offline-safe; empty on first-ever run).
|
|
540
|
-
const cache = keptRows.length ? { rows: [], accessFence: state.cacheAccessFence ?? "" }
|
|
680
|
+
const cache = keptRows.length ? { rows: [], accessFence: state.cacheAccessFence ?? "" }
|
|
681
|
+
: defaultView(state) ? await readCached(collection.id, collection)
|
|
682
|
+
: { rows: [], accessFence: (await readAccessFence(collection.id)) ?? null };
|
|
541
683
|
const cached = cache.rows;
|
|
542
684
|
if (generation !== firstPageGeneration) return published ?? state;
|
|
543
|
-
const base = facts(collection, { cacheAccessFence: cache.accessFence ?? "" });
|
|
685
|
+
const base = facts(collection, { ...criteria(state), cacheAccessFence: cache.accessFence ?? "" });
|
|
544
686
|
// A cold cache is usable while a slow request is still pending; warm rows stay exactly as shown.
|
|
545
687
|
const retained = keptRows.length ? derive({ ...state, refreshing: true, loadingMore: false }) : cached.length ? derive({ ...base, status: "ready", rows: cached, refreshing: true }) : undefined;
|
|
546
688
|
if (retained) {
|
|
@@ -551,7 +693,8 @@ async function readFirstPage(state: State, arg?: unknown): Promise<State> {
|
|
|
551
693
|
let countPending = true;
|
|
552
694
|
let countTotal: number | null = null;
|
|
553
695
|
let rowsPublished = !!retained;
|
|
554
|
-
|
|
696
|
+
const filter = queryFilter(base, collection);
|
|
697
|
+
void countDataItems(collection.id, filter)
|
|
555
698
|
.then((result) => (typeof result.totalCount === "number" && Number.isFinite(result.totalCount) && result.totalCount >= 0 ? result.totalCount : null))
|
|
556
699
|
.catch(() => null)
|
|
557
700
|
.then((total) => {
|
|
@@ -570,11 +713,11 @@ async function readFirstPage(state: State, arg?: unknown): Promise<State> {
|
|
|
570
713
|
}
|
|
571
714
|
});
|
|
572
715
|
try {
|
|
573
|
-
const response = await queryDataItems(collection.id, PAGE_SIZE, { sort:
|
|
716
|
+
const response = await queryDataItems(collection.id, PAGE_SIZE, { filter, sort: querySort(base, collection) });
|
|
574
717
|
if (generation !== firstPageGeneration) return published ?? state;
|
|
575
718
|
const items = response.dataItems ?? response.items ?? [];
|
|
576
719
|
let rows = items.map((item, index) => itemRow(item, collection, index));
|
|
577
|
-
await writeCached(collection.id, rows, generation, cache.accessFence);
|
|
720
|
+
if (defaultView(base)) await writeCached(collection.id, rows, generation, cache.accessFence);
|
|
578
721
|
if (generation !== firstPageGeneration) return published ?? state;
|
|
579
722
|
// Read interaction state after storage too: a tap may happen while a local write awaits.
|
|
580
723
|
const previous = published?.collectionId === collection.id ? published : state.collectionId === collection.id ? state : undefined;
|
|
@@ -611,6 +754,13 @@ const svc = defineService<State, {
|
|
|
611
754
|
loadMore: (state: State, arg?: unknown) => Promise<State>;
|
|
612
755
|
toggleRow: (state: State, arg?: unknown) => State;
|
|
613
756
|
publish: (state: State) => State;
|
|
757
|
+
search: (state: State, arg?: unknown) => State | Promise<State>;
|
|
758
|
+
setSort: (state: State, arg?: unknown) => State | Promise<State>;
|
|
759
|
+
setCategory: (state: State, arg?: unknown) => State | Promise<State>;
|
|
760
|
+
clearFilters: (state: State) => State | Promise<State>;
|
|
761
|
+
openSort: (state: State) => State;
|
|
762
|
+
openCategory: (state: State) => State;
|
|
763
|
+
closePanels: (state: State) => State;
|
|
614
764
|
/** [rico] #3372 — a row RichContent's on_link: `{ url }` of the tapped link. */
|
|
615
765
|
openLink: (state: State, arg?: unknown) => Promise<State>;
|
|
616
766
|
}>("himiBrandedCmsCollection", {
|
|
@@ -619,6 +769,19 @@ const svc = defineService<State, {
|
|
|
619
769
|
notPersisted: cacheOwnedKeys,
|
|
620
770
|
actions: {
|
|
621
771
|
load: loadFirstPage,
|
|
772
|
+
search: (state, arg) => changeCriteria(state, { query: argValue(arg, "value").slice(0, 256) }),
|
|
773
|
+
setSort: (state, arg) => {
|
|
774
|
+
const sort = argValue(arg, "id");
|
|
775
|
+
return SORT_IDS.includes(sort as SortId) ? changeCriteria(state, { sort }) : published ?? state;
|
|
776
|
+
},
|
|
777
|
+
setCategory: (state, arg) => {
|
|
778
|
+
const category = argValue(arg, "id");
|
|
779
|
+
return !category || categoryCatalog?.values.includes(category) ? changeCriteria(state, { category, categoryField: category ? categoryCatalog?.field ?? "" : "" }) : published ?? state;
|
|
780
|
+
},
|
|
781
|
+
clearFilters: (state) => changeCriteria(state, { query: "", category: "", categoryField: "" }),
|
|
782
|
+
openSort: (state) => published = derive({ ...(published ?? state), sortOpen: true, categoryOpen: false }),
|
|
783
|
+
openCategory: (state) => published = derive({ ...(published ?? state), sortOpen: false, categoryOpen: !((published ?? state).hideCategory) }),
|
|
784
|
+
closePanels: (state) => published = derive({ ...(published ?? state), sortOpen: false, categoryOpen: false }),
|
|
622
785
|
// The error node's, the banner's and the sign-in return's "Try again": the same first load, forced.
|
|
623
786
|
retry: (state, arg) => loadFirstPage(state, { ...(typeof arg === "object" && arg ? arg as Record<string, unknown> : {}), force: "1" }),
|
|
624
787
|
loadMore: async (state) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$source": "en",
|
|
3
|
-
"$generated": "2026-11-
|
|
3
|
+
"$generated": "2026-11-12T18:53:33.063Z",
|
|
4
4
|
"messages": {
|
|
5
5
|
"h_01e1787a9e5b": {
|
|
6
6
|
"source": "App language",
|
|
@@ -487,8 +487,7 @@
|
|
|
487
487
|
"source": "Clear search",
|
|
488
488
|
"kind": "Button.title",
|
|
489
489
|
"translation": "",
|
|
490
|
-
"key": "collections.clearCta"
|
|
491
|
-
"keyOrigin": "string-table"
|
|
490
|
+
"key": "collections.clearCta"
|
|
492
491
|
},
|
|
493
492
|
"h_69af16a1ea5b": {
|
|
494
493
|
"source": "Loading group...",
|
|
@@ -501,8 +500,7 @@
|
|
|
501
500
|
"source": "All",
|
|
502
501
|
"kind": "atom.label",
|
|
503
502
|
"translation": "",
|
|
504
|
-
"key": "collection.all"
|
|
505
|
-
"keyOrigin": "string-table"
|
|
503
|
+
"key": "collection.all"
|
|
506
504
|
},
|
|
507
505
|
"h_6b21fb791ac0": {
|
|
508
506
|
"source": "About",
|
|
@@ -761,8 +759,7 @@
|
|
|
761
759
|
"source": "No matching items",
|
|
762
760
|
"kind": "Text.text",
|
|
763
761
|
"translation": "",
|
|
764
|
-
"key": "collection.empty"
|
|
765
|
-
"keyOrigin": "string-table"
|
|
762
|
+
"key": "collection.empty"
|
|
766
763
|
},
|
|
767
764
|
"h_a14a8c9cb59d": {
|
|
768
765
|
"source": "Groups are temporarily unavailable.",
|
|
@@ -850,8 +847,7 @@
|
|
|
850
847
|
"source": "Sort",
|
|
851
848
|
"kind": "Text.text",
|
|
852
849
|
"translation": "",
|
|
853
|
-
"key": "collection.sortShown"
|
|
854
|
-
"keyOrigin": "string-table"
|
|
850
|
+
"key": "collection.sortShown"
|
|
855
851
|
},
|
|
856
852
|
"h_ae1ef0143294": {
|
|
857
853
|
"source": "Dark",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$source": "en",
|
|
3
|
-
"$generated": "2026-11-
|
|
3
|
+
"$generated": "2026-11-12T18:53:33.063Z",
|
|
4
4
|
"messages": {
|
|
5
5
|
"h_0028d743eb44": {
|
|
6
6
|
"source": "Sale",
|
|
@@ -881,8 +881,7 @@
|
|
|
881
881
|
"source": "Clear search",
|
|
882
882
|
"kind": "Button.title",
|
|
883
883
|
"translation": "",
|
|
884
|
-
"key": "collections.clearCta"
|
|
885
|
-
"keyOrigin": "string-table"
|
|
884
|
+
"key": "collections.clearCta"
|
|
886
885
|
},
|
|
887
886
|
"h_694e6062a668": {
|
|
888
887
|
"source": "Shipping",
|
|
@@ -902,8 +901,7 @@
|
|
|
902
901
|
"source": "All",
|
|
903
902
|
"kind": "atom.label",
|
|
904
903
|
"translation": "",
|
|
905
|
-
"key": "collection.all"
|
|
906
|
-
"keyOrigin": "string-table"
|
|
904
|
+
"key": "collection.all"
|
|
907
905
|
},
|
|
908
906
|
"h_6b21fb791ac0": {
|
|
909
907
|
"source": "About",
|
|
@@ -1427,8 +1425,7 @@
|
|
|
1427
1425
|
"source": "No matching items",
|
|
1428
1426
|
"kind": "Text.text",
|
|
1429
1427
|
"translation": "",
|
|
1430
|
-
"key": "collection.empty"
|
|
1431
|
-
"keyOrigin": "string-table"
|
|
1428
|
+
"key": "collection.empty"
|
|
1432
1429
|
},
|
|
1433
1430
|
"h_a1ba61405311": {
|
|
1434
1431
|
"source": "SUBSCRIPTION DETAILS",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$source": "en",
|
|
3
|
-
"$generated": "2026-11-
|
|
3
|
+
"$generated": "2026-11-12T18:53:33.063Z",
|
|
4
4
|
"messages": {
|
|
5
5
|
"h_01e1787a9e5b": {
|
|
6
6
|
"source": "App language",
|
|
@@ -606,8 +606,7 @@
|
|
|
606
606
|
"source": "Clear search",
|
|
607
607
|
"kind": "Button.title",
|
|
608
608
|
"translation": "",
|
|
609
|
-
"key": "collections.clearCta"
|
|
610
|
-
"keyOrigin": "string-table"
|
|
609
|
+
"key": "collections.clearCta"
|
|
611
610
|
},
|
|
612
611
|
"h_69af16a1ea5b": {
|
|
613
612
|
"source": "Loading group...",
|
|
@@ -627,8 +626,7 @@
|
|
|
627
626
|
"source": "All",
|
|
628
627
|
"kind": "atom.label",
|
|
629
628
|
"translation": "",
|
|
630
|
-
"key": "collection.all"
|
|
631
|
-
"keyOrigin": "string-table"
|
|
629
|
+
"key": "collection.all"
|
|
632
630
|
},
|
|
633
631
|
"h_6b21fb791ac0": {
|
|
634
632
|
"source": "About",
|
|
@@ -957,8 +955,7 @@
|
|
|
957
955
|
"source": "No matching items",
|
|
958
956
|
"kind": "Text.text",
|
|
959
957
|
"translation": "",
|
|
960
|
-
"key": "collection.empty"
|
|
961
|
-
"keyOrigin": "string-table"
|
|
958
|
+
"key": "collection.empty"
|
|
962
959
|
},
|
|
963
960
|
"h_a14a8c9cb59d": {
|
|
964
961
|
"source": "Groups are temporarily unavailable.",
|
|
@@ -1072,8 +1069,7 @@
|
|
|
1072
1069
|
"source": "Sort",
|
|
1073
1070
|
"kind": "Text.text",
|
|
1074
1071
|
"translation": "",
|
|
1075
|
-
"key": "collection.sortShown"
|
|
1076
|
-
"keyOrigin": "string-table"
|
|
1072
|
+
"key": "collection.sortShown"
|
|
1077
1073
|
},
|
|
1078
1074
|
"h_ae1ef0143294": {
|
|
1079
1075
|
"source": "Dark",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$source": "en",
|
|
3
|
-
"$generated": "2026-11-
|
|
3
|
+
"$generated": "2026-11-12T18:53:33.063Z",
|
|
4
4
|
"messages": {
|
|
5
5
|
"h_01e1787a9e5b": {
|
|
6
6
|
"source": "App language",
|
|
@@ -600,8 +600,7 @@
|
|
|
600
600
|
"source": "Clear search",
|
|
601
601
|
"kind": "Button.title",
|
|
602
602
|
"translation": "",
|
|
603
|
-
"key": "collections.clearCta"
|
|
604
|
-
"keyOrigin": "string-table"
|
|
603
|
+
"key": "collections.clearCta"
|
|
605
604
|
},
|
|
606
605
|
"h_69b498ddb194": {
|
|
607
606
|
"source": "Add to queue",
|
|
@@ -621,8 +620,7 @@
|
|
|
621
620
|
"source": "All",
|
|
622
621
|
"kind": "atom.label",
|
|
623
622
|
"translation": "",
|
|
624
|
-
"key": "collection.all"
|
|
625
|
-
"keyOrigin": "string-table"
|
|
623
|
+
"key": "collection.all"
|
|
626
624
|
},
|
|
627
625
|
"h_6b21fb791ac0": {
|
|
628
626
|
"source": "About",
|
|
@@ -957,8 +955,7 @@
|
|
|
957
955
|
"source": "No matching items",
|
|
958
956
|
"kind": "Text.text",
|
|
959
957
|
"translation": "",
|
|
960
|
-
"key": "collection.empty"
|
|
961
|
-
"keyOrigin": "string-table"
|
|
958
|
+
"key": "collection.empty"
|
|
962
959
|
},
|
|
963
960
|
"h_a1ba61405311": {
|
|
964
961
|
"source": "SUBSCRIPTION DETAILS",
|
|
@@ -1058,8 +1055,7 @@
|
|
|
1058
1055
|
"source": "Sort",
|
|
1059
1056
|
"kind": "Text.text",
|
|
1060
1057
|
"translation": "",
|
|
1061
|
-
"key": "collection.sortShown"
|
|
1062
|
-
"keyOrigin": "string-table"
|
|
1058
|
+
"key": "collection.sortShown"
|
|
1063
1059
|
},
|
|
1064
1060
|
"h_ae1ef0143294": {
|
|
1065
1061
|
"source": "Dark",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$source": "en",
|
|
3
|
-
"$generated": "2026-11-
|
|
3
|
+
"$generated": "2026-11-12T18:53:33.063Z",
|
|
4
4
|
"messages": {
|
|
5
5
|
"h_0028d743eb44": {
|
|
6
6
|
"source": "Sale",
|
|
@@ -721,8 +721,7 @@
|
|
|
721
721
|
"source": "Clear search",
|
|
722
722
|
"kind": "Button.title",
|
|
723
723
|
"translation": "",
|
|
724
|
-
"key": "collections.clearCta"
|
|
725
|
-
"keyOrigin": "string-table"
|
|
724
|
+
"key": "collections.clearCta"
|
|
726
725
|
},
|
|
727
726
|
"h_694e6062a668": {
|
|
728
727
|
"source": "Shipping",
|
|
@@ -735,8 +734,7 @@
|
|
|
735
734
|
"source": "All",
|
|
736
735
|
"kind": "atom.label",
|
|
737
736
|
"translation": "",
|
|
738
|
-
"key": "collection.all"
|
|
739
|
-
"keyOrigin": "string-table"
|
|
737
|
+
"key": "collection.all"
|
|
740
738
|
},
|
|
741
739
|
"h_6b21fb791ac0": {
|
|
742
740
|
"source": "About",
|
|
@@ -1107,8 +1105,7 @@
|
|
|
1107
1105
|
"source": "No matching items",
|
|
1108
1106
|
"kind": "Text.text",
|
|
1109
1107
|
"translation": "",
|
|
1110
|
-
"key": "collection.empty"
|
|
1111
|
-
"keyOrigin": "string-table"
|
|
1108
|
+
"key": "collection.empty"
|
|
1112
1109
|
},
|
|
1113
1110
|
"h_a1fffaaafb7c": {
|
|
1114
1111
|
"source": "List",
|
|
@@ -1217,8 +1214,7 @@
|
|
|
1217
1214
|
"source": "Sort",
|
|
1218
1215
|
"kind": "Text.text",
|
|
1219
1216
|
"translation": "",
|
|
1220
|
-
"key": "collection.sortShown"
|
|
1221
|
-
"keyOrigin": "string-table"
|
|
1217
|
+
"key": "collection.sortShown"
|
|
1222
1218
|
},
|
|
1223
1219
|
"h_ae1ef0143294": {
|
|
1224
1220
|
"source": "Dark",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$source": "en",
|
|
3
|
-
"$generated": "2026-11-
|
|
3
|
+
"$generated": "2026-11-12T18:53:33.063Z",
|
|
4
4
|
"messages": {
|
|
5
5
|
"h_01e1787a9e5b": {
|
|
6
6
|
"source": "App language",
|
|
@@ -684,8 +684,7 @@
|
|
|
684
684
|
"source": "Clear search",
|
|
685
685
|
"kind": "Button.title",
|
|
686
686
|
"translation": "",
|
|
687
|
-
"key": "collections.clearCta"
|
|
688
|
-
"keyOrigin": "string-table"
|
|
687
|
+
"key": "collections.clearCta"
|
|
689
688
|
},
|
|
690
689
|
"h_678c2fd69f13": {
|
|
691
690
|
"source": "Loading the menu...",
|
|
@@ -698,8 +697,7 @@
|
|
|
698
697
|
"source": "All",
|
|
699
698
|
"kind": "atom.label",
|
|
700
699
|
"translation": "",
|
|
701
|
-
"key": "collection.all"
|
|
702
|
-
"keyOrigin": "string-table"
|
|
700
|
+
"key": "collection.all"
|
|
703
701
|
},
|
|
704
702
|
"h_6b21fb791ac0": {
|
|
705
703
|
"source": "About",
|
|
@@ -1042,8 +1040,7 @@
|
|
|
1042
1040
|
"source": "No matching items",
|
|
1043
1041
|
"kind": "Text.text",
|
|
1044
1042
|
"translation": "",
|
|
1045
|
-
"key": "collection.empty"
|
|
1046
|
-
"keyOrigin": "string-table"
|
|
1043
|
+
"key": "collection.empty"
|
|
1047
1044
|
},
|
|
1048
1045
|
"h_a1fffaaafb7c": {
|
|
1049
1046
|
"source": "List",
|
|
@@ -1138,8 +1135,7 @@
|
|
|
1138
1135
|
"source": "Sort",
|
|
1139
1136
|
"kind": "Text.text",
|
|
1140
1137
|
"translation": "",
|
|
1141
|
-
"key": "collection.sortShown"
|
|
1142
|
-
"keyOrigin": "string-table"
|
|
1138
|
+
"key": "collection.sortShown"
|
|
1143
1139
|
},
|
|
1144
1140
|
"h_ae1ef0143294": {
|
|
1145
1141
|
"source": "Dark",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$source": "en",
|
|
3
|
-
"$generated": "2026-11-
|
|
3
|
+
"$generated": "2026-11-12T18:53:33.063Z",
|
|
4
4
|
"messages": {
|
|
5
5
|
"h_0028d743eb44": {
|
|
6
6
|
"source": "Sale",
|
|
@@ -616,8 +616,7 @@
|
|
|
616
616
|
"source": "Clear search",
|
|
617
617
|
"kind": "Button.title",
|
|
618
618
|
"translation": "",
|
|
619
|
-
"key": "collections.clearCta"
|
|
620
|
-
"keyOrigin": "string-table"
|
|
619
|
+
"key": "collections.clearCta"
|
|
621
620
|
},
|
|
622
621
|
"h_694e6062a668": {
|
|
623
622
|
"source": "Shipping",
|
|
@@ -630,8 +629,7 @@
|
|
|
630
629
|
"source": "All",
|
|
631
630
|
"kind": "atom.label",
|
|
632
631
|
"translation": "",
|
|
633
|
-
"key": "collection.all"
|
|
634
|
-
"keyOrigin": "string-table"
|
|
632
|
+
"key": "collection.all"
|
|
635
633
|
},
|
|
636
634
|
"h_6b21fb791ac0": {
|
|
637
635
|
"source": "About",
|