@uniweb/build 1.24.0 → 1.24.1
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 +7 -7
- package/src/backend-models.js +55 -0
- package/src/resolve-data-schema.js +17 -4
- package/src/site/queries-config.js +4 -1
- package/src/site/query-processor.js +24 -1
- package/src/uwx/records.js +29 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniweb/build",
|
|
3
|
-
"version": "1.24.
|
|
3
|
+
"version": "1.24.1",
|
|
4
4
|
"description": "Build tooling for the Uniweb Component Web Platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -57,12 +57,12 @@
|
|
|
57
57
|
"js-yaml": "^4.3.2",
|
|
58
58
|
"sharp": "^0.35.5",
|
|
59
59
|
"yaml": "^2.5.0",
|
|
60
|
-
"@uniweb/
|
|
60
|
+
"@uniweb/schemas": "~1.7.4",
|
|
61
|
+
"@uniweb/theming": "~1.3.2",
|
|
61
62
|
"@uniweb/content-writer": "~1.3.2",
|
|
62
|
-
"@uniweb/
|
|
63
|
+
"@uniweb/content-reader": "~1.5.11",
|
|
63
64
|
"@uniweb/semantic-parser": "~1.13.5",
|
|
64
|
-
"@uniweb/
|
|
65
|
-
"@uniweb/theming": "~1.3.2"
|
|
65
|
+
"@uniweb/projections": "~1.2.17"
|
|
66
66
|
},
|
|
67
67
|
"optionalDependencies": {
|
|
68
68
|
"@uniweb/runtime": "~1.6.5"
|
|
@@ -74,8 +74,8 @@
|
|
|
74
74
|
"@tailwindcss/vite": "^4.0.0",
|
|
75
75
|
"@vitejs/plugin-react": "^4.0.0 || ^5.0.0",
|
|
76
76
|
"vite-plugin-svgr": "^4.0.0",
|
|
77
|
-
"@uniweb/
|
|
78
|
-
"@uniweb/
|
|
77
|
+
"@uniweb/runtime": "~1.6.5",
|
|
78
|
+
"@uniweb/core": "~1.6.13"
|
|
79
79
|
},
|
|
80
80
|
"peerDependenciesMeta": {
|
|
81
81
|
"vite": {
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The system Models whose records only a backend holds — `@uniweb/catalog`, a site backend's store.
|
|
3
|
+
*
|
|
4
|
+
* A site READS one and holds none. It names one in a query (`queries.yml`: `schema: '@uniweb/catalog'`)
|
|
5
|
+
* and in a data key (`meta.js`: `data: { store: { schema: '@uniweb/catalog', whole: true } }`), and the
|
|
6
|
+
* published site's records service answers it: the catalogs its owner made public, each with its
|
|
7
|
+
* offerings and prices, which a visitor who isn't signed in may see. Its records are written in the
|
|
8
|
+
* app, on the site's backend, so no file of a site is one: a build or a push that finds one stops.
|
|
9
|
+
*
|
|
10
|
+
* ⭐ NOTHING HERE DEFINES ONE. The backend's definition is the only one, and the app edits it with its
|
|
11
|
+
* own screen, so a copy kept here could only drift from it. That is the difference from the system
|
|
12
|
+
* Models a site's records may name (`@uniweb/schemas/system`: `@uniweb/link`, `@uniweb/file`), whose
|
|
13
|
+
* definitions a site with no backend builds and validates its own records with.
|
|
14
|
+
*
|
|
15
|
+
* ⛔ Until 2026-11-16 every build refused the name as reserved, and a push named it a Model the backend
|
|
16
|
+
* has none of (the backend's data-schema read answers 404 for its system Models, `@uniweb/link`
|
|
17
|
+
* included, measured on a local backend that day), so a site could not declare its store at all.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/** The backend-held system Models, by their full name. */
|
|
21
|
+
export const BACKEND_MODELS = Object.freeze(['@uniweb/catalog'])
|
|
22
|
+
|
|
23
|
+
/** Is this ref one of them? */
|
|
24
|
+
export function isBackendModel(ref) {
|
|
25
|
+
return typeof ref === 'string' && BACKEND_MODELS.includes(ref)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The refusal for files kept as records of one — `records/uniweb/catalog/`.
|
|
30
|
+
*
|
|
31
|
+
* @param {string} where - the directory, as the author wrote it (`records/uniweb/catalog/`)
|
|
32
|
+
* @param {string} ref - the Model (`@uniweb/catalog`)
|
|
33
|
+
*/
|
|
34
|
+
export function backendRecordsRefusal(where, ref) {
|
|
35
|
+
return (
|
|
36
|
+
`${where}: ${ref} is a site backend's own, so a site holds none of its records. Its owner writes ` +
|
|
37
|
+
`them in the app, on the site's backend; the site reads them with a query (\`schema: '${ref}'\` in ` +
|
|
38
|
+
`queries.yml). Remove these files.`
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* What a build says about a query of one, which no build has records for: the published site's
|
|
44
|
+
* records service answers it, and a local run sees it with `uniweb dev --published`.
|
|
45
|
+
*
|
|
46
|
+
* @param {string} name - the query's name
|
|
47
|
+
* @param {string} ref - the Model
|
|
48
|
+
*/
|
|
49
|
+
export function backendQueryNote(name, ref) {
|
|
50
|
+
return (
|
|
51
|
+
`Query "${name}" reads ${ref}, which only a site backend holds, so a build has none of its records. ` +
|
|
52
|
+
'On the published site, its records service answers it, with what the site\'s owner made public; ' +
|
|
53
|
+
'`uniweb dev --published` shows that here.'
|
|
54
|
+
)
|
|
55
|
+
}
|
|
@@ -45,6 +45,7 @@ import { existsSync, readdirSync, statSync } from 'node:fs'
|
|
|
45
45
|
import { join, resolve, isAbsolute, extname, basename } from 'node:path'
|
|
46
46
|
import { dataRefOf } from '@uniweb/core/data-keys'
|
|
47
47
|
import { SYSTEM_RECORD_SCHEMAS } from '@uniweb/schemas/system'
|
|
48
|
+
import { BACKEND_MODELS, isBackendModel } from './backend-models.js'
|
|
48
49
|
import { assertOptionsTargets, assertI18nPaths } from './uwx/data-schema.js'
|
|
49
50
|
import { pathToFileURL } from 'node:url'
|
|
50
51
|
import { createRequire } from 'node:module'
|
|
@@ -228,15 +229,25 @@ export async function resolveSchemaRef(ref, { srcDir, aliases }) {
|
|
|
228
229
|
|
|
229
230
|
// ⭐ THE SYSTEM MODELS A SITE'S RECORDS MAY NAME — `@uniweb/link` — resolve from the build's own
|
|
230
231
|
// copy (`@uniweb/schemas/system`), whatever the foundation holds: a site with no backend builds,
|
|
231
|
-
// validates and renders a link record with it.
|
|
232
|
-
//
|
|
232
|
+
// validates and renders a link record with it. A backend-held one — `@uniweb/catalog` — has no
|
|
233
|
+
// copy here (`./backend-models.js`): `buildDataSchemaMap` passes over it, so asking for its
|
|
234
|
+
// definition is a mistake that says so. Every other `@uniweb/` name is platform plumbing, never a
|
|
235
|
+
// data-schema source. (The whole scope was refused until 2026-09-28.)
|
|
233
236
|
if (scope === RESERVED_SYSTEM_SCOPE) {
|
|
234
237
|
const system = SYSTEM_RECORD_SCHEMAS[name]
|
|
235
238
|
if (system) return normalizeNamedSchema(system, ref)
|
|
239
|
+
if (isBackendModel(ref)) {
|
|
240
|
+
throw new Error(
|
|
241
|
+
`'${ref}' is a site backend's own Model: only the backend defines it, and a site's records are never ` +
|
|
242
|
+
`of it. A site reads it with a query or a data key.`
|
|
243
|
+
)
|
|
244
|
+
}
|
|
236
245
|
const allowed = Object.keys(SYSTEM_RECORD_SCHEMAS).map((n) => `'@${scope}/${n}'`).join(', ')
|
|
246
|
+
const read = BACKEND_MODELS.map((m) => `'${m}'`).join(', ')
|
|
237
247
|
throw new Error(
|
|
238
248
|
`'@${scope}' is the reserved platform system namespace: the only data schemas a site's records ` +
|
|
239
|
-
`may name in it are ${allowed}
|
|
249
|
+
`may name in it are ${allowed}, and a query or a data key may also read ${read}, which a site ` +
|
|
250
|
+
`backend holds. Use '@std/${name}' for the shared standard schemas.`
|
|
240
251
|
)
|
|
241
252
|
}
|
|
242
253
|
|
|
@@ -346,7 +357,9 @@ export async function buildDataSchemaMap(refs, { srcDir }) {
|
|
|
346
357
|
const queue = Array.from(refs)
|
|
347
358
|
while (queue.length > 0) {
|
|
348
359
|
const ref = queue.shift()
|
|
349
|
-
|
|
360
|
+
// A backend-held system Model (`@uniweb/catalog`) is a ref with no definition here: a data key or
|
|
361
|
+
// a query reads it, and the backend's definition is the only one (`./backend-models.js`).
|
|
362
|
+
if (map[ref] || isBackendModel(ref)) continue
|
|
350
363
|
map[ref] = await resolveSchemaRef(ref, { srcDir, aliases })
|
|
351
364
|
for (const target of collectNestedRefs(map[ref])) {
|
|
352
365
|
if (!map[target]) queue.push(target)
|
|
@@ -32,6 +32,7 @@ import { join } from 'node:path'
|
|
|
32
32
|
import { existsSync, readFileSync } from 'node:fs'
|
|
33
33
|
import { recordLayout } from '@uniweb/schemas/conform'
|
|
34
34
|
import { isSystemRecordRef } from '@uniweb/schemas/system'
|
|
35
|
+
import { isBackendModel } from '../backend-models.js'
|
|
35
36
|
import { detectFoundationType, parseCatalogRef } from './foundation-ref.js'
|
|
36
37
|
import { readRegisteredFoundation } from './registered-foundation.js'
|
|
37
38
|
import { buildDataSchemaMap, SCHEMA_NOT_FOUND } from '../resolve-data-schema.js'
|
|
@@ -387,7 +388,9 @@ export async function dataKeyTyping(siteRoot, declarations, opts = {}) {
|
|
|
387
388
|
const { schemas } = await resolveRecordSchemas(siteRoot, [...named, ...keyTypes.values()], { siteYml })
|
|
388
389
|
for (const [key, type] of keyTypes) {
|
|
389
390
|
const ref = defaultSchema(key)
|
|
390
|
-
|
|
391
|
+
// A type only a site backend holds (`@uniweb/catalog`) has no definition here, and is a type all
|
|
392
|
+
// the same (`../backend-models.js`).
|
|
393
|
+
if (schemas[ref] || explicit.has(ref) || !(schemas[type] || isBackendModel(type))) continue
|
|
391
394
|
typing.set(ref, type)
|
|
392
395
|
}
|
|
393
396
|
return typing
|
|
@@ -69,6 +69,7 @@ import { refuseNotOneRecord } from './record-file.js'
|
|
|
69
69
|
import { resolveRecordSchemas, resolveQueriesConfig, dataKeyTyping } from './queries-config.js'
|
|
70
70
|
import { keyOfDefaultRef } from '../uwx/data-key-types.js'
|
|
71
71
|
import { standardTypeFor } from './standard-type-for.js'
|
|
72
|
+
import { isBackendModel, backendRecordsRefusal, backendQueryNote } from '../backend-models.js'
|
|
72
73
|
import { parseFrontmatter } from '../utils/frontmatter.js'
|
|
73
74
|
import { toDeliveredRecord, toStoredRecord, storedPath, briefFieldMap, contentBodyField, misplacedFields, undeclaredFields, withoutUndeclared, mapReferences, recordLayout } from '@uniweb/schemas/conform'
|
|
74
75
|
import { ownsType, undeclaredAdvice, listOf } from './undeclared-fields.js'
|
|
@@ -1267,6 +1268,8 @@ export async function processQueries(siteDir, queriesConfigIn, recordsDir, baseP
|
|
|
1267
1268
|
poolBySchema.delete(ref)
|
|
1268
1269
|
poolBySchema.set(type, [...(poolBySchema.get(type) || []), ...held])
|
|
1269
1270
|
}
|
|
1271
|
+
// Once typed, so a folder named for a key typed `@uniweb/catalog` is refused with the catalog's own.
|
|
1272
|
+
refuseBackendRecords(poolBySchema, pool.dir)
|
|
1270
1273
|
|
|
1271
1274
|
// ⭐ THE DATA SCHEMA EACH QUERY'S RECORDS ARE DELIVERED IN (`deliverRecord`) — resolved
|
|
1272
1275
|
// from the foundation's source once for every query and every folder of records.
|
|
@@ -1305,7 +1308,11 @@ export async function processQueries(siteDir, queriesConfigIn, recordsDir, baseP
|
|
|
1305
1308
|
parsed.dataSchema = (parsed.schema && dataSchemas[parsed.schema]) || null
|
|
1306
1309
|
parsed.references = references
|
|
1307
1310
|
parsed.unsendable = unsendable
|
|
1308
|
-
if (parsed.poolEntities.length === 0) {
|
|
1311
|
+
if (parsed.poolEntities.length === 0 && isBackendModel(parsed.schema)) {
|
|
1312
|
+
// ⭐ Records only a site backend holds (`@uniweb/catalog`): none here, ever, so `[]` is the
|
|
1313
|
+
// answer, and the published site's records service answers it with what the owner made public.
|
|
1314
|
+
console.log(`[query-processor] ${backendQueryNote(name, parsed.schema)}`)
|
|
1315
|
+
} else if (parsed.poolEntities.length === 0) {
|
|
1309
1316
|
const dirs = folderRef ? poolDirsForSchema(folderRef) : null
|
|
1310
1317
|
console.warn(
|
|
1311
1318
|
`[query-processor] Query "${name}" matches no records — ` +
|
|
@@ -1350,6 +1357,22 @@ async function querySchemas(siteDir, queriesConfig, typing = new Map(), poolBySc
|
|
|
1350
1357
|
return { schemas, missing }
|
|
1351
1358
|
}
|
|
1352
1359
|
|
|
1360
|
+
/**
|
|
1361
|
+
* Stop the build for files kept as records of a Model only a site backend holds — `records/uniweb/catalog/`
|
|
1362
|
+
* (`../backend-models.js`): its records are written in the app, on the site's backend, so a site reads
|
|
1363
|
+
* them with a query and holds none. A push refuses the same files.
|
|
1364
|
+
*
|
|
1365
|
+
* @param {Map<string, Array>} poolBySchema - the records, by the ref their folder names
|
|
1366
|
+
* @param {string} dir - the records directory, as the site names it
|
|
1367
|
+
*/
|
|
1368
|
+
export function refuseBackendRecords(poolBySchema, dir) {
|
|
1369
|
+
const lines = []
|
|
1370
|
+
for (const [ref, held] of poolBySchema) {
|
|
1371
|
+
if (isBackendModel(ref) && held?.length) lines.push(backendRecordsRefusal(`${dir}/${held[0].dirs.join('/')}/`, ref))
|
|
1372
|
+
}
|
|
1373
|
+
if (lines.length) throw new Error(`[uniweb] ${lines.join('\n')}`)
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1353
1376
|
/**
|
|
1354
1377
|
* Stop the build for records whose data schema resolves to nothing, naming each folder and
|
|
1355
1378
|
* query and what to write: every record has a data schema [Diego, 2026-11-11]. `missing` holds
|
package/src/uwx/records.js
CHANGED
|
@@ -73,6 +73,11 @@ import { loadFreeformRecord } from '../i18n/freeform.js'
|
|
|
73
73
|
import { isDraftRecord } from '../site/record-draft.js'
|
|
74
74
|
import { LINK_MODEL, linkRecordRefusal } from './link-records.js'
|
|
75
75
|
import { FILE_MODEL } from './file-records.js'
|
|
76
|
+
import { isBackendModel, backendRecordsRefusal } from '../backend-models.js'
|
|
77
|
+
|
|
78
|
+
// What `typedFor` answers for a data key typed by a Model only a site backend holds: known, with no
|
|
79
|
+
// declaration to map records by.
|
|
80
|
+
const BACKEND_HELD = Symbol('backend-held')
|
|
76
81
|
|
|
77
82
|
const DATE_KINDS = new Set(['date', 'datetime'])
|
|
78
83
|
// The record's OWN keys — identity and transport, never a field of any section, never
|
|
@@ -1076,6 +1081,12 @@ export async function buildRecordEntities(siteRoot, opts = {}) {
|
|
|
1076
1081
|
const key = keyOfDefaultRef(schema)
|
|
1077
1082
|
const type = key ? keyTypes.get(key) : null
|
|
1078
1083
|
if (!type || explicitBy.has(schema)) return null
|
|
1084
|
+
// A type only a site backend holds (`@uniweb/catalog`) has no declaration to read, here or from
|
|
1085
|
+
// the backend, and is a type all the same: the query names it, and a folder of it is refused.
|
|
1086
|
+
if (isBackendModel(type)) {
|
|
1087
|
+
keyTyped.set(schema, type)
|
|
1088
|
+
return BACKEND_HELD
|
|
1089
|
+
}
|
|
1079
1090
|
const declaration = await declarationFor(modelFor(type, `data key "${key}"`))
|
|
1080
1091
|
if (!declaration) return null
|
|
1081
1092
|
keyTyped.set(schema, type)
|
|
@@ -1209,8 +1220,18 @@ export async function buildRecordEntities(siteRoot, opts = {}) {
|
|
|
1209
1220
|
for (const [schema, poolEntities] of poolBySchema) {
|
|
1210
1221
|
if (schema === LINK_MODEL || schema === FILE_MODEL) continue
|
|
1211
1222
|
const label = poolEntities[0].dirs.join('/')
|
|
1223
|
+
// ⛔ Records only a site backend holds (`@uniweb/catalog`, `../backend-models.js`) are never a
|
|
1224
|
+
// site's files: the owner writes them in the app. Refused, as a build refuses them.
|
|
1225
|
+
if (isBackendModel(schema)) {
|
|
1226
|
+
refusals.push(backendRecordsRefusal(`${pool.dir}/${label}/`, schema))
|
|
1227
|
+
continue
|
|
1228
|
+
}
|
|
1212
1229
|
const modelName = modelFor(schema, `${pool.dir}/${label}/`)
|
|
1213
1230
|
const declaration = (await declarationFor(modelName)) || (await typedFor(schema))
|
|
1231
|
+
if (declaration === BACKEND_HELD) {
|
|
1232
|
+
refusals.push(backendRecordsRefusal(`${pool.dir}/${label}/`, keyTyped.get(schema)))
|
|
1233
|
+
continue
|
|
1234
|
+
}
|
|
1214
1235
|
if (!declaration) {
|
|
1215
1236
|
// An explicit schema the author asked for is a hard error; one only the
|
|
1216
1237
|
// folder's name supplied is refused for the folder, with the rest of the push.
|
|
@@ -1376,8 +1397,12 @@ export async function buildRecordEntities(siteRoot, opts = {}) {
|
|
|
1376
1397
|
for (const { name, decl } of queries) {
|
|
1377
1398
|
const schema = decl.schema || decl.model
|
|
1378
1399
|
const hasRecords = poolBySchema.has(schema)
|
|
1379
|
-
// A query over link records names a system Model, which resolves whatever the foundation holds
|
|
1380
|
-
|
|
1400
|
+
// A query over link records names a system Model, which resolves whatever the foundation holds,
|
|
1401
|
+
// and so does one over a Model only a site backend holds (`@uniweb/catalog`): its declaration
|
|
1402
|
+
// goes up, and the published site's records service answers it. The backend's data-schema read
|
|
1403
|
+
// answers neither (404, measured 2026-11-16), so asking it would refuse the push.
|
|
1404
|
+
const backendHeld = isBackendModel(schema)
|
|
1405
|
+
const resolved = schema === LINK_MODEL || schema === FILE_MODEL || backendHeld || (hasRecords
|
|
1381
1406
|
? !unresolved.has(schema)
|
|
1382
1407
|
: Boolean((await declarationFor(modelFor(schema, `query "${name}"`))) || (await typedFor(schema))))
|
|
1383
1408
|
if (!resolved) {
|
|
@@ -1385,7 +1410,8 @@ export async function buildRecordEntities(siteRoot, opts = {}) {
|
|
|
1385
1410
|
if (!hasRecords) refusals.push(noDataSchema(`query "${name}"`, qualifyRef(schema, scope)))
|
|
1386
1411
|
continue
|
|
1387
1412
|
}
|
|
1388
|
-
|
|
1413
|
+
// A query a data key types by such a Model (`store: {}`, typed `@uniweb/catalog`) has none either.
|
|
1414
|
+
if (!hasRecords && !backendHeld && !isBackendModel(keyTyped.get(schema))) {
|
|
1389
1415
|
// "Nothing pushed" and "nothing there" look identical, so say which.
|
|
1390
1416
|
const dirs = poolDirsForSchema(schema)
|
|
1391
1417
|
warnings.push(
|