@vectoriahq/quac 0.23.0 → 0.25.0-next.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.
@@ -1,5 +1,5 @@
1
1
  import type { LayerLocks, PrintLayoutTemplate, FieldAttachment, FieldEditRule, LayerFormLayout, LayerScaleRange, ProjectMeasurement } from '../model/QgsProject.ts';
2
- import type { StacAsset, StacCatalog, StacCollection, StacExtent, StacLink, StacProvider, TableColumn, TableColumnValue, TableColumnValueRelation } from '../model/Stac.ts';
2
+ import type { StacAsset, StacCatalog, StacCollection, StacExtent, StacLink, StacProvider, TableColumn, TableColumnRuleLeftOut, TableColumnRelationReference, TableColumnValue, TableColumnValueRelation } from '../model/Stac.ts';
3
3
  /**
4
4
  * Source-agnostic intermediate model + the single STAC generator that
5
5
  * consumes it.
@@ -91,6 +91,8 @@ export declare const QUAC_PRINT_LAYOUTS_FIELD = "quac:print_layouts";
91
91
  export declare const QUAC_BRAND_COLOR_FIELD = "quac:brand_color";
92
92
  /** The key a top-level Catalog lists the source's layers left out of it under, each with its id, title and reason. */
93
93
  export declare const QUAC_LEFT_OUT_FIELD = "quac:left_out";
94
+ /** The top-level Catalog's field listing the logo variables that write no `icon` link, and why. */
95
+ export declare const QUAC_LOGO_LEFT_OUT_FIELD = "quac:logo_left_out";
94
96
  /** The key an `icon` link takes for the theme its image is for: `dark` for the logo shown in a dark theme. */
95
97
  export declare const QUAC_THEME_FIELD = "quac:theme";
96
98
  /**
@@ -363,6 +365,25 @@ export interface LeftOutLayer {
363
365
  * not know, is not read. Empty where the Catalog lists none.
364
366
  */
365
367
  export declare function readCatalogueLeftOut(catalog: StacCatalog): LeftOutLayer[];
368
+ /**
369
+ * Why a logo variable writes no `icon` link, as `quac:logo_left_out` gives it:
370
+ * its value does not end in a logo's file type (`not_an_image`), is an
371
+ * absolute path, a drive, a home folder or an address (`not_relative`), or
372
+ * leaves the project's folder (`outside_folder`); its file could not be read
373
+ * (`not_read`); or it is the dark logo, and no logo is linked (`no_logo`).
374
+ */
375
+ export type LogoLeftOutReason = 'not_an_image' | 'not_relative' | 'outside_folder' | 'not_read' | 'no_logo';
376
+ /** A logo variable `quac:logo_left_out` names, by the variable's name, never its value, and why it writes no link. */
377
+ export interface LogoLeftOut {
378
+ variable: 'quac_logo' | 'quac_logo_dark';
379
+ reason: LogoLeftOutReason;
380
+ }
381
+ /**
382
+ * The logo variables a top-level Catalog lists in `quac:logo_left_out`, in its
383
+ * order. An entry naming another variable, or a reason this package does not
384
+ * know, is not read. Empty where the Catalog lists none.
385
+ */
386
+ export declare function readCatalogueLogoLeftOut(catalog: StacCatalog): LogoLeftOut[];
366
387
  export declare function readCatalogueInitialView(catalog: StacCatalog): NormalizedBbox | null;
367
388
  /**
368
389
  * Reads shared source declarations back off a Collection.
@@ -380,6 +401,27 @@ export declare function readCollectionDisplayField(collection: StacCollection):
380
401
  * of any other shape, or a `table:columns` that is not a list, yields nothing.
381
402
  */
382
403
  export declare function declaredColumns(collection: StacCollection): Generator<[string, Record<string, unknown>]>;
404
+ /** The column field naming the QGIS Server services that hide a field. */
405
+ export declare const QUAC_QGIS_SERVER_HIDDEN_FIELD = "quac:qgis_server_hidden";
406
+ /** The column field listing a field's rules the catalogue leaves out. */
407
+ export declare const QUAC_RULES_LEFT_OUT_FIELD = "quac:rules_left_out";
408
+ /**
409
+ * The fields a Collection's columns hide from QGIS Server's WMS and from its
410
+ * WFS (`quac:qgis_server_hidden`), each in declared order. An application
411
+ * that serves the layer's features itself leaves these fields' values out of
412
+ * the same services. A service this package does not know is not read.
413
+ */
414
+ export declare function readCollectionServerHiddenFields(collection: StacCollection): {
415
+ wms: string[];
416
+ wfs: string[];
417
+ };
418
+ /**
419
+ * Each field's rules the catalogue leaves out (`quac:rules_left_out`), keyed
420
+ * by field name, in the column's order. An entry whose `rule` this package
421
+ * does not know is not read; a `text` that is not a string and a `strength`
422
+ * other than `enforced` or `warn` are left off. A field with none is absent.
423
+ */
424
+ export declare function readCollectionFieldRulesLeftOut(collection: StacCollection): Record<string, TableColumnRuleLeftOut[]>;
383
425
  /** Each field's alias, its column's `title`. A column with a blank or no `title` is absent. */
384
426
  export declare function readCollectionFieldAliases(collection: StacCollection): Record<string, string>;
385
427
  /** Each field's comment, its column's `description`, trimmed. A column with a blank or no `description` is absent. */
@@ -407,6 +449,13 @@ export declare function readCollectionFieldValues(collection: StacCollection): R
407
449
  * `order_field`, reads as ordered by key.
408
450
  */
409
451
  export declare function readCollectionFieldValueRelations(collection: StacCollection): Record<string, TableColumnValueRelation>;
452
+ /**
453
+ * Each column's `quac:relation_reference`, keyed by field name — the
454
+ * counterpart of the write in `stacCatalogue.ts`. A column declaring none is
455
+ * absent from the result, as is one naming no relation or a relation the
456
+ * Collection's `quac:related_to` does not declare.
457
+ */
458
+ export declare function readCollectionFieldRelationReferences(collection: StacCollection): Record<string, TableColumnRelationReference>;
410
459
  /**
411
460
  * The units a Collection's source measures in, or null where it names none or
412
461
  * names anything this does not read, which is read as QGIS's default of square
@@ -101,6 +101,8 @@ export const QUAC_PRINT_LAYOUTS_FIELD = 'quac:print_layouts';
101
101
  export const QUAC_BRAND_COLOR_FIELD = 'quac:brand_color';
102
102
  /** The key a top-level Catalog lists the source's layers left out of it under, each with its id, title and reason. */
103
103
  export const QUAC_LEFT_OUT_FIELD = 'quac:left_out';
104
+ /** The top-level Catalog's field listing the logo variables that write no `icon` link, and why. */
105
+ export const QUAC_LOGO_LEFT_OUT_FIELD = 'quac:logo_left_out';
104
106
  /** The key an `icon` link takes for the theme its image is for: `dark` for the logo shown in a dark theme. */
105
107
  export const QUAC_THEME_FIELD = 'quac:theme';
106
108
  /**
@@ -444,6 +446,25 @@ export function readCatalogueLeftOut(catalog) {
444
446
  : [];
445
447
  });
446
448
  }
449
+ const LOGO_LEFT_OUT_REASONS = new Set(['not_an_image', 'not_relative', 'outside_folder', 'not_read', 'no_logo']);
450
+ /**
451
+ * The logo variables a top-level Catalog lists in `quac:logo_left_out`, in its
452
+ * order. An entry naming another variable, or a reason this package does not
453
+ * know, is not read. Empty where the Catalog lists none.
454
+ */
455
+ export function readCatalogueLogoLeftOut(catalog) {
456
+ const value = catalog[QUAC_LOGO_LEFT_OUT_FIELD];
457
+ if (!Array.isArray(value))
458
+ return [];
459
+ return value.flatMap((entry) => {
460
+ if (!entry || typeof entry !== 'object')
461
+ return [];
462
+ const { variable, reason } = entry;
463
+ return (variable === 'quac_logo' || variable === 'quac_logo_dark') && typeof reason === 'string' && LOGO_LEFT_OUT_REASONS.has(reason)
464
+ ? [{ variable, reason: reason }]
465
+ : [];
466
+ });
467
+ }
447
468
  export function readCatalogueInitialView(catalog) {
448
469
  const value = catalog[INITIAL_VIEW_FIELD];
449
470
  if (!Array.isArray(value) || value.length !== 4)
@@ -486,6 +507,59 @@ export function* declaredColumns(collection) {
486
507
  yield [name, candidate];
487
508
  }
488
509
  }
510
+ /** The column field naming the QGIS Server services that hide a field. */
511
+ export const QUAC_QGIS_SERVER_HIDDEN_FIELD = 'quac:qgis_server_hidden';
512
+ /** The column field listing a field's rules the catalogue leaves out. */
513
+ export const QUAC_RULES_LEFT_OUT_FIELD = 'quac:rules_left_out';
514
+ /**
515
+ * The fields a Collection's columns hide from QGIS Server's WMS and from its
516
+ * WFS (`quac:qgis_server_hidden`), each in declared order. An application
517
+ * that serves the layer's features itself leaves these fields' values out of
518
+ * the same services. A service this package does not know is not read.
519
+ */
520
+ export function readCollectionServerHiddenFields(collection) {
521
+ const hidden = { wms: [], wfs: [] };
522
+ for (const [name, column] of declaredColumns(collection)) {
523
+ const services = column[QUAC_QGIS_SERVER_HIDDEN_FIELD];
524
+ if (!Array.isArray(services))
525
+ continue;
526
+ if (services.includes('wms'))
527
+ hidden.wms.push(name);
528
+ if (services.includes('wfs'))
529
+ hidden.wfs.push(name);
530
+ }
531
+ return hidden;
532
+ }
533
+ const RULE_LEFT_OUT_KINDS = new Set(['widget', 'default', 'constraint', 'value_relation']);
534
+ /**
535
+ * Each field's rules the catalogue leaves out (`quac:rules_left_out`), keyed
536
+ * by field name, in the column's order. An entry whose `rule` this package
537
+ * does not know is not read; a `text` that is not a string and a `strength`
538
+ * other than `enforced` or `warn` are left off. A field with none is absent.
539
+ */
540
+ export function readCollectionFieldRulesLeftOut(collection) {
541
+ const result = nameRecord();
542
+ for (const [name, column] of declaredColumns(collection)) {
543
+ const value = column[QUAC_RULES_LEFT_OUT_FIELD];
544
+ if (!Array.isArray(value))
545
+ continue;
546
+ const rules = value.flatMap((entry) => {
547
+ const candidate = readObject(entry);
548
+ const rule = candidate?.rule;
549
+ if (typeof rule !== 'string' || !RULE_LEFT_OUT_KINDS.has(rule))
550
+ return [];
551
+ const { text, strength } = candidate;
552
+ return [{
553
+ rule: rule,
554
+ ...(typeof text === 'string' && text !== '' ? { text } : {}),
555
+ ...(strength === 'enforced' || strength === 'warn' ? { strength } : {})
556
+ }];
557
+ });
558
+ if (rules.length > 0)
559
+ result[name] = rules;
560
+ }
561
+ return result;
562
+ }
489
563
  /** Each field's alias, its column's `title`. A column with a blank or no `title` is absent. */
490
564
  export function readCollectionFieldAliases(collection) {
491
565
  const aliases = nameRecord();
@@ -588,6 +662,31 @@ export function readCollectionFieldValueRelations(collection) {
588
662
  }
589
663
  return relations;
590
664
  }
665
+ /**
666
+ * Each column's `quac:relation_reference`, keyed by field name — the
667
+ * counterpart of the write in `stacCatalogue.ts`. A column declaring none is
668
+ * absent from the result, as is one naming no relation or a relation the
669
+ * Collection's `quac:related_to` does not declare.
670
+ */
671
+ export function readCollectionFieldRelationReferences(collection) {
672
+ const declaredRelations = new Set(readCollectionRelatedTo(collection).map((relation) => relation.id));
673
+ const references = nameRecord();
674
+ for (const [name, column] of declaredColumns(collection)) {
675
+ const entry = readObject(column['quac:relation_reference']);
676
+ if (!entry)
677
+ continue;
678
+ const relation = readTrimmedString(entry.relation);
679
+ if (!relation || !declaredRelations.has(relation))
680
+ continue;
681
+ const filter = readTrimmedString(entry.filter);
682
+ references[name] = {
683
+ relation,
684
+ ...(entry.allow_null === true ? { allow_null: true } : {}),
685
+ ...(filter ? { filter } : {})
686
+ };
687
+ }
688
+ return references;
689
+ }
591
690
  /**
592
691
  * The units a Collection's source measures in, or null where it names none or
593
692
  * names anything this does not read, which is read as QGIS's default of square
@@ -24,7 +24,8 @@ import type { StacCatalog, StacCollection } from '../model/Stac.ts';
24
24
  * the CRS `chooseWmsCrs` picks from `serverWmsCrsList`. No
25
25
  * file path, style asset, `via` link or detail of the layer's own data source
26
26
  * is written, nor an Attachment widget's default folder, nor the logo's
27
- * `icon` links, which name files beside the project.
27
+ * `icon` links, which name files beside the project, nor so
28
+ * `quac:logo_left_out`.
28
29
  * - A field the project hides from WMS or from WFS is left out of
29
30
  * `table:columns`, and every mention of it is dropped: from the form order,
30
31
  * the preset filters, the display field, a relation's join, and any
@@ -115,7 +116,12 @@ export interface HiddenFieldContext {
115
116
  * A lock whose expression uses one becomes `true`, and a field editable only
116
117
  * while such an expression holds becomes read-only, so that hiding a field
117
118
  * never unlocks an edit. A relation or Value Relation to a layer that is not
118
- * served is dropped, and one to a served layer names it by its served id. For
119
+ * served is dropped, and one to a served layer names it by its served id. A
120
+ * Relation Reference goes with its relation, or where its filter uses a
121
+ * hidden field. A column's default, constraint expression, Value Relation or
122
+ * Relation Reference dropped so is
123
+ * added to its `quac:rules_left_out`, and a rule already there loses an
124
+ * expression that names a hidden field. For
119
125
  * an application that serves a project's layers itself, as
120
126
  * `generateServerStacCatalogue` does for QGIS Server.
121
127
  */
@@ -1,4 +1,4 @@
1
- import { buildStacExtent, unionBboxes, withDataType, withFieldSize } from "./normalizedProject.js";
1
+ import { buildStacExtent, QUAC_LOGO_LEFT_OUT_FIELD, unionBboxes, withDataType, withFieldSize } from "./normalizedProject.js";
2
2
  import { serverLayerTree, wmsPublishedLayerIds } from "./serverLayerTree.js";
3
3
  import { generateStacCatalogue, QUAC_CATEGORISED_FIELD } from "./stacCatalogue.js";
4
4
  import { wfsGetFeatureAsset } from "./wfsStacCatalogue.js";
@@ -31,7 +31,8 @@ import { chooseWmsCrs, WEB_MAP_LINKS_EXTENSION, WMS_REQUEST_PARAMETERS } from ".
31
31
  * the CRS `chooseWmsCrs` picks from `serverWmsCrsList`. No
32
32
  * file path, style asset, `via` link or detail of the layer's own data source
33
33
  * is written, nor an Attachment widget's default folder, nor the logo's
34
- * `icon` links, which name files beside the project.
34
+ * `icon` links, which name files beside the project, nor so
35
+ * `quac:logo_left_out`.
35
36
  * - A field the project hides from WMS or from WFS is left out of
36
37
  * `table:columns`, and every mention of it is dropped: from the form order,
37
38
  * the preset filters, the display field, a relation's join, and any
@@ -91,6 +92,7 @@ export function generateServerStacCatalogue(project, options) {
91
92
  delete served.collections;
92
93
  delete served.catalogs;
93
94
  delete served.stac_extensions;
95
+ delete served[QUAC_LOGO_LEFT_OUT_FIELD];
94
96
  if (collections.length > 0)
95
97
  served.collections = collections;
96
98
  if (catalogs.length > 0)
@@ -224,7 +226,12 @@ function serveCollection(source, context) {
224
226
  * A lock whose expression uses one becomes `true`, and a field editable only
225
227
  * while such an expression holds becomes read-only, so that hiding a field
226
228
  * never unlocks an edit. A relation or Value Relation to a layer that is not
227
- * served is dropped, and one to a served layer names it by its served id. For
229
+ * served is dropped, and one to a served layer names it by its served id. A
230
+ * Relation Reference goes with its relation, or where its filter uses a
231
+ * hidden field. A column's default, constraint expression, Value Relation or
232
+ * Relation Reference dropped so is
233
+ * added to its `quac:rules_left_out`, and a rule already there loses an
234
+ * expression that names a hidden field. For
228
235
  * an application that serves a project's layers itself, as
229
236
  * `generateServerStacCatalogue` does for QGIS Server.
230
237
  */
@@ -237,7 +244,7 @@ export function withoutHiddenFields(source, layerId, context) {
237
244
  serveFilters(collection, hidden);
238
245
  serveRelations(collection, hidden, context);
239
246
  serveLocks(collection, hidden);
240
- serveColumns(collection, hidden, context);
247
+ serveColumns(collection, hidden, context, servedRelationParents(source, collection));
241
248
  serveStyleFields(collection, hidden);
242
249
  return collection;
243
250
  }
@@ -284,13 +291,30 @@ function serveLocks(collection, hidden) {
284
291
  }
285
292
  collection['quac:locks'] = served;
286
293
  }
287
- function serveColumns(collection, hidden, context) {
294
+ /**
295
+ * Each relation `serveRelations` kept, by id, with its parent's id in the
296
+ * source catalogue, where that parent's hidden fields are read.
297
+ */
298
+ function servedRelationParents(source, served) {
299
+ const keptIds = new Set(Array.isArray(served['quac:related_to'])
300
+ ? served['quac:related_to'].map((relation) => relation.id)
301
+ : []);
302
+ const parents = new Map();
303
+ if (!Array.isArray(source['quac:related_to']))
304
+ return parents;
305
+ for (const relation of source['quac:related_to']) {
306
+ if (keptIds.has(relation.id))
307
+ parents.set(relation.id, relation.parent_collection_id);
308
+ }
309
+ return parents;
310
+ }
311
+ function serveColumns(collection, hidden, context, servedRelations) {
288
312
  const columns = collection['table:columns'];
289
313
  if (!Array.isArray(columns))
290
314
  return;
291
315
  const kept = columns
292
316
  .filter((column) => !hidden.has(column.name))
293
- .map((column) => serveColumn(column, hidden, context));
317
+ .map((column) => serveColumn(column, hidden, context, servedRelations));
294
318
  if (kept.length > 0)
295
319
  collection['table:columns'] = kept;
296
320
  else
@@ -362,7 +386,7 @@ function withFieldType(column, fieldType, projectComments) {
362
386
  sized['quac:filled_by_data'] = true;
363
387
  return sized;
364
388
  }
365
- function serveColumn(source, hidden, context) {
389
+ function serveColumn(source, hidden, context, servedRelations) {
366
390
  const column = { ...source };
367
391
  const visibleWhen = column['quac:visible_when'];
368
392
  if (Array.isArray(visibleWhen)) {
@@ -385,17 +409,31 @@ function serveColumn(source, hidden, context) {
385
409
  delete served.default_root;
386
410
  column['quac:attachment'] = served;
387
411
  }
412
+ // A rule left out already keeps its kind, but not an expression that names a hidden field.
413
+ const leftOut = Array.isArray(column['quac:rules_left_out'])
414
+ ? column['quac:rules_left_out'].map((rule) => {
415
+ if (rule.rule === 'widget' || !mentionsAny(rule.text, hidden))
416
+ return rule;
417
+ const kept = { ...rule };
418
+ delete kept.text;
419
+ return kept;
420
+ })
421
+ : [];
388
422
  const fieldDefault = column['quac:default'];
389
- if (fieldDefault?.kind === 'expression' && mentionsAny(fieldDefault.expression, hidden))
423
+ if (fieldDefault?.kind === 'expression' && mentionsAny(fieldDefault.expression, hidden)) {
390
424
  delete column['quac:default'];
425
+ leftOut.push({ rule: 'default' });
426
+ }
391
427
  const constraints = column['quac:constraints'];
392
- if (constraints && mentionsAny(constraints.expression?.expression, hidden)) {
428
+ const constraintExpression = constraints?.expression;
429
+ if (constraints && mentionsAny(constraintExpression?.expression, hidden)) {
393
430
  const rest = { ...constraints };
394
431
  delete rest.expression;
395
432
  if (Object.keys(rest).length > 0)
396
433
  column['quac:constraints'] = rest;
397
434
  else
398
435
  delete column['quac:constraints'];
436
+ leftOut.push({ rule: 'constraint', ...(constraintExpression?.strength ? { strength: constraintExpression.strength } : {}) });
399
437
  }
400
438
  const relation = column['quac:value_relation'];
401
439
  if (relation) {
@@ -404,10 +442,23 @@ function serveColumn(source, hidden, context) {
404
442
  const usesHidden = [relation.key, relation.value, relation.order_field].some((field) => field !== undefined && lookupHidden.has(field))
405
443
  || mentionsAny(relation.filter, lookupHidden)
406
444
  || mentionsAny(relation.filter, hidden);
407
- if (!lookupId || usesHidden)
445
+ if (!lookupId || usesHidden) {
408
446
  delete column['quac:value_relation'];
447
+ leftOut.push({ rule: 'value_relation' });
448
+ }
409
449
  else
410
450
  column['quac:value_relation'] = { ...relation, collection: lookupId };
411
451
  }
452
+ const reference = column['quac:relation_reference'];
453
+ if (reference) {
454
+ const parentId = servedRelations.get(reference.relation);
455
+ const parentHidden = parentId === undefined ? new Set() : context.hiddenOf(parentId);
456
+ if (parentId === undefined || mentionsAny(reference.filter, parentHidden) || mentionsAny(reference.filter, hidden)) {
457
+ delete column['quac:relation_reference'];
458
+ leftOut.push({ rule: 'widget', text: 'RelationReference' });
459
+ }
460
+ }
461
+ if (leftOut.length > 0)
462
+ column['quac:rules_left_out'] = leftOut;
412
463
  return column;
413
464
  }
@@ -1,5 +1,5 @@
1
1
  import { arcgisQueryAsset } from "./arcgisStacCatalogue.js";
2
- import { QUAC_BRAND_COLOR_FIELD, QUAC_THEME_FIELD, QUAC_MEASUREMENT_FIELD, QUAC_PRINT_LAYOUTS_FIELD, slugify, generateStacFromNormalized, unionBboxes, withSelfLink } from "./normalizedProject.js";
2
+ import { QUAC_BRAND_COLOR_FIELD, QUAC_THEME_FIELD, QUAC_MEASUREMENT_FIELD, QUAC_LOGO_LEFT_OUT_FIELD, QUAC_PRINT_LAYOUTS_FIELD, slugify, generateStacFromNormalized, unionBboxes, withSelfLink } from "./normalizedProject.js";
3
3
  import { wfsGetFeatureAsset } from "./wfsStacCatalogue.js";
4
4
  import { delimitedTextField, QUAC_DELIMITED_TEXT } from "../model/delimitedText.js";
5
5
  import { featureFilterField, QUAC_FEATURE_FILTER } from "../model/featureFilter.js";
@@ -13,7 +13,7 @@ import { buildXyzLink } from "../model/stacXyz.js";
13
13
  import { brandColorOf } from "../parse/parseBrandColour.js";
14
14
  import { safeName } from "./splitCatalogue.js";
15
15
  import { findGeometrySiblings, readSiblingShapes, siblingCollectionId } from "../parse/geometrySiblings.js";
16
- import { findValueRelationLookup, isFilterInProject, isRelationInProject } from "../parse/projectNotes.js";
16
+ import { findRelationReferenceRelation, findValueRelationLookup, isFilterInProject, isRelationInProject } from "../parse/projectNotes.js";
17
17
  import { declaredMediaTypeForFile, isLayerFileOfFormat, PROJECT_DATA_ROLES, QML_STYLE_MEDIA_TYPE } from "../util/catalogueFileFormats.js";
18
18
  import { nameRecord } from "../util/nameRecord.js";
19
19
  /**
@@ -147,6 +147,7 @@ function qgsProjectToNormalized(project, companions, projectPath, projectFileNam
147
147
  styleFiles,
148
148
  relationsByChildLayerId: collectRelationsByChildLayerId(project.relations ?? [], layersById, collectionIdOf),
149
149
  valueRelationsByLayerId: collectValueRelationsByLayerId(project.layers, layersById, collectionIdOf),
150
+ relationReferencesByLayerId: collectRelationReferencesByLayerId(project.layers, project.relations ?? [], layersById),
150
151
  siblingsById,
151
152
  measurement: project.measurement ?? null,
152
153
  wfsTransactionLayers: project.wfsTransactionLayers ?? null,
@@ -178,6 +179,7 @@ function qgsProjectToNormalized(project, companions, projectPath, projectFileNam
178
179
  // Where the map *opens* is a different fact, and is only true of a project
179
180
  // whose author saved a canvas position, so it goes in its own field below
180
181
  // and is absent from a project that declares none.
182
+ const logos = projectLogos(project.variables ?? {});
181
183
  return {
182
184
  id: slugify(project.title || 'qgs-project') || 'qgs-project',
183
185
  title: project.title,
@@ -190,13 +192,13 @@ function qgsProjectToNormalized(project, companions, projectPath, projectFileNam
190
192
  activeCollectionId: project.initialActiveLayerId && layersById.has(project.initialActiveLayerId)
191
193
  ? collectionIdOf(project.initialActiveLayerId)
192
194
  : null,
193
- vendorFields: projectVendorFields(project),
194
- links: projectLogoLinks(project.variables ?? {}),
195
+ vendorFields: projectVendorFields(project, logos.leftOut),
196
+ links: logos.links,
195
197
  nodes
196
198
  };
197
199
  }
198
- /** The top-level Catalog's fields the project sets: its print layouts and its Brand colour. */
199
- function projectVendorFields(project) {
200
+ /** The top-level Catalog's fields the project sets: its print layouts, its Brand colour and the logos it leaves out. */
201
+ function projectVendorFields(project, logosLeftOut) {
200
202
  const fields = {};
201
203
  if (project.printLayouts && project.printLayouts.length > 0) {
202
204
  fields[QUAC_PRINT_LAYOUTS_FIELD] = project.printLayouts.map(({ name, template }) => ({ name, template }));
@@ -204,6 +206,8 @@ function projectVendorFields(project) {
204
206
  const brandColor = brandColorOf(project.brandColour);
205
207
  if (brandColor)
206
208
  fields[QUAC_BRAND_COLOR_FIELD] = brandColor;
209
+ if (logosLeftOut.length > 0)
210
+ fields[QUAC_LOGO_LEFT_OUT_FIELD] = logosLeftOut;
207
211
  return Object.keys(fields).length > 0 ? fields : undefined;
208
212
  }
209
213
  /** The project variables naming the map's logo, and the logo shown in a dark theme. */
@@ -224,19 +228,50 @@ const LOGO_MEDIA_TYPES = {
224
228
  * project, which the link gives as a data asset's href gives its file. A
225
229
  * value that is not such a path, such as an absolute path or an address,
226
230
  * leaves the folder, or does not end in a logo's extension, writes nothing,
227
- * and a dark logo is written only beside a logo.
231
+ * and a dark logo is written only beside a logo. Each variable set that
232
+ * writes no link is in `leftOut`, with why, as `quac:logo_left_out` lists it.
228
233
  */
229
- function projectLogoLinks(variables) {
234
+ function projectLogos(variables) {
235
+ const links = [];
236
+ const leftOut = [];
230
237
  const light = logoLink(variables[LOGO_VARIABLE]);
231
- if (!light)
232
- return [];
238
+ if (typeof light === 'string')
239
+ leftOut.push({ variable: LOGO_VARIABLE, reason: light });
240
+ else if (light)
241
+ links.push(light);
233
242
  const dark = logoLink(variables[LOGO_DARK_VARIABLE]);
234
- return dark ? [light, { ...dark, title: 'Logo for a dark theme', [QUAC_THEME_FIELD]: 'dark' }] : [light];
243
+ if (typeof dark === 'string')
244
+ leftOut.push({ variable: LOGO_DARK_VARIABLE, reason: dark });
245
+ else if (dark && links.length === 0)
246
+ leftOut.push({ variable: LOGO_DARK_VARIABLE, reason: 'no_logo' });
247
+ else if (dark)
248
+ links.push({ ...dark, title: 'Logo for a dark theme', [QUAC_THEME_FIELD]: 'dark' });
249
+ return { links, leftOut };
235
250
  }
251
+ /** A logo variable's link, why it writes none, or null where the variable is unset or blank. */
236
252
  function logoLink(value) {
237
- const path = projectRelativeFile(value ?? '');
253
+ const text = (value ?? '').trim();
254
+ if (!text)
255
+ return null;
256
+ if (!isProjectRelativeFolder(text))
257
+ return 'not_relative';
258
+ if (leavesFolder(text))
259
+ return 'outside_folder';
260
+ const path = projectRelativeFile(text);
238
261
  const mediaType = path ? LOGO_MEDIA_TYPES[path.slice(path.lastIndexOf('.') + 1).toLowerCase()] : undefined;
239
- return path && mediaType ? { rel: 'icon', href: `./${encodeAssetPath(path)}`, type: mediaType, title: 'Logo' } : null;
262
+ return path && mediaType ? { rel: 'icon', href: `./${encodeAssetPath(path)}`, type: mediaType, title: 'Logo' } : 'not_an_image';
263
+ }
264
+ /** Whether a relative path's `..` names climb above the folder it starts in. */
265
+ function leavesFolder(text) {
266
+ let depth = 0;
267
+ for (const name of text.split(/[\\/]/)) {
268
+ if (name === '' || name === '.')
269
+ continue;
270
+ depth += name === '..' ? -1 : 1;
271
+ if (depth < 0)
272
+ return true;
273
+ }
274
+ return false;
240
275
  }
241
276
  /**
242
277
  * A path relative to the project and inside its folder, with `/` between its
@@ -325,6 +360,35 @@ function collectValueRelationsByLayerId(layers, layersById, collectionIdOf) {
325
360
  }
326
361
  return byLayerId;
327
362
  }
363
+ /**
364
+ * Each layer's Relation Reference widgets as `quac:relation_reference`
365
+ * writes them, keyed by layer id and then field name. The relation is found
366
+ * as `findRelationReferenceRelation` finds it; a widget with none writes
367
+ * nothing. Where the widget does not say whether a blank is allowed, one is
368
+ * allowed unless a field the relation joins must not be blank, as QGIS
369
+ * decides (`QgsRelation::referencingFieldsAllowNull`,
370
+ * `src/core/qgsrelation.cpp`, `qgis/QGIS@release-3_40`).
371
+ */
372
+ function collectRelationReferencesByLayerId(layers, relations, layersById) {
373
+ const byLayerId = new Map();
374
+ for (const layer of layers) {
375
+ const references = nameRecord();
376
+ for (const [field, widget] of Object.entries(layer.fieldRelationReferences ?? {})) {
377
+ const relation = findRelationReferenceRelation(layer.id, field, widget, relations, layersById);
378
+ if (!relation)
379
+ continue;
380
+ const allowNull = widget.allowNull ?? relation.fieldPairs.every((pair) => !layer.fieldEditRules[pair.childField]?.notNull);
381
+ references[field] = {
382
+ relation: relation.id,
383
+ ...(allowNull ? { allow_null: true } : {}),
384
+ ...(widget.filterExpression ? { filter: widget.filterExpression } : {})
385
+ };
386
+ }
387
+ if (Object.keys(references).length > 0)
388
+ byLayerId.set(layer.id, references);
389
+ }
390
+ return byLayerId;
391
+ }
328
392
  /** A Value Relation widget as `quac:value_relation` stores it: a member at its default is left off. */
329
393
  function valueRelationToJson(collectionId, widget) {
330
394
  return {
@@ -491,6 +555,7 @@ function qgsLayerToNormalized(layer, context, geometryFilter = geometryFilterOf(
491
555
  const { layerWgs84Extents } = context;
492
556
  const relatedTo = context.relationsByChildLayerId.get(layer.id);
493
557
  const valueRelations = context.valueRelationsByLayerId.get(layer.id);
558
+ const relationReferences = context.relationReferencesByLayerId.get(layer.id);
494
559
  const bbox = effectiveWgs84Bbox(layer, layerWgs84Extents);
495
560
  const metadata = layer.resourceMetadata;
496
561
  const ds = layer.dataSource;
@@ -505,7 +570,7 @@ function qgsLayerToNormalized(layer, context, geometryFilter = geometryFilterOf(
505
570
  geometryType: layer.geometryType,
506
571
  wkbTypes: layer.wkbType ? [layer.wkbType] : [],
507
572
  qgisServerNames: qgisServerNamesOf(layer, context),
508
- tableColumns: deriveTableColumns(geojson, layer.fieldNames, layer.fieldAliases, layer.fieldValueMaps, layer.fieldAttachments, layer.fieldEditRules, valueRelations, layer.formLayout ?? null, layer.fieldIcons, layer.fieldControls, layer.fieldComments),
573
+ tableColumns: deriveTableColumns(geojson, layer.fieldNames, layer.fieldAliases, layer.fieldValueMaps, layer.fieldAttachments, layer.fieldEditRules, valueRelations, layer.formLayout ?? null, layer.fieldIcons, layer.fieldControls, layer.fieldComments, layer.serverHiddenFields, fieldRulesLeftOutOf(layer, valueRelations, relationReferences), relationReferences),
509
574
  formOrder: layer.formLayout?.fields.map((field) => field.name),
510
575
  assets: buildLayerAssets(layer, context, geometryFilter, styleParts),
511
576
  keywords: metadata.keywords.length > 0 ? metadata.keywords : undefined,
@@ -880,6 +945,10 @@ function unionExtent(layers, layerWgs84Extents) {
880
945
  * - **quac:value_relation**
881
946
  * the Collection a field's choices are read from, when
882
947
  * QGIS's Value Relation edit widget names one the project holds
948
+ * - **quac:relation_reference**
949
+ * the relation whose parent features fill the field, when
950
+ * QGIS's Relation Reference edit widget joins it to a parent
951
+ * the project holds
883
952
  * - **quac:attachment**
884
953
  * that the field holds a file's path, when QGIS's
885
954
  * Attachment edit widget declares one
@@ -912,7 +981,7 @@ function unionExtent(layers, layerWgs84Extents) {
912
981
  * exist": this means a hidden WFS layer's schema is fully visible to the
913
982
  * dev panel and to STAC clients before any data is fetched.
914
983
  */
915
- function deriveTableColumns(geojson, fieldNames, fieldAliases, fieldValueMaps = nameRecord(), fieldAttachments = nameRecord(), fieldEditRules = nameRecord(), fieldValueRelations = nameRecord(), formLayout = null, fieldIcons = nameRecord(), fieldControls = nameRecord(), fieldComments = nameRecord()) {
984
+ function deriveTableColumns(geojson, fieldNames, fieldAliases, fieldValueMaps = nameRecord(), fieldAttachments = nameRecord(), fieldEditRules = nameRecord(), fieldValueRelations = nameRecord(), formLayout = null, fieldIcons = nameRecord(), fieldControls = nameRecord(), fieldComments = nameRecord(), serverHiddenFields = undefined, fieldRulesLeftOut = nameRecord(), fieldRelationReferences = nameRecord()) {
916
985
  const observedTypes = new Map();
917
986
  const orderedFieldNames = [];
918
987
  const seen = new Set();
@@ -962,6 +1031,9 @@ function deriveTableColumns(geojson, fieldNames, fieldAliases, fieldValueMaps =
962
1031
  const valueRelation = fieldValueRelations[name];
963
1032
  if (valueRelation)
964
1033
  column['quac:value_relation'] = valueRelation;
1034
+ const relationReference = fieldRelationReferences[name];
1035
+ if (relationReference)
1036
+ column['quac:relation_reference'] = relationReference;
965
1037
  const attachment = fieldAttachments[name];
966
1038
  if (attachment)
967
1039
  column['quac:attachment'] = attachmentToJson(attachment);
@@ -1021,9 +1093,50 @@ function deriveTableColumns(geojson, fieldNames, fieldAliases, fieldValueMaps =
1021
1093
  if (placed?.editableWhen)
1022
1094
  column['quac:editable_when'] = placed.editableWhen;
1023
1095
  }
1096
+ const hiddenFrom = [];
1097
+ if (serverHiddenFields?.wms.includes(name))
1098
+ hiddenFrom.push('wms');
1099
+ if (serverHiddenFields?.wfs.includes(name))
1100
+ hiddenFrom.push('wfs');
1101
+ if (hiddenFrom.length > 0)
1102
+ column['quac:qgis_server_hidden'] = hiddenFrom;
1103
+ const leftOut = fieldRulesLeftOut[name];
1104
+ if (leftOut?.length)
1105
+ column['quac:rules_left_out'] = leftOut.map(ruleLeftOutToJson);
1024
1106
  return column;
1025
1107
  });
1026
1108
  }
1109
+ /**
1110
+ * A layer's field rules its Collection leaves out: those its parsing left out
1111
+ * (`fieldRulesLeftOut`), then each Value Relation whose lookup layer is not
1112
+ * in the catalogue, which `quac:value_relation` therefore does not name, then
1113
+ * each Relation Reference with no relation, as a widget left out. The
1114
+ * lookup is not named either: it may be a layer the project leaves out of WMS.
1115
+ */
1116
+ function fieldRulesLeftOutOf(layer, valueRelations, relationReferences) {
1117
+ const leftOut = nameRecord();
1118
+ for (const [field, rules] of Object.entries(layer.fieldRulesLeftOut ?? {}))
1119
+ leftOut[field] = [...rules];
1120
+ for (const field of Object.keys(layer.fieldValueRelations)) {
1121
+ if (valueRelations?.[field])
1122
+ continue;
1123
+ (leftOut[field] ??= []).push({ rule: 'value_relation', text: null });
1124
+ }
1125
+ for (const field of Object.keys(layer.fieldRelationReferences ?? {})) {
1126
+ if (relationReferences?.[field])
1127
+ continue;
1128
+ (leftOut[field] ??= []).push({ rule: 'widget', text: 'RelationReference' });
1129
+ }
1130
+ return leftOut;
1131
+ }
1132
+ /** A left-out field rule as `quac:rules_left_out` stores it: a blank text is left off. */
1133
+ function ruleLeftOutToJson(rule) {
1134
+ return {
1135
+ rule: rule.rule,
1136
+ ...(rule.text ? { text: rule.text } : {}),
1137
+ ...(rule.strength ? { strength: rule.strength } : {})
1138
+ };
1139
+ }
1027
1140
  /** A field's constraint expression as `quac:constraints` stores it: a description the source left blank is left off. */
1028
1141
  function constraintExpressionToJson(constraint) {
1029
1142
  return {
@@ -21,12 +21,20 @@ export type NewFeatureProblem = 'unknown-field' | 'not-fillable' | 'required' |
21
21
  * - `visible-when` / `editable-when`: an expression that hides or locks the
22
22
  * field in the form, so whether it is filled in depends on the other values;
23
23
  * - `value-relation`: its choices are another layer's records;
24
+ * - `relation-reference`: it holds a parent feature's key, which only the
25
+ * parent layer's features can check;
24
26
  * - `unique`: an enforced Unique constraint, which needs the layer's other features;
25
27
  * - `date-format`: it stores dates in a format of its own;
26
28
  * - `attachment`: it holds a file's path, and the file is not part of the feature;
27
- * - `type`: its type is one this does not know.
29
+ * - `type`: its type is one this does not know;
30
+ * - `widget`: the catalogue leaves out its edit widget (`quac:rules_left_out`),
31
+ * which may restrict its values;
32
+ * - `left-out`: the catalogue leaves out a rule of a kind this does not know.
33
+ *
34
+ * A constraint expression or Value Relation the catalogue leaves out is
35
+ * `constraint-expression` or `value-relation`, as one it carries is.
28
36
  */
29
- export type UncheckedFieldRule = 'constraint-expression' | 'visible-when' | 'editable-when' | 'value-relation' | 'unique' | 'date-format' | 'attachment' | 'type';
37
+ export type UncheckedFieldRule = 'constraint-expression' | 'visible-when' | 'editable-when' | 'value-relation' | 'relation-reference' | 'unique' | 'date-format' | 'attachment' | 'type' | 'widget' | 'left-out';
30
38
  export interface NewFeatureCheck {
31
39
  /** The fields refused, in the layer's field order, then the fields the layer does not have. */
32
40
  problems: {
@@ -53,10 +61,11 @@ type Properties = Readonly<Record<string, unknown>>;
53
61
  * Checkbox spelling, and its range. A rule that needs more than the Collection
54
62
  * to check is listed in `unchecked`, not passed.
55
63
  *
56
- * It checks only what the Collection carries. A catalogue generated from a
57
- * QGIS project leaves out a setting it cannot read, such as a constraint
58
- * expression `readQgisExpression` cannot read, and lists it in the project's
59
- * `notes`, which a caller reads as well.
64
+ * It checks only what the Collection carries. A rule the catalogue leaves
65
+ * out, such as a constraint expression `readQgisExpression` cannot read, is
66
+ * listed in the column's `quac:rules_left_out`, and so in `unchecked`, apart
67
+ * from a default value, which this does not fill: a caller that fills
68
+ * defaults reads `quac:rules_left_out` itself.
60
69
  *
61
70
  * A Collection that declares no fields refuses every value. A warning
62
71
  * (`warn`) constraint refuses nothing, as QGIS saves past it. Values are
@@ -8,10 +8,11 @@ import { declaredColumns, readCollectionFieldEditRules, readCollectionFieldTypes
8
8
  * Checkbox spelling, and its range. A rule that needs more than the Collection
9
9
  * to check is listed in `unchecked`, not passed.
10
10
  *
11
- * It checks only what the Collection carries. A catalogue generated from a
12
- * QGIS project leaves out a setting it cannot read, such as a constraint
13
- * expression `readQgisExpression` cannot read, and lists it in the project's
14
- * `notes`, which a caller reads as well.
11
+ * It checks only what the Collection carries. A rule the catalogue leaves
12
+ * out, such as a constraint expression `readQgisExpression` cannot read, is
13
+ * listed in the column's `quac:rules_left_out`, and so in `unchecked`, apart
14
+ * from a default value, which this does not fill: a caller that fills
15
+ * defaults reads `quac:rules_left_out` itself.
15
16
  *
16
17
  * A Collection that declares no fields refuses every value. A warning
17
18
  * (`warn`) constraint refuses nothing, as QGIS saves past it. Values are
@@ -106,6 +107,30 @@ export function newQgisUuid(format) {
106
107
  const KNOWN_TYPES = new Set(['string', 'int', 'long', 'double', 'boolean', 'date', 'time', 'timestamp']);
107
108
  const DATE_TYPES = new Set(['date', 'time', 'timestamp']);
108
109
  function uncheckedRules(column, type, unique, dateFormat) {
110
+ const found = new Set();
111
+ for (const rule of uncheckedColumnRules(column, type, unique, dateFormat))
112
+ found.add(rule);
113
+ for (const rule of leftOutRules(column))
114
+ found.add(rule);
115
+ return Array.from(found);
116
+ }
117
+ /** The unchecked rules a column's `quac:rules_left_out` gives: every entry but a default and a constraint that only warns. */
118
+ function leftOutRules(column) {
119
+ const value = column['quac:rules_left_out'];
120
+ if (!Array.isArray(value))
121
+ return [];
122
+ return value.flatMap((entry) => {
123
+ const { rule, strength } = entry && typeof entry === 'object' ? entry : {};
124
+ switch (rule) {
125
+ case 'default': return [];
126
+ case 'constraint': return strength === 'warn' ? [] : ['constraint-expression'];
127
+ case 'value_relation': return ['value-relation'];
128
+ case 'widget': return ['widget'];
129
+ default: return ['left-out'];
130
+ }
131
+ });
132
+ }
133
+ function uncheckedColumnRules(column, type, unique, dateFormat) {
109
134
  const found = [];
110
135
  const constraints = column['quac:constraints'];
111
136
  const expression = constraints && typeof constraints === 'object' ? constraints.expression : undefined;
@@ -118,6 +143,8 @@ function uncheckedRules(column, type, unique, dateFormat) {
118
143
  found.push('editable-when');
119
144
  if (column['quac:value_relation'])
120
145
  found.push('value-relation');
146
+ if (column['quac:relation_reference'])
147
+ found.push('relation-reference');
121
148
  if (unique)
122
149
  found.push('unique');
123
150
  if (dateFormat)
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  * `@vectoriahq/quac`.
4
4
  */
5
5
  export type { QgsProject, ProjectMetadata, MapExtent, BoundingBox, LayerEntry, EditLock, LayerLocks, LockedEdit, ProjectMeasurement, LayerStyle, LayerResourceMetadata, LayerScaleRange, LayerContact, LayerAttribution, FieldAttachment, FieldCheckbox, FieldConstraintExpression, FieldDefaultExpression, FieldDefaultValue, FieldEditRule, FormLayoutField, LayerFormLayout, FieldFixedValue, FieldRange, FieldUuidFormat, FieldValueMapEntry, DataSource, FileDataSource, WfsDataSource, WmsDataSource, UnsupportedDataSource, LayerTreeNode, LayerGroup, LayerTreeLeaf, QgsRelation, QgsRelationFieldPair, ProjectNote, ProjectNoteReason } from './model/QgsProject.ts';
6
- export type { StacCatalog, StacCollection, StacItem, StacAsset, StacExtent, StacLink, StacObject, StacProvider, TableColumn, TableColumnType, TableColumnValue, TableColumnValueRelation, TableColumnAttachment, TableColumnCheckbox, TableColumnRange } from './model/Stac.ts';
6
+ export type { StacCatalog, StacCollection, StacItem, StacAsset, StacExtent, StacLink, StacObject, StacProvider, TableColumn, TableColumnType, TableColumnValue, TableColumnRelationReference, TableColumnValueRelation, TableColumnRuleLeftOut, TableColumnServerService, TableColumnAttachment, TableColumnCheckbox, TableColumnRange } from './model/Stac.ts';
7
7
  export { STAC_VERSION } from './model/Stac.ts';
8
8
  export { isIconLibraryAddress, resolveFieldIconAddress } from './model/fieldIconAddress.ts';
9
9
  export { collectCollectionStyles, getDefaultStyle, styleAssetKey, GL_STYLE_MEDIA_TYPE } from './model/stacStyles.ts';
@@ -37,8 +37,8 @@ export { FILE_EXTENSION, FILE_SIZE_FIELD, TABLE_ROW_COUNT_FIELD, readCollectionR
37
37
  export { PMTILES_MEDIA_TYPE, VISUAL_ROLE, readCollectionPmtiles } from './model/stacPmtiles.ts';
38
38
  export type { StacPmtilesSource } from './model/stacPmtiles.ts';
39
39
  export type { StacCompanionData } from './generate/stacCatalogue.ts';
40
- export { QUAC_ACTIVE_COLLECTION_FIELD, QUAC_FILTERS_FIELD, QUAC_FORM_ORDER_FIELD, QUAC_LOCKS_FIELD, QUAC_MUTUALLY_EXCLUSIVE_FIELD, QUAC_PRIVATE_FIELD, readCatalogueActiveCollection, readCatalogueInitialView, readCataloguePrintLayouts, readCatalogueBrandColor, readCatalogueLogos, readCatalogueLeftOut, readCollectionDisplayField, readCollectionEditable, readCollectionFieldAliases, readCollectionFieldComments, readCollectionFieldAttachments, readCollectionFieldEditRules, readCollectionFieldNames, readCollectionFieldTypes, readCollectionFieldValueRelations, readCollectionFieldValues, readCollectionFormLayout, readCollectionGeometryType, readCollectionGeometryTypes, readCollectionIdentifiable, readCollectionMeasurement, readCollectionOpacity, readCollectionIcon, readCollectionAddedMessage, readCollectionMapTip, readCollectionLegendImage, readCollectionFilters, readCollectionLocks, readCollectionPrivate, readCollectionRelatedTo, readCollectionScaleRange, readCollectionVisibility, statedOpacity } from './generate/normalizedProject.ts';
41
- export type { CatalogueLogo, LeftOutLayer, LeftOutReason, CollectionFilter, CollectionFormLayout, CollectionRelation, CollectionRelationField } from './generate/normalizedProject.ts';
40
+ export { QUAC_ACTIVE_COLLECTION_FIELD, QUAC_FILTERS_FIELD, QUAC_FORM_ORDER_FIELD, QUAC_LOCKS_FIELD, QUAC_MUTUALLY_EXCLUSIVE_FIELD, QUAC_PRIVATE_FIELD, readCatalogueActiveCollection, readCatalogueInitialView, readCataloguePrintLayouts, readCatalogueBrandColor, readCatalogueLogos, readCatalogueLeftOut, readCatalogueLogoLeftOut, QUAC_LOGO_LEFT_OUT_FIELD, readCollectionDisplayField, readCollectionEditable, readCollectionFieldAliases, readCollectionFieldComments, readCollectionFieldAttachments, readCollectionFieldEditRules, readCollectionFieldNames, readCollectionFieldRulesLeftOut, readCollectionServerHiddenFields, QUAC_QGIS_SERVER_HIDDEN_FIELD, QUAC_RULES_LEFT_OUT_FIELD, readCollectionFieldTypes, readCollectionFieldValueRelations, readCollectionFieldRelationReferences, readCollectionFieldValues, readCollectionFormLayout, readCollectionGeometryType, readCollectionGeometryTypes, readCollectionIdentifiable, readCollectionMeasurement, readCollectionOpacity, readCollectionIcon, readCollectionAddedMessage, readCollectionMapTip, readCollectionLegendImage, readCollectionFilters, readCollectionLocks, readCollectionPrivate, readCollectionRelatedTo, readCollectionScaleRange, readCollectionVisibility, statedOpacity } from './generate/normalizedProject.ts';
41
+ export type { CatalogueLogo, LeftOutLayer, LeftOutReason, LogoLeftOut, LogoLeftOutReason, CollectionFilter, CollectionFormLayout, CollectionRelation, CollectionRelationField } from './generate/normalizedProject.ts';
42
42
  export { generateStacCatalogueFromWfsCapabilities } from './generate/wfsStacCatalogue.ts';
43
43
  export type { WfsStacCatalogueOptions } from './generate/wfsStacCatalogue.ts';
44
44
  export { generateStacCatalogueFromFolder } from './generate/folderStacCatalogue.ts';
package/dist/index.js CHANGED
@@ -24,7 +24,7 @@ export { DATA_ROLE, findAssetByRole, readDataAsset } from "./model/stacAssetRole
24
24
  export { THUMBNAIL_ROLE, readCollectionAttribution, readCollectionDeprecation, readCollectionSelfHref, readCollectionThumbnail } from "./model/stacCollectionNotes.js";
25
25
  export { FILE_EXTENSION, FILE_SIZE_FIELD, TABLE_ROW_COUNT_FIELD, readCollectionRowCount, readDataAssetFileSize } from "./model/stacSizeAndCount.js";
26
26
  export { PMTILES_MEDIA_TYPE, VISUAL_ROLE, readCollectionPmtiles } from "./model/stacPmtiles.js";
27
- export { QUAC_ACTIVE_COLLECTION_FIELD, QUAC_FILTERS_FIELD, QUAC_FORM_ORDER_FIELD, QUAC_LOCKS_FIELD, QUAC_MUTUALLY_EXCLUSIVE_FIELD, QUAC_PRIVATE_FIELD, readCatalogueActiveCollection, readCatalogueInitialView, readCataloguePrintLayouts, readCatalogueBrandColor, readCatalogueLogos, readCatalogueLeftOut, readCollectionDisplayField, readCollectionEditable, readCollectionFieldAliases, readCollectionFieldComments, readCollectionFieldAttachments, readCollectionFieldEditRules, readCollectionFieldNames, readCollectionFieldTypes, readCollectionFieldValueRelations, readCollectionFieldValues, readCollectionFormLayout, readCollectionGeometryType, readCollectionGeometryTypes, readCollectionIdentifiable, readCollectionMeasurement, readCollectionOpacity, readCollectionIcon, readCollectionAddedMessage, readCollectionMapTip, readCollectionLegendImage, readCollectionFilters, readCollectionLocks, readCollectionPrivate, readCollectionRelatedTo, readCollectionScaleRange, readCollectionVisibility, statedOpacity } from "./generate/normalizedProject.js";
27
+ export { QUAC_ACTIVE_COLLECTION_FIELD, QUAC_FILTERS_FIELD, QUAC_FORM_ORDER_FIELD, QUAC_LOCKS_FIELD, QUAC_MUTUALLY_EXCLUSIVE_FIELD, QUAC_PRIVATE_FIELD, readCatalogueActiveCollection, readCatalogueInitialView, readCataloguePrintLayouts, readCatalogueBrandColor, readCatalogueLogos, readCatalogueLeftOut, readCatalogueLogoLeftOut, QUAC_LOGO_LEFT_OUT_FIELD, readCollectionDisplayField, readCollectionEditable, readCollectionFieldAliases, readCollectionFieldComments, readCollectionFieldAttachments, readCollectionFieldEditRules, readCollectionFieldNames, readCollectionFieldRulesLeftOut, readCollectionServerHiddenFields, QUAC_QGIS_SERVER_HIDDEN_FIELD, QUAC_RULES_LEFT_OUT_FIELD, readCollectionFieldTypes, readCollectionFieldValueRelations, readCollectionFieldRelationReferences, readCollectionFieldValues, readCollectionFormLayout, readCollectionGeometryType, readCollectionGeometryTypes, readCollectionIdentifiable, readCollectionMeasurement, readCollectionOpacity, readCollectionIcon, readCollectionAddedMessage, readCollectionMapTip, readCollectionLegendImage, readCollectionFilters, readCollectionLocks, readCollectionPrivate, readCollectionRelatedTo, readCollectionScaleRange, readCollectionVisibility, statedOpacity } from "./generate/normalizedProject.js";
28
28
  export { generateStacCatalogueFromWfsCapabilities } from "./generate/wfsStacCatalogue.js";
29
29
  export { generateStacCatalogueFromFolder } from "./generate/folderStacCatalogue.js";
30
30
  export { generateCollectionForDroppedFile, generateCollectionForLinkedFile } from "./generate/fileLayerCollection.js";
@@ -248,6 +248,14 @@ export interface LayerEntry {
248
248
  * layer hides none.
249
249
  */
250
250
  serverHiddenFields?: ServerHiddenFields;
251
+ /**
252
+ * The rules each field has that the layer's Collection does not carry,
253
+ * keyed by field name, in the order they are read: an edit widget that is
254
+ * not read, a default value expression or a constraint expression
255
+ * `readQgisExpression` cannot read. Each is also a `ProjectNote`. Absent
256
+ * where the layer leaves none out.
257
+ */
258
+ fieldRulesLeftOut?: Record<string, FieldRuleLeftOut[]>;
251
259
  /**
252
260
  * All named styles defined for the layer. QGIS allows multiple symbology
253
261
  * styles per layer (e.g. "Asset Owner" + "Priority") with one currently
@@ -284,6 +292,12 @@ export interface LayerEntry {
284
292
  * widget are absent.
285
293
  */
286
294
  fieldValueRelations: Record<string, FieldValueRelation>;
295
+ /**
296
+ * Relation Reference edit widgets, keyed by field name — the fields QGIS
297
+ * fills by picking a feature of the parent layer under one of the
298
+ * project's relations. Fields with no such widget are absent.
299
+ */
300
+ fieldRelationReferences?: Record<string, FieldRelationReference>;
287
301
  /**
288
302
  * Attachment edit widgets, keyed by field name — the fields QGIS declares as
289
303
  * holding a file rather than text. Fields with no such widget are absent.
@@ -453,6 +467,21 @@ export interface FieldValueRelation {
453
467
  /** Whether the order is reversed (`OrderByDescending`). */
454
468
  descending: boolean;
455
469
  }
470
+ /**
471
+ * A field's Relation Reference edit widget, as far as QUAC reads it: the
472
+ * relation whose parent features it offers, whether it offers a blank, and
473
+ * the expression narrowing the parent features. Its map identification,
474
+ * filter fields, embedded form, add-feature button and fetch limit are not
475
+ * read.
476
+ */
477
+ export interface FieldRelationReference {
478
+ /** The relation's id (`Relation`); empty when the widget names none. */
479
+ relationId: string;
480
+ /** Whether the widget offers a blank (`AllowNULL`); null when the widget does not say. */
481
+ allowNull: boolean | null;
482
+ /** The QGIS expression narrowing the parent features (`FilterExpression`); empty for none. */
483
+ filterExpression: string;
484
+ }
456
485
  /**
457
486
  * A field's Attachment edit widget, as far as QUAC reads it. QGIS calls
458
487
  * the widget `ExternalResource`; the field holds a file's path rather than
@@ -808,6 +837,19 @@ export interface LayerTreeLeaf {
808
837
  checked: boolean;
809
838
  }
810
839
  /** The fields of a layer QGIS Server hides, by the service that hides them. */
840
+ /**
841
+ * A rule of a field that its Collection does not carry, as
842
+ * `quac:rules_left_out` writes it: `rule` says which, `text` is the widget's
843
+ * type, the expression, or the lookup layer's name, and `strength` is a
844
+ * constraint expression's.
845
+ */
846
+ export interface FieldRuleLeftOut {
847
+ rule: FieldRuleLeftOutKind;
848
+ text: string | null;
849
+ strength?: 'enforced' | 'warn';
850
+ }
851
+ /** The kinds of field rule a Collection leaves out (`quac:rules_left_out`). */
852
+ export type FieldRuleLeftOutKind = 'widget' | 'default' | 'constraint' | 'value_relation';
811
853
  export interface ServerHiddenFields {
812
854
  wms: string[];
813
855
  wfs: string[];
@@ -145,6 +145,8 @@ export interface TableColumn {
145
145
  'quac:attachment'?: TableColumnAttachment;
146
146
  /** Declares that the column's choices are the records of another Collection of the same catalogue. */
147
147
  'quac:value_relation'?: TableColumnValueRelation;
148
+ /** Declares that the column is filled by picking a feature of the parent Collection under one of this Collection's relations. */
149
+ 'quac:relation_reference'?: TableColumnRelationReference;
148
150
  /** Written only as `false`: the source shows the column but does not let anyone change it. */
149
151
  'quac:editable'?: false;
150
152
  /** A value the column is filled with on its own. */
@@ -200,6 +202,27 @@ export interface TableColumn {
200
202
  'quac:control'?: 'buttons' | 'dropdown';
201
203
  /** Written only as `true`: the source's form puts the column's name above its value. */
202
204
  'quac:label_on_top'?: true;
205
+ /**
206
+ * The QGIS Server services that leave the column's values out, `wms` before
207
+ * `wfs`. Written only where the source hides the column from one.
208
+ */
209
+ 'quac:qgis_server_hidden'?: TableColumnServerService[];
210
+ /** The column's rules the catalogue leaves out, in the order the source was read. */
211
+ 'quac:rules_left_out'?: TableColumnRuleLeftOut[];
212
+ }
213
+ /** A QGIS Server service that can hide a column (`quac:qgis_server_hidden`). */
214
+ export type TableColumnServerService = 'wms' | 'wfs';
215
+ /**
216
+ * A rule of a column the catalogue leaves out: an edit `widget` it does not
217
+ * read, a `default` or `constraint` expression it cannot read, or a
218
+ * `value_relation` whose lookup is not in the catalogue. `text` is the
219
+ * widget's type, the expression or the lookup layer's name, and `strength` a
220
+ * constraint's.
221
+ */
222
+ export interface TableColumnRuleLeftOut {
223
+ rule: 'widget' | 'default' | 'constraint' | 'value_relation';
224
+ text?: string;
225
+ strength?: 'enforced' | 'warn';
203
226
  }
204
227
  /**
205
228
  * A column whose choices come from another Collection's records: `key` is the
@@ -228,6 +251,20 @@ export interface TableColumnValueRelation {
228
251
  /** Written only as `true`: the order is reversed. */
229
252
  descending?: true;
230
253
  }
254
+ /**
255
+ * A column filled by picking one of the parent's features under a relation
256
+ * this Collection declares in `quac:related_to`. The picked feature's values
257
+ * of the relation's parent fields fill its child fields, and the feature is
258
+ * shown by the parent Collection's `quac:display_field`.
259
+ */
260
+ export interface TableColumnRelationReference {
261
+ /** The `id` of the relation, among this Collection's `quac:related_to`. */
262
+ relation: string;
263
+ /** Written only as `true`: the field may be left without a parent. */
264
+ allow_null?: true;
265
+ /** A QGIS expression narrowing the parent's features. */
266
+ filter?: string;
267
+ }
231
268
  /**
232
269
  * A Checkbox column. Every member is written only where it differs from the
233
270
  * source's default, so `{}` is a checkbox with no states that allows no blank.
@@ -72,7 +72,13 @@ function parseMapLayer(maplayer, notes, photoSettings) {
72
72
  if (!id)
73
73
  return null;
74
74
  const layerNotes = [];
75
- const note = (reason, field, text) => layerNotes.push({ layerId: id, layerName: name, field, reason, text });
75
+ const fieldRulesLeftOut = nameRecord();
76
+ const note = (reason, field, text, strength) => {
77
+ layerNotes.push({ layerId: id, layerName: name, field, reason, text });
78
+ if (field !== null && (reason === 'widget' || reason === 'default' || reason === 'constraint')) {
79
+ (fieldRulesLeftOut[field] ??= []).push({ rule: reason, text, ...(strength ? { strength } : {}) });
80
+ }
81
+ };
76
82
  const type = maplayer.getAttribute('type') ?? '';
77
83
  const geometryType = maplayer.getAttribute('geometry') || null;
78
84
  const wkbType = maplayer.getAttribute('wkbType') || null;
@@ -86,6 +92,7 @@ function parseMapLayer(maplayer, notes, photoSettings) {
86
92
  const fieldAliases = parseFieldAliases(maplayer);
87
93
  const { styles, activeIndex } = parseLayerStyles(maplayer);
88
94
  const fieldValueRelations = parseFieldValueRelations(maplayer);
95
+ const fieldRelationReferences = parseFieldRelationReferences(maplayer);
89
96
  const fieldAttachments = parseFieldAttachments(maplayer, photoSettings.merginNaming[id] ?? nameRecord(), photoSettings);
90
97
  if (dataSource.kind === 'unsupported')
91
98
  note('source', null, dataSource.hint);
@@ -121,6 +128,7 @@ function parseMapLayer(maplayer, notes, photoSettings) {
121
128
  isPrivate: parsePrivate(maplayer),
122
129
  legendImage: parseLegendImage(maplayer),
123
130
  fieldValueRelations,
131
+ ...(Object.keys(fieldRelationReferences).length > 0 ? { fieldRelationReferences } : {}),
124
132
  fieldAttachments,
125
133
  fieldEditRules: parseFieldEditRules(maplayer, note),
126
134
  icon: parseLayerIcon(maplayer),
@@ -133,6 +141,8 @@ function parseMapLayer(maplayer, notes, photoSettings) {
133
141
  locks: parseQfieldSyncLocks(maplayer),
134
142
  rawXml: new XMLSerializer().serializeToString(maplayer)
135
143
  };
144
+ if (Object.keys(fieldRulesLeftOut).length > 0)
145
+ layer.fieldRulesLeftOut = fieldRulesLeftOut;
136
146
  // Added once the layer is read whole, so a layer that fails part way leaves one `layer` note.
137
147
  notes.push(...layerNotes);
138
148
  return layer;
@@ -142,7 +152,7 @@ function parseMapLayer(maplayer, notes, photoSettings) {
142
152
  * in `<editWidget type>`. `TextEdit` is QGIS's plain text box, which needs
143
153
  * nothing carried. An empty type is a field with no widget set.
144
154
  */
145
- const READ_WIDGET_TYPES = new Set(['', 'TextEdit', 'ValueMap', 'ValueRelation', 'ExternalResource', 'Hidden', 'Color', 'CheckBox', 'Range', 'DateTime', 'UuidGenerator']);
155
+ const READ_WIDGET_TYPES = new Set(['', 'TextEdit', 'ValueMap', 'ValueRelation', 'RelationReference', 'ExternalResource', 'Hidden', 'Color', 'CheckBox', 'Range', 'DateTime', 'UuidGenerator']);
146
156
  /**
147
157
  * Notes each field's widget the Collection does not carry: one of a type not
148
158
  * in `READ_WIDGET_TYPES`, and a Value Relation or Attachment widget its reader
@@ -402,6 +412,48 @@ function parseFieldValueRelations(maplayer) {
402
412
  }
403
413
  return result;
404
414
  }
415
+ /**
416
+ * Reads every field's Relation Reference edit widget, keyed by field name.
417
+ * QGIS writes its config as a flat `<Option>` map
418
+ * (`QgsRelationReferenceConfigDlg::config`,
419
+ * `src/gui/editorwidgets/qgsrelationreferenceconfigdlg.cpp`,
420
+ * `qgis/QGIS@release-3_40`, read 2026-12-02):
421
+ *
422
+ * <editWidget type="RelationReference">
423
+ * <config>
424
+ * <Option type="Map">
425
+ * <Option type="QString" value="trees_inspections" name="Relation"/>
426
+ * <Option type="bool" value="false" name="AllowNULL"/>
427
+ * <Option type="QString" value="" name="FilterExpression"/>
428
+ * </Option>
429
+ * </config>
430
+ * </editWidget>
431
+ *
432
+ * Every Relation Reference widget is read, as QGIS falls back to the first
433
+ * relation joining the field where `Relation` names none or one the project
434
+ * lacks, and leaves `AllowNULL` unset to mean "blank unless the field must
435
+ * not be empty" (`QgsRelationReferenceWidgetWrapper::initWidget`,
436
+ * `src/gui/editorwidgets/qgsrelationreferencewidgetwrapper.cpp`, same
437
+ * branch). The catalogue resolves both.
438
+ *
439
+ * A field with no RelationReference widget is absent from the returned map.
440
+ */
441
+ function parseFieldRelationReferences(maplayer) {
442
+ const result = nameRecord();
443
+ for (const [name, editWidget] of layerEditWidgets(maplayer)) {
444
+ if (result[name])
445
+ continue;
446
+ if (editWidget?.getAttribute('type') !== 'RelationReference')
447
+ continue;
448
+ const options = readOptionMap(editWidget);
449
+ result[name] = {
450
+ relationId: readTrimmedOption(options, 'Relation') ?? '',
451
+ allowNull: options.has('AllowNULL') ? readFlag(options, 'AllowNULL') : null,
452
+ filterExpression: readTrimmedOption(options, 'FilterExpression') ?? ''
453
+ };
454
+ }
455
+ return result;
456
+ }
405
457
  /**
406
458
  * QGIS's `DocumentViewerContent`, by its own order from zero
407
459
  * (`src/gui/qgsexternalresourcewidget.h`, `qgis/QGIS@master`, read
@@ -617,7 +669,7 @@ function parseFieldEditRules(maplayer, note) {
617
669
  ruleFor(name).constraintExpression = expression;
618
670
  }
619
671
  else
620
- note('constraint', name, written.expression);
672
+ note('constraint', name, written.expression, strength);
621
673
  }
622
674
  }
623
675
  // A Range with Allow NULL off, or a Date/Time with it off, is a required
@@ -1,4 +1,4 @@
1
- import type { FieldValueRelation, LayerEntry, PresetFilter, ProjectNote, QgsRelation } from '../model/QgsProject.ts';
1
+ import type { FieldRelationReference, FieldValueRelation, LayerEntry, PresetFilter, ProjectNote, QgsRelation } from '../model/QgsProject.ts';
2
2
  /**
3
3
  * The rules that decide whether a setting naming another layer reaches the
4
4
  * catalogue, and the notes for those that do not. `generateStacCatalogue`
@@ -13,14 +13,25 @@ import type { FieldValueRelation, LayerEntry, PresetFilter, ProjectNote, QgsRela
13
13
  * project holds neither.
14
14
  */
15
15
  export declare function findValueRelationLookup(widget: FieldValueRelation, layers: readonly LayerEntry[], layersById: ReadonlyMap<string, LayerEntry>): LayerEntry | undefined;
16
+ /**
17
+ * The relation a Relation Reference widget offers the parent features of:
18
+ * among the project's relations joining this field of this layer to a parent
19
+ * the project holds, the one whose id the widget names, and otherwise the
20
+ * first, as QGIS falls back to the first relation referencing the field
21
+ * (`QgsRelationReferenceWidgetWrapper::initWidget`,
22
+ * `src/gui/editorwidgets/qgsrelationreferencewidgetwrapper.cpp`,
23
+ * `qgis/QGIS@release-3_40`). Undefined where no such relation exists.
24
+ */
25
+ export declare function findRelationReferenceRelation(layerId: string, field: string, widget: FieldRelationReference, relations: readonly QgsRelation[], layersById: ReadonlyMap<string, LayerEntry>): QgsRelation | undefined;
16
26
  /** Whether the project holds both of a relation's layers. */
17
27
  export declare function isRelationInProject(relation: QgsRelation, layersById: ReadonlyMap<string, LayerEntry>): boolean;
18
28
  /** Whether the project holds a filter's layer and that layer has its field. */
19
29
  export declare function isFilterInProject(filter: PresetFilter, layersById: ReadonlyMap<string, LayerEntry>): boolean;
20
30
  /**
21
31
  * The notes for the settings that name another layer and do not reach the
22
- * catalogue: Value Relations, relations and filters, in that order, and each
23
- * in the project's order. `textFilters` are the Mergin Maps `Text` filters
32
+ * catalogue: Value Relations, Relation References, relations and filters, in
33
+ * that order, and each in the project's order. A Relation Reference with no
34
+ * relation is noted as a widget left out, as the catalogue records it. `textFilters` are the Mergin Maps `Text` filters
24
35
  * `parseMerginFilters` passes over.
25
36
  */
26
37
  export declare function crossLayerNotes(layers: readonly LayerEntry[], relations: readonly QgsRelation[], filters: readonly PresetFilter[], textFilters: readonly PresetFilter[]): ProjectNote[];
@@ -14,6 +14,21 @@
14
14
  export function findValueRelationLookup(widget, layers, layersById) {
15
15
  return layersById.get(widget.layerId) ?? layers.find((candidate) => candidate.name === widget.layerName);
16
16
  }
17
+ /**
18
+ * The relation a Relation Reference widget offers the parent features of:
19
+ * among the project's relations joining this field of this layer to a parent
20
+ * the project holds, the one whose id the widget names, and otherwise the
21
+ * first, as QGIS falls back to the first relation referencing the field
22
+ * (`QgsRelationReferenceWidgetWrapper::initWidget`,
23
+ * `src/gui/editorwidgets/qgsrelationreferencewidgetwrapper.cpp`,
24
+ * `qgis/QGIS@release-3_40`). Undefined where no such relation exists.
25
+ */
26
+ export function findRelationReferenceRelation(layerId, field, widget, relations, layersById) {
27
+ const joining = relations.filter((relation) => (relation.childLayerId === layerId &&
28
+ isRelationInProject(relation, layersById) &&
29
+ relation.fieldPairs.some((pair) => pair.childField === field)));
30
+ return joining.find((relation) => relation.id === widget.relationId) ?? joining[0];
31
+ }
17
32
  /** Whether the project holds both of a relation's layers. */
18
33
  export function isRelationInProject(relation, layersById) {
19
34
  return layersById.has(relation.parentLayerId) && layersById.has(relation.childLayerId);
@@ -24,8 +39,9 @@ export function isFilterInProject(filter, layersById) {
24
39
  }
25
40
  /**
26
41
  * The notes for the settings that name another layer and do not reach the
27
- * catalogue: Value Relations, relations and filters, in that order, and each
28
- * in the project's order. `textFilters` are the Mergin Maps `Text` filters
42
+ * catalogue: Value Relations, Relation References, relations and filters, in
43
+ * that order, and each in the project's order. A Relation Reference with no
44
+ * relation is noted as a widget left out, as the catalogue records it. `textFilters` are the Mergin Maps `Text` filters
29
45
  * `parseMerginFilters` passes over.
30
46
  */
31
47
  export function crossLayerNotes(layers, relations, filters, textFilters) {
@@ -38,6 +54,12 @@ export function crossLayerNotes(layers, relations, filters, textFilters) {
38
54
  notes.push(noteFor(layer.id, field, 'value-relation', widget.layerName || widget.layerId));
39
55
  }
40
56
  }
57
+ for (const layer of layers) {
58
+ for (const [field, widget] of Object.entries(layer.fieldRelationReferences ?? {})) {
59
+ if (!findRelationReferenceRelation(layer.id, field, widget, relations, layersById))
60
+ notes.push(noteFor(layer.id, field, 'widget', 'RelationReference'));
61
+ }
62
+ }
41
63
  for (const relation of relations) {
42
64
  if (!isRelationInProject(relation, layersById))
43
65
  notes.push(noteFor(relation.childLayerId, null, 'relation', relation.name || relation.id));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vectoriahq/quac",
3
- "version": "0.23.0",
3
+ "version": "0.25.0-next.1",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "description": "Writes and reads QUAC, which adds map layer settings to STAC catalogues.",
@@ -113,6 +113,21 @@
113
113
  "additionalProperties": false
114
114
  }
115
115
  },
116
+ "quac:logo_left_out": {
117
+ "description": "On the top-level Catalog: the logo variables the source sets that write no icon link, the logo's first, each by the variable's name, never its value, with why it writes none. Written from a QGIS project's quac_logo and quac_logo_dark variables.",
118
+ "type": "array",
119
+ "minItems": 1,
120
+ "maxItems": 2,
121
+ "items": {
122
+ "type": "object",
123
+ "required": ["variable", "reason"],
124
+ "properties": {
125
+ "variable": { "enum": ["quac_logo", "quac_logo_dark"] },
126
+ "reason": { "enum": ["not_an_image", "not_relative", "outside_folder", "not_read", "no_logo"] }
127
+ },
128
+ "additionalProperties": false
129
+ }
130
+ },
116
131
  "quac:visibility_checked": {
117
132
  "description": "On a group: whether the group opens switched on. In a catalogue of basemaps, true marks the basemap that is shown first, and false keeps a group hidden.",
118
133
  "type": "boolean"
@@ -683,6 +698,36 @@
683
698
  "description": "The form puts the field's name above its value, across the form's width. Written from QGIS's Label on top in the Attributes Form.",
684
699
  "const": true
685
700
  },
701
+ "quac:qgis_server_hidden": {
702
+ "description": "The QGIS Server services that leave the field's values out: wms for GetFeatureInfo and GetProjectSettings, wfs for DescribeFeatureType and GetFeature, in that order. Written from the WMS and WFS boxes of QGIS's QGIS Server settings in the Attributes Form.",
703
+ "type": "array",
704
+ "minItems": 1,
705
+ "maxItems": 2,
706
+ "uniqueItems": true,
707
+ "items": { "enum": ["wms", "wfs"] }
708
+ },
709
+ "quac:rules_left_out": {
710
+ "description": "The field's rules the catalogue leaves out, in the order the source was read: an edit widget it does not read, a default or constraint expression it cannot read, or a Value Relation whose lookup layer is not in the catalogue.",
711
+ "type": "array",
712
+ "minItems": 1,
713
+ "items": {
714
+ "type": "object",
715
+ "required": ["rule"],
716
+ "properties": {
717
+ "rule": { "enum": ["widget", "default", "constraint", "value_relation"] },
718
+ "text": {
719
+ "description": "The widget's type, or the expression, as the source wrote it.",
720
+ "type": "string",
721
+ "minLength": 1
722
+ },
723
+ "strength": {
724
+ "description": "A constraint expression's strength: enforced refuses a value it fails, warn saves it with a warning.",
725
+ "enum": ["enforced", "warn"]
726
+ }
727
+ },
728
+ "additionalProperties": false
729
+ }
730
+ },
686
731
  "quac:values": {
687
732
  "description": "The values the field takes, each with the label a form shows for it, in the source's order. Written from a QGIS Value Map widget or an ArcGIS coded-value domain.",
688
733
  "type": "array",
@@ -713,6 +758,9 @@
713
758
  "quac:value_relation": {
714
759
  "$ref": "#/definitions/value_relation"
715
760
  },
761
+ "quac:relation_reference": {
762
+ "$ref": "#/definitions/relation_reference"
763
+ },
716
764
  "quac:attachment": {
717
765
  "$ref": "#/definitions/attachment"
718
766
  }
@@ -945,6 +993,29 @@
945
993
  },
946
994
  "additionalProperties": false
947
995
  },
996
+ "relation_reference": {
997
+ "description": "The field is filled by picking a feature of the parent Collection under one of this Collection's relations. Written from a QGIS Relation Reference widget.",
998
+ "type": "object",
999
+ "required": [
1000
+ "relation"
1001
+ ],
1002
+ "properties": {
1003
+ "relation": {
1004
+ "description": "The id of the relation, among this Collection's quac:related_to.",
1005
+ "type": "string",
1006
+ "minLength": 1
1007
+ },
1008
+ "allow_null": {
1009
+ "const": true,
1010
+ "description": "The field may be left without a parent."
1011
+ },
1012
+ "filter": {
1013
+ "type": "string",
1014
+ "description": "A QGIS expression narrowing the parent's features."
1015
+ }
1016
+ },
1017
+ "additionalProperties": false
1018
+ },
948
1019
  "value_relation": {
949
1020
  "description": "The field's choices are the records of another Collection in the same catalogue. Written from a QGIS Value Relation widget.",
950
1021
  "type": "object",