@dcupl/common 2.0.0-beta.5 → 2.0.0-beta.7

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.
@@ -1,3 +1,26 @@
1
1
  import { ListItem, DcuplFilterOptions, InverseIndexReferenceMap, DcuplGlobalQueryOptions, DcuplFacet } from './types/index.js';
2
2
  import { QueryManager } from './queryData.js';
3
+ /**
4
+ * Build facet entries for `attribute`.
5
+ *
6
+ * Pipeline order — IMPORTANT, do not shuffle:
7
+ *
8
+ * Fast path (options.sort omitted, default):
9
+ * 1. walk validFacetKeys in insertion order
10
+ * 2. for each key: compute entry (binary size if calculateFacets is false)
11
+ * 3. skip if excludeZeros && size === 0 (does NOT advance count)
12
+ * 4. early-return when filterItemEntries.length === count
13
+ * 5. push and continue
14
+ *
15
+ * Sort path (options.sort set):
16
+ * 1. walk ALL validFacetKeys (ignore count for early-return)
17
+ * 2. for each key: compute entry with FULL size (override calculateFacets: false)
18
+ * 3. push every entry
19
+ * 4. drop zeros if excludeZeros
20
+ * 5. sort by chosen mode (size sorts tie-break on value asc, undefined last)
21
+ * 6. truncate to count
22
+ *
23
+ * The sort path is opt-in because it forfeits both early-return optimizations.
24
+ * Most call sites only need a partial answer and stay on the fast path.
25
+ */
3
26
  export declare function getFacets<ListType extends ListItem = ListItem>(modelData: Map<string, ListType>, remoteModelData: Map<string, ListType>, options: DcuplFilterOptions, query: DcuplGlobalQueryOptions<any>, attribute: string, modelIndexMap: InverseIndexReferenceMap, queryManager: QueryManager): DcuplFacet[];