@uniweb/build 0.63.1 → 0.63.2
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 +4 -4
- package/src/uwx/data-key-types.js +12 -6
- package/src/validate-data.js +22 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniweb/build",
|
|
3
|
-
"version": "0.63.
|
|
3
|
+
"version": "0.63.2",
|
|
4
4
|
"description": "Build tooling for the Uniweb Component Web Platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -58,11 +58,11 @@
|
|
|
58
58
|
"sharp": "^0.35.3",
|
|
59
59
|
"yaml": "^2.5.0",
|
|
60
60
|
"@uniweb/content-reader": "^1.2.5",
|
|
61
|
+
"@uniweb/projections": "^0.7.3",
|
|
61
62
|
"@uniweb/content-writer": "^0.3.4",
|
|
62
63
|
"@uniweb/schemas": "^0.7.0",
|
|
63
|
-
"@uniweb/
|
|
64
|
-
"@uniweb/semantic-parser": "^1.4.1"
|
|
65
|
-
"@uniweb/theming": "^0.1.15"
|
|
64
|
+
"@uniweb/theming": "^0.1.15",
|
|
65
|
+
"@uniweb/semantic-parser": "^1.4.1"
|
|
66
66
|
},
|
|
67
67
|
"optionalDependencies": {
|
|
68
68
|
"@uniweb/runtime": "^0.27.4"
|
|
@@ -19,9 +19,10 @@
|
|
|
19
19
|
import { declaredKeys } from '@uniweb/core/data-keys'
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
|
-
* The type each data key of a foundation
|
|
23
|
-
*
|
|
24
|
-
*
|
|
22
|
+
* The type each data key of a foundation names, where every declaration of the key agrees on
|
|
23
|
+
* one — from its built `schema.json`: each section type's `data:` (at the top level, beside
|
|
24
|
+
* `_self` and `dataSchemas`), each layout's (under `_layouts`), and the foundation's own, which
|
|
25
|
+
* reaches every section (`main.js` `data:`, under `_self`).
|
|
25
26
|
*
|
|
26
27
|
* @param {object|null} foundationSchema - a foundation's built `dist/meta/schema.json`
|
|
27
28
|
* @returns {Map<string, string>} data key → its schema ref (`team` → `@/member`)
|
|
@@ -29,14 +30,19 @@ import { declaredKeys } from '@uniweb/core/data-keys'
|
|
|
29
30
|
export function dataKeyTypes(foundationSchema) {
|
|
30
31
|
const types = new Map()
|
|
31
32
|
const conflicted = new Set()
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
for (const [key, ref] of declaredKeys(entry.data)) {
|
|
33
|
+
const declare = (data) => {
|
|
34
|
+
for (const [key, ref] of declaredKeys(data)) {
|
|
35
35
|
if (!ref) continue
|
|
36
36
|
if (types.has(key) && types.get(key) !== ref) conflicted.add(key)
|
|
37
37
|
else types.set(key, ref)
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
+
for (const [name, entry] of Object.entries(foundationSchema || {})) {
|
|
41
|
+
if (!entry || typeof entry !== 'object' || name === 'dataSchemas') continue
|
|
42
|
+
if (name === '_self') declare(entry.data)
|
|
43
|
+
else if (name === '_layouts') for (const layout of Object.values(entry)) declare(layout?.data)
|
|
44
|
+
else if (!name.startsWith('_')) declare(entry.data)
|
|
45
|
+
}
|
|
40
46
|
for (const key of conflicted) types.delete(key)
|
|
41
47
|
return types
|
|
42
48
|
}
|
package/src/validate-data.js
CHANGED
|
@@ -41,6 +41,7 @@ import { validateAndNormalizeSchema, buildDataSchemaMap } from './resolve-data-s
|
|
|
41
41
|
export { validateItem, isStaticallyCheckable } from '@uniweb/schemas/conform'
|
|
42
42
|
import { buildSchema } from './schema.js'
|
|
43
43
|
import { resolveRecordsDir, readEntityPool, groupPoolBySchema } from './site/entity-pool.js'
|
|
44
|
+
import { dataKeyTypes, keyOfDefaultRef } from './uwx/data-key-types.js'
|
|
44
45
|
import { readEntityFile } from './uwx/entity-source.js'
|
|
45
46
|
import { toFetchList } from './site/data-fetcher.js'
|
|
46
47
|
import { resolveFoundationSrcPath } from './utils/foundation-source-root.js'
|
|
@@ -86,6 +87,9 @@ export async function validateDataInputs({ siteRoot, foundationPath }) {
|
|
|
86
87
|
const srcDir = resolveFoundationSrcPath(foundationPath)
|
|
87
88
|
const foundation = await buildSchema(srcDir)
|
|
88
89
|
const dataSchemas = foundation.dataSchemas || {}
|
|
90
|
+
// The type each data key names — a records folder named for a typed key holds records of
|
|
91
|
+
// that type when no data schema has its name (`uwx/data-key-types.js`).
|
|
92
|
+
const keyTypes = dataKeyTypes(foundation)
|
|
89
93
|
|
|
90
94
|
const site = await collectSiteContent(siteRoot, { foundationPath })
|
|
91
95
|
const config = site.config || {}
|
|
@@ -275,7 +279,7 @@ export async function validateDataInputs({ siteRoot, foundationPath }) {
|
|
|
275
279
|
// its folder names. ⭐ The set a push sends: every file in the records directory is
|
|
276
280
|
// a record and every record is pushed, whether or not a section reads it — and
|
|
277
281
|
// until 2026-09-24 one that no section read was never checked here.
|
|
278
|
-
const files = await validateRecordFiles(siteRoot, { srcDir, dataSchemas, paths: config.paths, checked: checkedRecords })
|
|
282
|
+
const files = await validateRecordFiles(siteRoot, { srcDir, dataSchemas, keyTypes, paths: config.paths, checked: checkedRecords })
|
|
279
283
|
violations.push(...files.violations)
|
|
280
284
|
setupErrors.push(...files.setupErrors)
|
|
281
285
|
for (const ref of files.schemas) schemasSeen.add(ref)
|
|
@@ -321,22 +325,34 @@ function listViolation(finding, label, base) {
|
|
|
321
325
|
* that names no record of its schema is reported under the rule `ref`, since a push
|
|
322
326
|
* cannot send it.
|
|
323
327
|
*
|
|
324
|
-
* A folder
|
|
325
|
-
*
|
|
328
|
+
* ⭐ A folder named for a data key the foundation types, when no data schema has its name,
|
|
329
|
+
* holds records of that type and is checked against it — `records/team/` against `@/member`
|
|
330
|
+
* for `data: { team: '@/member' }` — the way a push sends them [Diego, 2026-09-25]
|
|
331
|
+
* (`uwx/data-key-types.js`). A folder whose schema resolves to nothing even so is left out in
|
|
332
|
+
* silence: its records are schema-less, delivered as files, and the push says so itself.
|
|
326
333
|
*
|
|
327
334
|
* @returns {Promise<{ violations: object[], setupErrors: object[], schemas: Set<string>, checked: number }>}
|
|
328
335
|
*/
|
|
329
|
-
async function validateRecordFiles(siteRoot, { srcDir, dataSchemas, paths, checked }) {
|
|
336
|
+
async function validateRecordFiles(siteRoot, { srcDir, dataSchemas, keyTypes = new Map(), paths, checked }) {
|
|
330
337
|
const out = { violations: [], setupErrors: [], schemas: new Set(), checked: 0 }
|
|
331
338
|
const pool = await readEntityPool(siteRoot, { dir: resolveRecordsDir(siteRoot, paths).rel })
|
|
332
339
|
// Every record is read first: a reference names a record of another schema by its
|
|
333
340
|
// name — its file's, or its `slug:` — or by the id its file carries.
|
|
334
341
|
const read = []
|
|
335
342
|
const names = new Map() // schema (as its folder names it) → the names and ids of its records
|
|
336
|
-
for (const [
|
|
337
|
-
|
|
343
|
+
for (const [folderRef, entities] of groupPoolBySchema(pool.entities)) {
|
|
344
|
+
let ref = folderRef
|
|
345
|
+
let schema = await schemaForRecords(folderRef, { srcDir, dataSchemas })
|
|
346
|
+
const typed = schema ? null : keyTypes.get(keyOfDefaultRef(folderRef))
|
|
347
|
+
if (typed) {
|
|
348
|
+
schema = await schemaForRecords(typed, { srcDir, dataSchemas })
|
|
349
|
+
if (schema) ref = typed
|
|
350
|
+
}
|
|
351
|
+
// Records are named under what they ARE — a reference to `@/member` finds the ones kept
|
|
352
|
+
// in `records/team/` — and under the folder's own ref as well.
|
|
338
353
|
const known = names.get(ref) ?? new Set()
|
|
339
354
|
names.set(ref, known)
|
|
355
|
+
if (ref !== folderRef) names.set(folderRef, known)
|
|
340
356
|
for (const pooled of entities) {
|
|
341
357
|
let records
|
|
342
358
|
try {
|