uniweb 1.34.1 → 1.34.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",
3
- "version": "1.34.1",
3
+ "version": "1.34.3",
4
4
  "description": "Create structured Vite + React sites with content/code separation",
5
5
  "type": "module",
6
6
  "bin": {
@@ -42,14 +42,14 @@
42
42
  "prompts": "^2.4.2",
43
43
  "tar": "^7.5.21",
44
44
  "@uniweb/content-writer": "~1.3.2",
45
+ "@uniweb/semantic-parser": "~1.13.4",
45
46
  "@uniweb/core": "~1.6.12",
46
- "@uniweb/schemas": "~1.7.2",
47
- "@uniweb/semantic-parser": "~1.13.4"
47
+ "@uniweb/schemas": "~1.7.4"
48
48
  },
49
49
  "peerDependencies": {
50
- "@uniweb/build": "~1.23.1",
51
50
  "@uniweb/semantic-parser": "~1.13.4",
52
- "@uniweb/content-reader": "~1.5.10"
51
+ "@uniweb/content-reader": "~1.5.10",
52
+ "@uniweb/build": "~1.23.3"
53
53
  },
54
54
  "peerDependenciesMeta": {
55
55
  "@uniweb/build": {
@@ -45,7 +45,7 @@ site/
45
45
  | `form` | a form an author designs | a list of controls |
46
46
  | `scene` | a Scene Composition Format document | flat |
47
47
 
48
- Each type's fields, with what each is for: https://github.com/uniweb/schemas/tree/main/src/standard. A record holds only its type's fields: a push refuses one with a field the type lacks, though a static build keeps it. What a site says differently (a topic) goes in a field the type has (`tags`), or the type is not the one.
48
+ Each type's fields, with what each is for: https://github.com/uniweb/schemas/tree/main/src/standard. A record holds only its type's fields: `uniweb validate` reports one the type lacks, a push refuses it, and a build notes it and leaves it out, so a component receives the same record on a static host and a hosted site. What a site says differently (a topic) goes in a field the type has (`tags`), or the type is not the one.
49
49
 
50
50
  Keep directories flat — `records/article/2025/x.md` reads as the `2025` schema of an `article` org. A `_`-prefixed file is not a record.
51
51
 
@@ -176,7 +176,7 @@ function Article({ content, block }) { // data: { article: { schema: '@std/art
176
176
 
177
177
  **Component-side fetching** for a search box, "load more", a lazy popover: `useFetched`, `useCacheEntry`, `useWholeRecord` share the framework's cache and dedupe same-key requests. On a prerendered page a hook's first render finds only the page's own data; anything else prerenders as the loading state. Declare a key for whatever a page must show without JavaScript.
178
178
 
179
- **`uniweb validate`** checks every record file against declared schemas (missing required, type/enum/format, nested fields); a violation fails it (`--lax` only reports), and `push`/`publish` refuse the same findings. External queries are reported as deferred. A `ref` must name a record in the project (a uuid is left alone); an `options` value isn't checked against the entity it names.
179
+ **`uniweb validate`** checks every record file against declared schemas (missing required, type/enum/format, nested fields, and what a push cannot carry: a field the schema lacks, a markdown body with no field for it); a violation fails it (`--lax` only reports), and `push`/`publish` refuse the same findings. External queries are reported as deferred. A `ref` must name a record in the project (a uuid is left alone); an `options` value isn't checked against the entity it names.
180
180
 
181
181
  ## External sources and transports
182
182
 
@@ -29,6 +29,7 @@ import {
29
29
  } from '../utils/sync-point.js'
30
30
  import { sentRoots } from '../utils/site-roots.js'
31
31
  import { humanBytes } from '../utils/bytes.js'
32
+ import { anotherClientsSessionLines } from '../utils/registry-auth.js'
32
33
  import {
33
34
  describeRequestError,
34
35
  describeWorkspace,
@@ -2633,8 +2634,15 @@ export async function pushSyncPackages({
2633
2634
  return null
2634
2635
  }
2635
2636
  error(`${label} push rejected: HTTP ${res.status} ${res.statusText}`)
2636
- // A typed 403 says its own cause (a plan's limit, say), which is not the credentials.
2637
- if ((res.status === 401 || res.status === 403) && typeof problem?.reason !== 'string') {
2637
+ // A typed 403 says its own cause (a plan's limit, say), which is not the credentials. A
2638
+ // session made for another of the backend's clients is the credentials, and says so.
2639
+ const anotherClient = await anotherClientsSessionLines(problem, {
2640
+ origin: client.origin,
2641
+ fromEnv: Boolean(process.env.UNIWEB_TOKEN)
2642
+ })
2643
+ if (anotherClient) {
2644
+ for (const line of anotherClient) note(line)
2645
+ } else if ((res.status === 401 || res.status === 403) && typeof problem?.reason !== 'string') {
2638
2646
  note(
2639
2647
  "Credentials weren't accepted — log in again (`uniweb login --server <url>`), or check UNIWEB_TOKEN."
2640
2648
  )
@@ -156,8 +156,10 @@ function printSiteHuman(result) {
156
156
  )
157
157
  }
158
158
  for (const f of g.findings) {
159
+ // A finding on the record itself (its markdown body, its shape) names no field.
160
+ const at = f.field ? ` › ${f.field}` : ''
159
161
  log(
160
- ` ${colors.yellow}•${colors.reset} item ${colors.bright}"${f.item}"${colors.reset} › ${f.field} — ${f.message}`
162
+ ` ${colors.yellow}•${colors.reset} item ${colors.bright}"${f.item}"${colors.reset}${at} — ${f.message}`
161
163
  )
162
164
  }
163
165
  }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "generatedAt": "2026-11-11T22:21:29.972Z",
3
+ "generatedAt": "2026-11-12T00:25:23.192Z",
4
4
  "packages": {
5
5
  "@uniweb/api": {
6
6
  "version": "1.7.0"
7
7
  },
8
8
  "@uniweb/build": {
9
- "version": "1.23.1"
9
+ "version": "1.23.3"
10
10
  },
11
11
  "@uniweb/content-reader": {
12
12
  "version": "1.5.10"
@@ -24,7 +24,7 @@
24
24
  "version": "1.0.9"
25
25
  },
26
26
  "@uniweb/kit": {
27
- "version": "1.7.20"
27
+ "version": "1.7.21"
28
28
  },
29
29
  "@uniweb/loom": {
30
30
  "version": "1.1.3"
@@ -42,10 +42,10 @@
42
42
  "version": "1.0.1"
43
43
  },
44
44
  "@uniweb/schemas": {
45
- "version": "1.7.2"
45
+ "version": "1.7.4"
46
46
  },
47
47
  "@uniweb/scholar": {
48
- "version": "1.1.2"
48
+ "version": "1.1.3"
49
49
  },
50
50
  "@uniweb/semantic-parser": {
51
51
  "version": "1.13.4"
package/src/index.js CHANGED
@@ -2036,7 +2036,8 @@ Authenticates with a backend and stores its session in
2036
2036
  logs you out of the first (once the new login succeeds). The backend you are
2037
2037
  logged in to is where the backend commands go (push, pull, publish, status,
2038
2038
  register, clone) — so this is how you switch. Already logged in to it, login
2039
- does nothing; add --password, --browser, --token-paste or --token to log in again.
2039
+ does nothing, unless that backend no longer accepts the session: then it signs in
2040
+ again. Add --password, --browser, --token-paste or --token to log in again anyway.
2040
2041
 
2041
2042
  Without --server: https://uniweb.app (or \$UNIWEB_SERVER). No command talks
2042
2043
  to a backend you are not logged in to — run one before logging in and it asks first.
@@ -24,7 +24,7 @@
24
24
 
25
25
  import { execFile, execFileSync } from 'node:child_process'
26
26
  import { existsSync, readFileSync, realpathSync } from 'node:fs'
27
- import { join, relative, resolve, sep } from 'node:path'
27
+ import { basename, dirname, join, relative, resolve, sep } from 'node:path'
28
28
  import yaml from 'js-yaml'
29
29
  import { repoOf } from './sync-point.js'
30
30
  import { quietGitEnv, upstreamOf } from './git.js'
@@ -148,11 +148,15 @@ export function mountHolding(siteDir, abs) {
148
148
 
149
149
  // git names a repository's top by its real path, and a mount may be reached through a link (a
150
150
  // temporary folder on macOS is): compared as written, it would read as outside the repository.
151
+ // ⭐ A folder that is not there — one inside a submodule no clone checked out — is its nearest
152
+ // folder that is, resolved, and the rest as written. ⛔ Until 2026-11-11 it was compared as written,
153
+ // so a mount inside such a submodule read as a folder no repository holds.
151
154
  function realOf(abs) {
152
155
  try {
153
156
  return realpathSync(abs)
154
157
  } catch {
155
- return abs // not there: compared as written
158
+ const parent = dirname(abs)
159
+ return parent === abs ? abs : join(realOf(parent), basename(abs))
156
160
  }
157
161
  }
158
162
 
@@ -356,12 +356,50 @@ export async function fetchMe({ apiBase, token }) {
356
356
  `token check failed: HTTP ${res.status} ${res.statusText}`
357
357
  )
358
358
  e.status = res.status
359
+ // The refusal's body, so a caller can say why: a session made for another of the
360
+ // backend's clients (`anotherClientsSessionLines`) is not a wrong or expired token.
361
+ e.problem = await res.json().catch(() => null)
359
362
  throw e
360
363
  }
361
364
  const data = await res.json().catch(() => null)
362
365
  return data?.account || null
363
366
  }
364
367
 
368
+ /** The reason a backend gives when a session was made for another of its clients. */
369
+ export const SESSION_FOR_ANOTHER_CLIENT = 'session_for_another_client'
370
+
371
+ /**
372
+ * What to say when a backend refuses a session because it was made for another of its
373
+ * clients. Its problem body says `reason: "session_for_another_client"`, and `client` names
374
+ * whose session the route takes: here a session made for the Uniweb app, sent to a route that
375
+ * takes only the CLI's (`client: "cli"`). Null for any other refusal, so a caller keeps its
376
+ * own message.
377
+ *
378
+ * ⭐ IT NAMES THE FIX: a session the CLI signs in for itself, on the backend that refused
379
+ * (`loginCommand`). ⛔ Until 2026-11-11 the token checks said only "HTTP 401", and a push said
380
+ * nothing at all, since its advice was for a refusal with no reason.
381
+ *
382
+ * @param {object|null|undefined} problem - the refusal's parsed body
383
+ * @param {{ origin: string, fromEnv?: boolean }} o - the backend that refused, and whether the
384
+ * session came from UNIWEB_TOKEN
385
+ * @returns {Promise<string[]|null>}
386
+ */
387
+ export async function anotherClientsSessionLines(problem, { origin, fromEnv = false } = {}) {
388
+ if (problem?.reason !== SESSION_FOR_ANOTHER_CLIENT || problem?.client !== 'cli') return null
389
+ const { loginCommand } = await import('./config.js')
390
+ const { getCliPrefix } = await import('./interactive.js')
391
+ const login = loginCommand(origin, getCliPrefix())
392
+ return fromEnv
393
+ ? [
394
+ `UNIWEB_TOKEN holds a session made for the Uniweb app, and ${origin} takes only a session the uniweb CLI signed in with.`,
395
+ `Set UNIWEB_TOKEN to a CLI session, or unset it and sign in: ${login} --browser (or --password).`
396
+ ]
397
+ : [
398
+ `This session was made for the Uniweb app, and ${origin} takes only a session the uniweb CLI signed in with.`,
399
+ `Sign in from the CLI: ${login} --browser (or --password).`
400
+ ]
401
+ }
402
+
365
403
  // Username/password — prompts unless UNIWEB_USERNAME/PASSWORD are set.
366
404
  async function loginViaPassword({ apiBase, nonInteractive }) {
367
405
  let username = process.env.UNIWEB_USERNAME
@@ -423,7 +461,15 @@ async function loginViaTokenPaste({ apiBase, nonInteractive }) {
423
461
  }
424
462
  )
425
463
  if (!token) process.exit(1)
426
- const account = await fetchMe({ apiBase, token }) // throws if the token is invalid
464
+ let account
465
+ try {
466
+ account = await fetchMe({ apiBase, token })
467
+ } catch (err) {
468
+ // Said as the `--token` check says it (`anotherClientsSessionLines`); any other refusal as before.
469
+ const lines = await anotherClientsSessionLines(err.problem, { origin: normOrigin(apiBase) })
470
+ if (lines) throw new Error(lines.join('\n '))
471
+ throw err
472
+ }
427
473
  const record = { token, origin: normOrigin(apiBase) }
428
474
  if (account?.uuid) record.uuid = account.uuid
429
475
  if (account?.username) record.username = account.username
@@ -730,7 +776,22 @@ export async function runRegistryLogin({ apiBase, args = [] } = {}) {
730
776
  )
731
777
  }
732
778
 
733
- if (existing?.token && !isExpired(existing)) {
779
+ // ⭐ A STORED SESSION THE BACKEND REFUSES IS NOT A LOGIN. A login that names no way of signing
780
+ // in keeps the session it finds, so it asks the backend first (`/dev/auth/me`) and signs in
781
+ // again on a 401: a session revoked, or one made for the Uniweb app, which a backend refuses on
782
+ // the CLI's routes since 2026-11-11. ⛔ Until then such a session got "Already logged in" here,
783
+ // while every command answered 401 and named this command as the fix. Any other answer (no
784
+ // network, a 5xx) keeps the session, as before: it says nothing about the session.
785
+ let refused = null
786
+ if (existing?.token && !isExpired(existing) && !forced) {
787
+ try {
788
+ await fetchMe({ apiBase, token: existing.token })
789
+ } catch (err) {
790
+ if (err.status === 401) refused = err
791
+ }
792
+ }
793
+
794
+ if (existing?.token && !isExpired(existing) && !refused) {
734
795
  const who =
735
796
  existing.username ||
736
797
  existing.handle ||
@@ -776,6 +837,13 @@ export async function runRegistryLogin({ apiBase, args = [] } = {}) {
776
837
  console.error(
777
838
  `Already logged in${who ? ` as \x1b[1m${who}\x1b[0m` : ''} (${key}) — logging in again replaces that session.\n`
778
839
  )
840
+ } else if (refused) {
841
+ const why = await anotherClientsSessionLines(refused.problem, { origin: key })
842
+ console.error(
843
+ `\x1b[33m!\x1b[0m ${key} refuses the session stored for it${why ? '' : ` (HTTP ${refused.status})`} — signing in again.`
844
+ )
845
+ if (why) console.error(`\x1b[2m ${why[0]}\x1b[0m`)
846
+ console.error('')
779
847
  } else if (current && current !== key) {
780
848
  // ⭐ ONE SESSION AT A TIME *[Diego, 2026-09-21]*: logging in here logs you out of there
781
849
  // — when this login succeeds (writeRegistryAuth replaces the file), so cancelling or
@@ -794,9 +862,13 @@ export async function runRegistryLogin({ apiBase, args = [] } = {}) {
794
862
  try {
795
863
  account = await fetchMe({ apiBase, token: tokenFlag })
796
864
  } catch (err) {
797
- console.error(
798
- `\x1b[31m✗\x1b[0m Token rejected by ${apiBase}: ${err.message}`
799
- )
865
+ const lines = await anotherClientsSessionLines(err.problem, { origin: normOrigin(apiBase) })
866
+ if (lines) {
867
+ console.error(`\x1b[31m✗\x1b[0m ${normOrigin(apiBase)} refuses this token.`)
868
+ for (const line of lines) console.error(` ${line}`)
869
+ } else {
870
+ console.error(`\x1b[31m✗\x1b[0m Token rejected by ${apiBase}: ${err.message}`)
871
+ }
800
872
  process.exit(1)
801
873
  }
802
874
  const record = { token: tokenFlag, origin: normOrigin(apiBase) }
@@ -949,6 +1021,9 @@ async function reportTokenProcess({ named, token }) {
949
1021
  ? `\x1b[31m✗\x1b[0m ${origin} refuses UNIWEB_TOKEN (HTTP ${err.status}).`
950
1022
  : `\x1b[31m✗\x1b[0m Could not check UNIWEB_TOKEN with ${origin}: ${err.message}`
951
1023
  )
1024
+ for (const line of (await anotherClientsSessionLines(err.problem, { origin, fromEnv: true })) || []) {
1025
+ console.error(` ${line}`)
1026
+ }
952
1027
  process.exit(1)
953
1028
  }
954
1029
  const who = account?.username || account?.handle || (account?.uuid ? `account ${account.uuid}` : null)
@@ -184,7 +184,12 @@ export function writableMounts(siteDir) {
184
184
  if (holding.kind === 'submodule') {
185
185
  const top = join(repo.top, holding.submodule.path)
186
186
  const sub = repoOf(top)
187
- if (!sub?.head) why = 'unchecked'
187
+ // ⛔ A submodule never checked out (a clone made without `--recurse-submodules`) is an empty
188
+ // folder of the site's own repository, and git answers for it with the site's: only a
189
+ // repository whose top is the submodule's folder is the submodule. Until 2026-11-11 the site's
190
+ // answer counted, and a pull in such a clone wrote the mounted pages into the top of the site's
191
+ // repository, committed them, and pinned the submodule to a commit of the site's.
192
+ if (!sub?.head || realOf(sub.top) !== realOf(top)) why = 'unchecked'
188
193
  else submodules.push({ segment, at: holding.submodule.path, root: relative(realOf(top), realOf(abs)).split(sep).join('/') || '.', repo: sub })
189
194
  } else if (holding.kind !== 'site') why = holding.kind
190
195
  } else {