@uniweb/build 1.24.0 → 1.24.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 +7 -7
- package/src/backend-models.js +55 -0
- package/src/foundation/mappings.js +42 -14
- 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/blueprint.js +27 -0
- package/src/uwx/records.js +29 -3
- package/src/uwx/registry-package.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniweb/build",
|
|
3
|
-
"version": "1.24.
|
|
3
|
+
"version": "1.24.2",
|
|
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/theming": "~1.3.2",
|
|
61
|
+
"@uniweb/schemas": "~1.7.4",
|
|
60
62
|
"@uniweb/content-reader": "~1.5.11",
|
|
61
|
-
"@uniweb/content-writer": "~1.3.2",
|
|
62
|
-
"@uniweb/projections": "~1.2.17",
|
|
63
63
|
"@uniweb/semantic-parser": "~1.13.5",
|
|
64
|
-
"@uniweb/
|
|
65
|
-
"@uniweb/
|
|
64
|
+
"@uniweb/projections": "~1.2.17",
|
|
65
|
+
"@uniweb/content-writer": "~1.3.2"
|
|
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
|
+
}
|
|
@@ -28,6 +28,11 @@
|
|
|
28
28
|
* - a `keys_from` that names no mapping, or an `@/x` that isn't one of the foundation's;
|
|
29
29
|
* - a reverse `follow` line's `model` that names no type, or an `@/x` the foundation doesn't define.
|
|
30
30
|
*
|
|
31
|
+
* A `set` mapping (`shape: set`) reads one file into several linked types: its `model` is the root
|
|
32
|
+
* part's type, and each of its `parts` names its own `model` (and may carry its own `keys_from` and
|
|
33
|
+
* `follow`). Each part is checked, and written in full, as a mapping's top level is; the rest of a
|
|
34
|
+
* set's rules are the backend's to judge.
|
|
35
|
+
*
|
|
31
36
|
* Mappings are editor-time only: they ride in `schema.json` as `_mappings` and never reach a page.
|
|
32
37
|
*
|
|
33
38
|
* @module
|
|
@@ -125,35 +130,57 @@ export function mappingProblems(decl, { types, names }) {
|
|
|
125
130
|
}
|
|
126
131
|
if (!('model' in decl)) {
|
|
127
132
|
found.push("`model` is missing: name the type the mapping translates, `model: '@/vehicle'`.")
|
|
128
|
-
}
|
|
129
|
-
|
|
133
|
+
}
|
|
134
|
+
found.push(...ruleProblems(decl, '', { types, names }))
|
|
135
|
+
if (Array.isArray(decl.parts)) {
|
|
136
|
+
for (const [i, part] of decl.parts.entries()) {
|
|
137
|
+
const at = `parts[${i}].`
|
|
138
|
+
if (!isMap(part)) continue
|
|
139
|
+
if (!('model' in part)) found.push(`\`${at}model\` is missing: name the type this part reads, \`model: '@/lesson'\`.`)
|
|
140
|
+
found.push(...ruleProblems(part, at, { types, names }))
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return found
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** The names one rule set gives — a mapping's top level, or one part of a `set` — checked. */
|
|
147
|
+
function ruleProblems(rules, at, { types, names }) {
|
|
148
|
+
const found = []
|
|
149
|
+
if ('model' in rules) {
|
|
150
|
+
const problem = refProblem(`${at}model`, rules.model, 'type')
|
|
130
151
|
if (problem) found.push(problem)
|
|
131
|
-
else if (
|
|
132
|
-
found.push(
|
|
152
|
+
else if (rules.model.startsWith('@/') && !types.has(rules.model)) {
|
|
153
|
+
found.push(`\`${at}model\` is \`${rules.model}\`, which is not one of the foundation's types (src/schemas/).`)
|
|
133
154
|
}
|
|
134
155
|
}
|
|
135
|
-
if ('keys_from' in
|
|
136
|
-
const problem = refProblem(
|
|
156
|
+
if ('keys_from' in rules) {
|
|
157
|
+
const problem = refProblem(`${at}keys_from`, rules.keys_from, 'mapping')
|
|
137
158
|
if (problem) found.push(problem)
|
|
138
|
-
else if (
|
|
139
|
-
found.push(
|
|
159
|
+
else if (rules.keys_from.startsWith('@/') && !names.has(rules.keys_from)) {
|
|
160
|
+
found.push(`\`${at}keys_from\` is \`${rules.keys_from}\`, which is not one of the foundation's mappings (src/${MAPPINGS_DIR}/).`)
|
|
140
161
|
}
|
|
141
162
|
}
|
|
142
|
-
found.push(...followProblems(
|
|
163
|
+
found.push(...followProblems(rules.follow, types, at))
|
|
143
164
|
return found
|
|
144
165
|
}
|
|
145
166
|
|
|
146
167
|
/**
|
|
147
168
|
* A mapping with every type and mapping it names in full (`scoped`: `@/x` → `@scope/x`): its `model`,
|
|
148
|
-
* its `keys_from` and a reverse `follow` line's `model
|
|
149
|
-
* is never touched.
|
|
169
|
+
* its `keys_from` and a reverse `follow` line's `model`, and the same in each of a `set`'s `parts`.
|
|
170
|
+
* Nothing else moves, and the file's own object is never touched.
|
|
150
171
|
*
|
|
151
172
|
* @param {object} decl - as written
|
|
152
173
|
* @param {(ref: string) => string} scoped
|
|
153
174
|
* @returns {object}
|
|
154
175
|
*/
|
|
155
176
|
export function mappingInFull(decl, scoped) {
|
|
156
|
-
const out =
|
|
177
|
+
const out = rulesInFull(decl, scoped)
|
|
178
|
+
if (Array.isArray(out.parts)) out.parts = out.parts.map((part) => (isMap(part) ? rulesInFull(part, scoped) : part))
|
|
179
|
+
return out
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function rulesInFull(rules, scoped) {
|
|
183
|
+
const out = { ...rules }
|
|
157
184
|
if (typeof out.model === 'string') out.model = scoped(out.model)
|
|
158
185
|
if (typeof out.keys_from === 'string') out.keys_from = scoped(out.keys_from)
|
|
159
186
|
if (Array.isArray(out.follow)) {
|
|
@@ -187,9 +214,10 @@ export function followModels(follow) {
|
|
|
187
214
|
return out
|
|
188
215
|
}
|
|
189
216
|
|
|
190
|
-
function followProblems(follow, types) {
|
|
217
|
+
function followProblems(follow, types, prefix = '') {
|
|
191
218
|
const found = []
|
|
192
|
-
for (const { at, spec } of followModels(follow)) {
|
|
219
|
+
for (const { at: where, spec } of followModels(follow)) {
|
|
220
|
+
const at = `${prefix}${where}`
|
|
193
221
|
const problem = refProblem(at, spec.model, 'type')
|
|
194
222
|
if (problem) found.push(problem)
|
|
195
223
|
else if (spec.model.startsWith('@/') && !types.has(spec.model)) {
|
|
@@ -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/blueprint.js
CHANGED
|
@@ -53,6 +53,8 @@ import { existsSync, readFileSync } from 'node:fs'
|
|
|
53
53
|
import { join, resolve } from 'node:path'
|
|
54
54
|
import yaml from 'js-yaml'
|
|
55
55
|
import { qualifyRef } from '@uniweb/schemas/refs'
|
|
56
|
+
import { dataRefOf } from '@uniweb/core/data-keys'
|
|
57
|
+
import { isBackendModel } from '../backend-models.js'
|
|
56
58
|
import { YAML_OPTIONS } from '../utils/yaml-schema.js'
|
|
57
59
|
import { unresolveSelfScope, bareOrg } from './self-scope.js'
|
|
58
60
|
import { writeYamlFile } from './project-writer.js'
|
|
@@ -440,6 +442,29 @@ function readSiteYml(siteRoot) {
|
|
|
440
442
|
}
|
|
441
443
|
}
|
|
442
444
|
|
|
445
|
+
/**
|
|
446
|
+
* The Models only a site backend holds (`@uniweb/catalog`) that a foundation's section types, layouts or
|
|
447
|
+
* main.js declare as data. Its `schema.json` carries no copy of one (`../backend-models.js`), so its
|
|
448
|
+
* data keys say it is a type the foundation renders, as a site backend counts it when it starts
|
|
449
|
+
* (backend, 2026-11-17: a blueprint line opening the catalog is applied once a foundation declares it).
|
|
450
|
+
*/
|
|
451
|
+
function backendModelsRendered(schema) {
|
|
452
|
+
const out = new Set()
|
|
453
|
+
const visit = (data) => {
|
|
454
|
+
if (!isMap(data)) return
|
|
455
|
+
for (const value of Object.values(data)) {
|
|
456
|
+
const { ref } = dataRefOf(value)
|
|
457
|
+
if (isBackendModel(ref)) out.add(ref)
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
for (const [key, entry] of Object.entries(schema || {})) {
|
|
461
|
+
if (key === '_self') visit(entry?.data)
|
|
462
|
+
else if (key === '_layouts' && isMap(entry)) for (const layout of Object.values(entry)) visit(layout?.data)
|
|
463
|
+
else if (key !== 'dataSchemas' && !key.startsWith('_')) visit(entry?.data)
|
|
464
|
+
}
|
|
465
|
+
return out
|
|
466
|
+
}
|
|
467
|
+
|
|
443
468
|
/**
|
|
444
469
|
* The types a site's foundations declare, each in full — the data schemas a backend started from the
|
|
445
470
|
* site installs: its foundation's and each extension's, the `dataSchemas` `register` registers.
|
|
@@ -477,6 +502,7 @@ export async function siteDeclaredTypes(siteRoot, siteYml, { scope = null, found
|
|
|
477
502
|
if (!schema) unread.push('its foundation could not be read')
|
|
478
503
|
else {
|
|
479
504
|
for (const ref of Object.keys(schema.dataSchemas || {})) types.add(qualifyRef(ref, scope))
|
|
505
|
+
for (const ref of backendModelsRendered(schema)) types.add(ref)
|
|
480
506
|
for (const ref of Object.keys(schema._mappings || {})) mappings.add(qualifyRef(ref, scope))
|
|
481
507
|
addVendors(schema, scope)
|
|
482
508
|
}
|
|
@@ -502,6 +528,7 @@ export async function siteDeclaredTypes(siteRoot, siteYml, { scope = null, found
|
|
|
502
528
|
}
|
|
503
529
|
types.add(qualifyRef(ref, extScope))
|
|
504
530
|
}
|
|
531
|
+
for (const ref of backendModelsRendered(schema)) types.add(ref)
|
|
505
532
|
for (const ref of Object.keys(schema._mappings || {})) mappings.add(qualifyRef(ref, extScope))
|
|
506
533
|
addVendors(schema, extScope)
|
|
507
534
|
}
|
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(
|
|
@@ -216,7 +216,7 @@ function buildDataSchemaEntities(dataSchemas, scope) {
|
|
|
216
216
|
* One `@uniweb/mapping-schema` entity per mapping the foundation defines (`schema._mappings`,
|
|
217
217
|
* `foundation/mappings.js`): its identity flat, as a data schema's is, and the rest of the file under
|
|
218
218
|
* `rules` — the envelope's `model:` names the exchange type, so the mapping's own `model:` cannot sit
|
|
219
|
-
* beside it. `rules.model`, `rules.keys_from` and a reverse `follow` line's `model` are named in
|
|
219
|
+
* beside it. `rules.model`, `rules.keys_from` and a reverse `follow` line's `model` (and the same in each of a `set`'s `parts`) are named in
|
|
220
220
|
* full; nothing else in `rules` is touched, since a backend judges it. A mapping another one names in `keys_from` comes first.
|
|
221
221
|
*
|
|
222
222
|
* @param {Object<string, object>} mappings - `{ '@/<name>': declaration }`
|