@uniweb/build 0.63.2 → 0.63.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 +4 -4
- package/src/uwx/records-project.js +31 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniweb/build",
|
|
3
|
-
"version": "0.63.
|
|
3
|
+
"version": "0.63.3",
|
|
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",
|
|
62
61
|
"@uniweb/content-writer": "^0.3.4",
|
|
62
|
+
"@uniweb/semantic-parser": "^1.4.1",
|
|
63
|
+
"@uniweb/projections": "^0.7.3",
|
|
63
64
|
"@uniweb/schemas": "^0.7.0",
|
|
64
|
-
"@uniweb/theming": "^0.1.15"
|
|
65
|
-
"@uniweb/semantic-parser": "^1.4.1"
|
|
65
|
+
"@uniweb/theming": "^0.1.15"
|
|
66
66
|
},
|
|
67
67
|
"optionalDependencies": {
|
|
68
68
|
"@uniweb/runtime": "^0.27.4"
|
|
@@ -41,7 +41,7 @@ import yaml from 'js-yaml'
|
|
|
41
41
|
import { YAML_OPTIONS } from '../utils/yaml-schema.js'
|
|
42
42
|
import { parseFrontmatter } from './entity-source.js'
|
|
43
43
|
import { writeRecordFile, writeQueriesConfig, writeRecordsConfig } from './project-writer.js'
|
|
44
|
-
import { defaultSchema, deferredFromSchema, foundationDataSchemas, foundationSchemaJson } from './queries-config.js'
|
|
44
|
+
import { defaultSchema, deferredFromSchema, foundationDataSchemas, foundationSchemaJson, QUERIES_YML_RELPATH } from './queries-config.js'
|
|
45
45
|
import { dataKeyTypes } from './data-key-types.js'
|
|
46
46
|
import { poolDirsForSchema, schemaForPoolDirs, resolveRecordsDir } from '../site/entity-pool.js'
|
|
47
47
|
import { folderYmlPath } from '../site/records-config.js'
|
|
@@ -283,7 +283,7 @@ function isDerivedDeferred(d, dataSchemas) {
|
|
|
283
283
|
return d.deferred.every((f) => a.has(f))
|
|
284
284
|
}
|
|
285
285
|
|
|
286
|
-
function declToFileShape(wire, dataSchemas = null, scope = null, own = null, keyTypes = null) {
|
|
286
|
+
function declToFileShape(wire, dataSchemas = null, scope = null, own = null, keyTypes = null, authored = null) {
|
|
287
287
|
// ⛔ UNDO THE PRODUCER'S QUALIFICATION FIRST, before anything compares against
|
|
288
288
|
// `schema`. The push qualifies a foundation-relative `@/x` to `@scope/x`
|
|
289
289
|
// (`site.js::queriesNested`), and both checks below are keyed by the author's
|
|
@@ -317,8 +317,14 @@ function declToFileShape(wire, dataSchemas = null, scope = null, own = null, key
|
|
|
317
317
|
// The default is the query's name — or, when no data schema has that name, the type the
|
|
318
318
|
// foundation declares for the data key of that name (`data-key-types.js`), which is what a
|
|
319
319
|
// push sent in its place. Either one stays unwritten, so the terse file stays terse.
|
|
320
|
+
// ⛔ UNLESS THE AUTHOR WROTE IT: a `schema:` the local file already states for this query is
|
|
321
|
+
// written back as it is. Until 2026-09-25 a pull into a working copy dropped international's
|
|
322
|
+
// `articles: { schema: '@std/article' }`, because a section types `articles` as `@std/article`.
|
|
320
323
|
const keyDefault = name && !own?.has(name) ? keyTypes?.get(name) : null
|
|
321
|
-
|
|
324
|
+
const written = name ? authored?.get(name) : undefined
|
|
325
|
+
if (d.schema && (d.schema === written || (d.schema !== defaultSchema(name) && d.schema !== keyDefault))) {
|
|
326
|
+
decl.schema = d.schema
|
|
327
|
+
}
|
|
322
328
|
setIf(decl, 'sort', d.sort)
|
|
323
329
|
setIf(decl, 'where', d.where)
|
|
324
330
|
setIf(decl, 'limit', d.limit)
|
|
@@ -383,6 +389,26 @@ function declToFileShape(wire, dataSchemas = null, scope = null, own = null, key
|
|
|
383
389
|
* (`info.foundation`, the pinned `@org/name@version`), which is that scope.
|
|
384
390
|
* @returns {{ collections?: 'updated'|'unchanged' }}
|
|
385
391
|
*/
|
|
392
|
+
// The `schema:` each query's author wrote, by query name — `queries.yml` over `site.yml::queries`,
|
|
393
|
+
// the precedence the build reads them in. A query written without one is absent.
|
|
394
|
+
function authoredQuerySchemas(siteRoot, siteYml) {
|
|
395
|
+
let file = null
|
|
396
|
+
try {
|
|
397
|
+
file = yaml.load(readFileSync(join(siteRoot, QUERIES_YML_RELPATH), 'utf8'), YAML_OPTIONS)
|
|
398
|
+
} catch {
|
|
399
|
+
file = null
|
|
400
|
+
}
|
|
401
|
+
const out = new Map()
|
|
402
|
+
for (const decls of [siteYml?.queries, file]) {
|
|
403
|
+
if (!decls || typeof decls !== 'object') continue
|
|
404
|
+
for (const [name, decl] of Object.entries(decls)) {
|
|
405
|
+
if (typeof decl?.schema === 'string') out.set(name, decl.schema)
|
|
406
|
+
else if (out.has(name)) out.delete(name)
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
return out
|
|
410
|
+
}
|
|
411
|
+
|
|
386
412
|
export function declarationsToQueriesYml({ document, siteRoot, scope, ...rest }) {
|
|
387
413
|
refuseOrgOption(rest, 'declarationsToQueriesYml')
|
|
388
414
|
const decls = Array.isArray(document?.queries) ? document.queries : []
|
|
@@ -408,10 +434,11 @@ export function declarationsToQueriesYml({ document, siteRoot, scope, ...rest })
|
|
|
408
434
|
// (`unresolveSelfScope`) — and the types of its data keys.
|
|
409
435
|
const own = ownSchemaNames(dataSchemas)
|
|
410
436
|
const keyTypes = siteYml ? dataKeyTypes(foundationSchemaJson(siteRoot, siteYml)) : null
|
|
437
|
+
const authored = authoredQuerySchemas(siteRoot, siteYml)
|
|
411
438
|
|
|
412
439
|
const queries = {}
|
|
413
440
|
for (const d of decls) {
|
|
414
|
-
const { name, decl } = declToFileShape(d, dataSchemas, selfScope, own, keyTypes)
|
|
441
|
+
const { name, decl } = declToFileShape(d, dataSchemas, selfScope, own, keyTypes, authored)
|
|
415
442
|
if (!name) continue
|
|
416
443
|
queries[name] = decl
|
|
417
444
|
}
|