@uniweb/kit 0.19.5 → 0.19.6

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/kit",
3
- "version": "0.19.5",
3
+ "version": "0.19.6",
4
4
  "description": "Standard component library for Uniweb foundations",
5
5
  "type": "module",
6
6
  "exports": {
@@ -43,8 +43,8 @@
43
43
  "shiki": "^3.0.0",
44
44
  "tailwind-merge": "^3.6.0",
45
45
  "temml": "^0.13.2",
46
- "@uniweb/core": "^0.30.0",
47
- "@uniweb/projections": "^0.7.4",
46
+ "@uniweb/core": "^0.31.0",
47
+ "@uniweb/projections": "^0.7.5",
48
48
  "@uniweb/semantic-parser": "^1.4.1",
49
49
  "@uniweb/scene": "^0.1.3"
50
50
  },
@@ -1,13 +1,13 @@
1
1
  /**
2
2
  * useWholeRecord — the whole of a record whose query delivers less of it.
3
3
  *
4
- * When a query's list carries less than a record — a `deferred: [...]` query, a
5
- * host's records service answering briefs, an external query that declares
6
- * `record:` — the whole record lives at its own address. This hook fetches that
4
+ * A query's list carries briefs — a static site's compiled list, a host's records
5
+ * service — and an external query that declares `record:` has its own request for
6
+ * one. The whole record, as stored, lives at its own address. This hook fetches that
7
7
  * record on demand, from the source the query's declaration picks:
8
8
  *
9
- * - a query over `records/{schema}/` with `deferred:` — the per-record file the
10
- * build emits;
9
+ * - a query over `records/{schema}/` — the per-record file the build emits for
10
+ * every record (only for a query with `deferred:`, since retired, until 2026-09-27);
11
11
  * - a host's records service — the query's question narrowed to the record,
12
12
  * asked `whole`;
13
13
  * - an external query — its `record:` request, `{slug}` substituted.
@@ -41,7 +41,7 @@
41
41
  * }
42
42
  */
43
43
 
44
- import { getUniweb, resolveFetchConfigs, buildDetailConfig, routeParamValue } from '@uniweb/core'
44
+ import { getUniweb, resolveFetchConfigs, buildDetailConfig, routeParamValue, routeFieldOf } from '@uniweb/core'
45
45
  import { useFetched } from './useFetched.js'
46
46
 
47
47
  /**
@@ -63,13 +63,11 @@ export function useWholeRecord(record, options = {}) {
63
63
  const request = buildDetailRequest(record, query, { param: options?.param })
64
64
  const result = useFetched(request)
65
65
 
66
- // No separate detail source for this collection — nothing was stripped from
67
- // the cascade, so the record the caller already holds IS the whole record.
68
- // Returning it beats both alternatives: `null` makes every caller null-check
69
- // a case that cannot fail, and requesting the per-record file anyway is a
70
- // guaranteed 404, because that file is only written for a `deferred:`
71
- // collection. `useFetched` is still called above — unconditionally, as the
72
- // rules of hooks require — and simply skips on a null request.
66
+ // No separate source for one record — an external query with no `record:` — so
67
+ // the record the caller already holds is all there is. Returning it beats `null`,
68
+ // which would make every caller null-check a case that cannot fail. `useFetched`
69
+ // is still called above — unconditionally, as the rules of hooks require — and
70
+ // simply skips on a null request.
73
71
  if (record && query && !request) {
74
72
  return { data: record, error: null, loading: false }
75
73
  }
@@ -82,7 +80,7 @@ export function useWholeRecord(record, options = {}) {
82
80
  * ⛔ THIS MUST NOT DECIDE THE ADDRESS ITSELF, and it used to. It read
83
81
  * `config.queries[name].detailUrl` (retired since) directly and otherwise composed
84
82
  * `/data/<name>/<slug>.json` by hand, which was wrong three ways: it 404'd on
85
- * any collection without `deferred:` (that file is only written for one), it
83
+ * any query without `deferred:` (that file was only written for one then), it
86
84
  * could not see a host's live record lane at all, and its hand-rolled `{slug}`
87
85
  * replace ignored a route whose param is named anything else.
88
86
  *
@@ -93,8 +91,8 @@ export function useWholeRecord(record, options = {}) {
93
91
  * per-record source is, then `buildDetailConfig` turns that plus a param into a
94
92
  * request. A fourth answer computed here is a fourth thing to drift.
95
93
  *
96
- * Returns null when the collection has no separate detail source — the common
97
- * case, and not a failure. The caller's record is already whole.
94
+ * Returns null when the query has no separate detail source — an external query
95
+ * with no `record:` — and the caller's record is all there is.
98
96
  *
99
97
  * Exported for tests only — not re-exported from the package index.
100
98
  *
@@ -116,7 +114,8 @@ export function buildDetailRequest(record, query, { param = null } = {}) {
116
114
  // `entity-store` matches on — else `slug`, the file lane's per-record key and the
117
115
  // documented default.
118
116
  const paramName = param || website?.recordPageFor?.(query)?.paramName || 'slug'
119
- const paramValue = routeParamValue(record, paramName)
117
+ // The field the query binds its page's URL segment to, when it binds one — else `$name`.
118
+ const paramValue = routeParamValue(record, paramName, routeFieldOf(config?.queries?.[query]))
120
119
  if (paramValue === undefined || paramValue === null || paramValue === '') return null
121
120
 
122
121
  // One synthetic source, resolved by the shared rule — same inputs the