@uniweb/projections 0.5.1 → 0.5.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniweb/projections",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "description": "Projections of a Uniweb site's content — agent index, per-page markdown, search index. Pure JS, runs anywhere.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -31,8 +31,8 @@
31
31
  "node": ">=20.19"
32
32
  },
33
33
  "dependencies": {
34
- "@uniweb/content-writer": "^0.3.4",
35
- "@uniweb/core": "^0.13.1"
34
+ "@uniweb/core": "^0.15.0",
35
+ "@uniweb/content-writer": "^0.3.4"
36
36
  },
37
37
  "devDependencies": {
38
38
  "vitest": "^4.1.7",
@@ -85,13 +85,13 @@ export function generateSearchIndex(siteContent, options = {}) {
85
85
  * describe *where the index lives* — only whether it serves queries.
86
86
  *
87
87
  * @param {Object} pagesIndex - Result of {@link generateSearchIndex}
88
- * @param {Object[]} [collectionIndexes] - Results of `generateRecordSearchIndex`
88
+ * @param {Object[]} [recordIndexes] - Results of `generateRecordSearchIndex`
89
89
  * @returns {Object} One index carrying every entry
90
90
  */
91
- export function mergeSearchIndexes(pagesIndex, collectionIndexes = []) {
91
+ export function mergeSearchIndexes(pagesIndex, recordIndexes = []) {
92
92
  const entries = [
93
93
  ...(pagesIndex?.entries || []),
94
- ...collectionIndexes.flatMap(index => index?.entries || [])
94
+ ...recordIndexes.flatMap(index => index?.entries || [])
95
95
  ]
96
96
 
97
97
  return {
@@ -29,8 +29,8 @@ function composeRoute(configRoute, slug) {
29
29
 
30
30
  /**
31
31
  * @param {string} name - Collection name (e.g. "articles")
32
- * @param {Object} config - Collection config from site.yml (config.collections[name])
33
- * @param {Object[]|Object} collectionData - Parsed cascade JSON (`data/{name}.json`),
32
+ * @param {Object} config - Query config from the site payload (config.queries[name])
33
+ * @param {Object[]|Object} recordData - Parsed cascade JSON (`data/{name}.json`),
34
34
  * which the build writes as a bare array. The `{ items: [...] }` envelope is
35
35
  * accepted too, since a host fetching the collection from a backend may carry one.
36
36
  * @param {string} locale - Locale code (e.g. "en")
@@ -66,7 +66,7 @@ const DISPLAY_VALUE_MAX = 200
66
66
  /**
67
67
  * Search-index entries for one named group of records.
68
68
  *
69
- * ⛔ RENAMED from `generateCollectionIndex` — 2026-08-27, and the old name was
69
+ * ⛔ RENAMED from `generateRecordIndex` — 2026-08-27, and the old name was
70
70
  * wrong in two ways that mattered.
71
71
  *
72
72
  * 1. **"Collection" is FRAMEWORK'S build concept** — a named set our build
@@ -86,7 +86,7 @@ const DISPLAY_VALUE_MAX = 200
86
86
  * being discussed cost one coordinated change; leaving it would have made the
87
87
  * entry the last place `collection` survived as a lane-crossing word.
88
88
  */
89
- export function generateRecordSearchIndex(name, config, collectionData, locale) {
89
+ export function generateRecordSearchIndex(name, config, recordData, locale) {
90
90
  // ⛔ NO DEFAULT FIELD LIST. This was `|| ['title']` — a claim about someone
91
91
  // else's schema, and wrong for any collection without a `title` (a `people`
92
92
  // collection has `name`, a `products` one has `label`). The failure was
@@ -99,9 +99,9 @@ export function generateRecordSearchIndex(name, config, collectionData, locale)
99
99
  // has told us something we could not otherwise know.
100
100
  const declaredFields = Array.isArray(config.search?.fields) ? config.search.fields : null
101
101
  const weight = config.search?.weight ?? 0.7
102
- const items = Array.isArray(collectionData)
103
- ? collectionData
104
- : collectionData?.items || []
102
+ const items = Array.isArray(recordData)
103
+ ? recordData
104
+ : recordData?.items || []
105
105
 
106
106
  const entries = items.map(item => {
107
107
  const fields = declaredFields ?? searchableKeys(item)