@vectoriahq/quac 0.22.0 → 0.24.0

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, TableColumnValue, TableColumnValueRelation } from '../model/Stac.ts';
3
3
  /**
4
4
  * Source-agnostic intermediate model + the single STAC generator that
5
5
  * consumes it.
@@ -87,6 +87,14 @@ export declare const QUAC_MUTUALLY_EXCLUSIVE_FIELD = "quac:mutually_exclusive";
87
87
  export declare const QUAC_ACTIVE_COLLECTION_FIELD = "quac:active_collection";
88
88
  /** The project's print layouts, on the top-level Catalog: each as its name and its QGIS layout template. */
89
89
  export declare const QUAC_PRINT_LAYOUTS_FIELD = "quac:print_layouts";
90
+ /** The colour the source names as its brand, on the top-level Catalog, as `#rrggbb`. */
91
+ export declare const QUAC_BRAND_COLOR_FIELD = "quac:brand_color";
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
+ 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";
96
+ /** The key an `icon` link takes for the theme its image is for: `dark` for the logo shown in a dark theme. */
97
+ export declare const QUAC_THEME_FIELD = "quac:theme";
90
98
  /**
91
99
  * One relation a Collection declares in `quac:related_to`: the parent
92
100
  * Collection its records hang off, the field pair(s) joining them, and the name
@@ -155,6 +163,11 @@ export interface NormalizedLayer {
155
163
  bbox: NormalizedBbox | null;
156
164
  /** The geometry type as QGIS names it, written as `quac:geometry_type`. */
157
165
  geometryType: string | null;
166
+ /**
167
+ * Every geometry type, in order, for a Collection made from QGIS's per-shape
168
+ * layers, written as `quac:geometry_type` in place of `geometryType`.
169
+ */
170
+ geometryTypes?: readonly string[] | null;
158
171
  /**
159
172
  * The WKB type names the layer's features take, such as `MultiPolygon` or
160
173
  * `PointZ`: one for most layers, one per shape for a file the project splits
@@ -264,6 +277,8 @@ export interface NormalizedProject {
264
277
  activeCollectionId?: string | null;
265
278
  /** Vendor-namespaced fields copied straight onto the top-level Catalog. */
266
279
  vendorFields?: Record<string, unknown>;
280
+ /** Links the top-level Catalog carries after its own, such as its logo's `icon` links. */
281
+ links?: StacLink[];
267
282
  /**
268
283
  * Project-wide providers — the project's own author, say — merged onto
269
284
  * every Collection the tree produces, alongside whatever that layer
@@ -320,6 +335,55 @@ export declare function readCatalogueActiveCollection(catalog: StacCatalog): str
320
335
  * not a `<Layout>` element, is not read. Empty where the Catalog lists none.
321
336
  */
322
337
  export declare function readCataloguePrintLayouts(catalog: StacCatalog): PrintLayoutTemplate[];
338
+ /** The top-level Catalog's `quac:brand_color`, as `#rrggbb` in lower case, or null where it has none or it is not that form. */
339
+ export declare function readCatalogueBrandColor(catalog: StacCatalog): string | null;
340
+ /** A logo a top-level Catalog links: its address and, where the link gives it, its media type. */
341
+ export interface CatalogueLogo {
342
+ href: string;
343
+ type?: string;
344
+ }
345
+ /**
346
+ * The logos a top-level Catalog links with `rel: "icon"`: `light`, the first
347
+ * with no `quac:theme`, and `dark`, the first whose `quac:theme` is `dark`.
348
+ * Each is null where the Catalog links none.
349
+ */
350
+ export declare function readCatalogueLogos(catalog: StacCatalog): {
351
+ light: CatalogueLogo | null;
352
+ dark: CatalogueLogo | null;
353
+ };
354
+ /** Why a source's layer was left out of its catalogue, as `quac:left_out` gives it. */
355
+ export type LeftOutReason = 'outside_folder' | 'not_a_file' | 'holds_credentials' | 'not_opened' | 'not_copied' | 'copy_failed';
356
+ /** A layer `quac:left_out` names: the id its Collection would have had, its title, and why it was left out. */
357
+ export interface LeftOutLayer {
358
+ id: string;
359
+ title: string;
360
+ reason: LeftOutReason;
361
+ }
362
+ /**
363
+ * The layers a top-level Catalog lists in `quac:left_out`, in its order. An
364
+ * entry without a string id and title, or with a reason this package does
365
+ * not know, is not read. Empty where the Catalog lists none.
366
+ */
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[];
323
387
  export declare function readCatalogueInitialView(catalog: StacCatalog): NormalizedBbox | null;
324
388
  /**
325
389
  * Reads shared source declarations back off a Collection.
@@ -337,6 +401,27 @@ export declare function readCollectionDisplayField(collection: StacCollection):
337
401
  * of any other shape, or a `table:columns` that is not a list, yields nothing.
338
402
  */
339
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[]>;
340
425
  /** Each field's alias, its column's `title`. A column with a blank or no `title` is absent. */
341
426
  export declare function readCollectionFieldAliases(collection: StacCollection): Record<string, string>;
342
427
  /** Each field's comment, its column's `description`, trimmed. A column with a blank or no `description` is absent. */
@@ -463,6 +548,12 @@ export declare function readCollectionIdentifiable(collection: StacCollection):
463
548
  export declare function readCollectionVisibility(collection: StacCollection | StacCatalog): boolean | null;
464
549
  /** The layer's geometry type as QGIS names it ("Point", "Line", "Polygon", "No geometry"); null when the source gives none. */
465
550
  export declare function readCollectionGeometryType(collection: StacCollection): string | null;
551
+ /**
552
+ * Every geometry type a Collection's summaries give, in order: one for a
553
+ * layer, and one per shape for a Collection made from QGIS's per-shape layers.
554
+ * Empty where it gives none.
555
+ */
556
+ export declare function readCollectionGeometryTypes(collection: StacCollection): string[];
466
557
  /** The scales the source draws the layer between; null when it sets no limit. */
467
558
  export declare function readCollectionScaleRange(collection: StacCollection): LayerScaleRange | null;
468
559
  /**
@@ -97,6 +97,14 @@ const INITIAL_VIEW_FIELD = 'quac:initial_view';
97
97
  export const QUAC_ACTIVE_COLLECTION_FIELD = 'quac:active_collection';
98
98
  /** The project's print layouts, on the top-level Catalog: each as its name and its QGIS layout template. */
99
99
  export const QUAC_PRINT_LAYOUTS_FIELD = 'quac:print_layouts';
100
+ /** The colour the source names as its brand, on the top-level Catalog, as `#rrggbb`. */
101
+ export const QUAC_BRAND_COLOR_FIELD = 'quac:brand_color';
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
+ 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';
106
+ /** The key an `icon` link takes for the theme its image is for: `dark` for the logo shown in a dark theme. */
107
+ export const QUAC_THEME_FIELD = 'quac:theme';
100
108
  /**
101
109
  * Records where a catalogue came from as the Catalog's `self` link, so the
102
110
  * document says it rather than a reader holding it alongside. Sources with no
@@ -129,7 +137,8 @@ export function generateStacFromNormalized(project) {
129
137
  links: [
130
138
  { rel: 'self', href: './catalog.json' },
131
139
  { rel: 'root', href: './catalog.json' },
132
- ...links
140
+ ...links,
141
+ ...(project.links ?? [])
133
142
  ]
134
143
  };
135
144
  if (project.bbox) {
@@ -218,8 +227,9 @@ function buildCollection(layer, defaultProviders, folder) {
218
227
  if (Object.values(layer.assets).some((asset) => typeof asset[PROJ_CODE] === 'string'))
219
228
  stacExtensions.push(PROJECTION_EXTENSION);
220
229
  const summaries = {};
221
- if (layer.geometryType)
222
- summaries['quac:geometry_type'] = [layer.geometryType];
230
+ const geometryTypes = layer.geometryTypes ?? (layer.geometryType ? [layer.geometryType] : []);
231
+ if (geometryTypes.length > 0)
232
+ summaries['quac:geometry_type'] = [...geometryTypes];
223
233
  const providers = [...defaultProviders, ...(layer.providers ?? [])];
224
234
  const collection = {
225
235
  type: 'Collection',
@@ -399,6 +409,62 @@ export function readCataloguePrintLayouts(catalog) {
399
409
  return typeof name === 'string' && typeof template === 'string' && /^<Layout[\s/>]/.test(template) ? [{ name, template }] : [];
400
410
  });
401
411
  }
412
+ /** The top-level Catalog's `quac:brand_color`, as `#rrggbb` in lower case, or null where it has none or it is not that form. */
413
+ export function readCatalogueBrandColor(catalog) {
414
+ const value = catalog[QUAC_BRAND_COLOR_FIELD];
415
+ return typeof value === 'string' && /^#[0-9a-f]{6}$/i.test(value) ? value.toLowerCase() : null;
416
+ }
417
+ /**
418
+ * The logos a top-level Catalog links with `rel: "icon"`: `light`, the first
419
+ * with no `quac:theme`, and `dark`, the first whose `quac:theme` is `dark`.
420
+ * Each is null where the Catalog links none.
421
+ */
422
+ export function readCatalogueLogos(catalog) {
423
+ const icons = (catalog.links ?? []).filter((link) => link.rel === 'icon' && typeof link.href === 'string' && link.href !== '');
424
+ const logo = (link) => link ? { href: link.href, ...(typeof link.type === 'string' ? { type: link.type } : {}) } : null;
425
+ return {
426
+ light: logo(icons.find((link) => link[QUAC_THEME_FIELD] === undefined)),
427
+ dark: logo(icons.find((link) => link[QUAC_THEME_FIELD] === 'dark'))
428
+ };
429
+ }
430
+ const LEFT_OUT_REASONS = new Set(['outside_folder', 'not_a_file', 'holds_credentials', 'not_opened', 'not_copied', 'copy_failed']);
431
+ /**
432
+ * The layers a top-level Catalog lists in `quac:left_out`, in its order. An
433
+ * entry without a string id and title, or with a reason this package does
434
+ * not know, is not read. Empty where the Catalog lists none.
435
+ */
436
+ export function readCatalogueLeftOut(catalog) {
437
+ const value = catalog[QUAC_LEFT_OUT_FIELD];
438
+ if (!Array.isArray(value))
439
+ return [];
440
+ return value.flatMap((entry) => {
441
+ if (!entry || typeof entry !== 'object')
442
+ return [];
443
+ const { id, title, reason } = entry;
444
+ return typeof id === 'string' && id !== '' && typeof title === 'string' && typeof reason === 'string' && LEFT_OUT_REASONS.has(reason)
445
+ ? [{ id, title, reason: reason }]
446
+ : [];
447
+ });
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
+ }
402
468
  export function readCatalogueInitialView(catalog) {
403
469
  const value = catalog[INITIAL_VIEW_FIELD];
404
470
  if (!Array.isArray(value) || value.length !== 4)
@@ -441,6 +507,59 @@ export function* declaredColumns(collection) {
441
507
  yield [name, candidate];
442
508
  }
443
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
+ }
444
563
  /** Each field's alias, its column's `title`. A column with a blank or no `title` is absent. */
445
564
  export function readCollectionFieldAliases(collection) {
446
565
  const aliases = nameRecord();
@@ -851,6 +970,15 @@ export function readCollectionGeometryType(collection) {
851
970
  const value = Array.isArray(summary) ? summary[0] : null;
852
971
  return typeof value === 'string' ? value : null;
853
972
  }
973
+ /**
974
+ * Every geometry type a Collection's summaries give, in order: one for a
975
+ * layer, and one per shape for a Collection made from QGIS's per-shape layers.
976
+ * Empty where it gives none.
977
+ */
978
+ export function readCollectionGeometryTypes(collection) {
979
+ const summary = collection.summaries?.['quac:geometry_type'];
980
+ return Array.isArray(summary) ? summary.filter((value) => typeof value === 'string') : [];
981
+ }
854
982
  /** The scales the source draws the layer between; null when it sets no limit. */
855
983
  export function readCollectionScaleRange(collection) {
856
984
  const minScale = readScaleDenominator(collection['quac:min_scale']);
@@ -23,7 +23,9 @@ import type { StacCatalog, StacCollection } from '../model/Stac.ts';
23
23
  * where the project publishes the layer for WFS, and a WMS link always, in
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
- * is written, nor an Attachment widget's default folder.
26
+ * is written, nor an Attachment widget's default folder, nor the logo's
27
+ * `icon` links, which name files beside the project, nor so
28
+ * `quac:logo_left_out`.
27
29
  * - A field the project hides from WMS or from WFS is left out of
28
30
  * `table:columns`, and every mention of it is dropped: from the form order,
29
31
  * the preset filters, the display field, a relation's join, and any
@@ -114,7 +116,10 @@ export interface HiddenFieldContext {
114
116
  * A lock whose expression uses one becomes `true`, and a field editable only
115
117
  * while such an expression holds becomes read-only, so that hiding a field
116
118
  * never unlocks an edit. A relation or Value Relation to a layer that is not
117
- * 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
+ * column's default, constraint expression or Value Relation dropped so is
121
+ * added to its `quac:rules_left_out`, and a rule already there loses an
122
+ * expression that names a hidden field. For
118
123
  * an application that serves a project's layers itself, as
119
124
  * `generateServerStacCatalogue` does for QGIS Server.
120
125
  */
@@ -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";
@@ -30,7 +30,9 @@ import { chooseWmsCrs, WEB_MAP_LINKS_EXTENSION, WMS_REQUEST_PARAMETERS } from ".
30
30
  * where the project publishes the layer for WFS, and a WMS link always, in
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
- * is written, nor an Attachment widget's default folder.
33
+ * is written, nor an Attachment widget's default folder, nor the logo's
34
+ * `icon` links, which name files beside the project, nor so
35
+ * `quac:logo_left_out`.
34
36
  * - A field the project hides from WMS or from WFS is left out of
35
37
  * `table:columns`, and every mention of it is dropped: from the form order,
36
38
  * the preset filters, the display field, a relation's join, and any
@@ -86,10 +88,11 @@ export function generateServerStacCatalogue(project, options) {
86
88
  const serveCatalog = (node) => {
87
89
  const collections = (node.collections ?? []).filter((collection) => servedIds.has(collection.id)).map((collection) => serveCollection(collection, context));
88
90
  const catalogs = (node.catalogs ?? []).map(serveCatalog);
89
- const served = { ...node, links: [...node.links.filter((link) => link.rel !== 'child'), ...childLinks(catalogueFolder(node) ?? './', collections, catalogs)] };
91
+ const served = { ...node, links: [...node.links.filter((link) => link.rel !== 'child' && link.rel !== 'icon'), ...childLinks(catalogueFolder(node) ?? './', collections, catalogs)] };
90
92
  delete served.collections;
91
93
  delete served.catalogs;
92
94
  delete served.stac_extensions;
95
+ delete served[QUAC_LOGO_LEFT_OUT_FIELD];
93
96
  if (collections.length > 0)
94
97
  served.collections = collections;
95
98
  if (catalogs.length > 0)
@@ -223,7 +226,10 @@ function serveCollection(source, context) {
223
226
  * A lock whose expression uses one becomes `true`, and a field editable only
224
227
  * while such an expression holds becomes read-only, so that hiding a field
225
228
  * never unlocks an edit. A relation or Value Relation to a layer that is not
226
- * 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
+ * column's default, constraint expression or Value Relation dropped so is
231
+ * added to its `quac:rules_left_out`, and a rule already there loses an
232
+ * expression that names a hidden field. For
227
233
  * an application that serves a project's layers itself, as
228
234
  * `generateServerStacCatalogue` does for QGIS Server.
229
235
  */
@@ -384,17 +390,31 @@ function serveColumn(source, hidden, context) {
384
390
  delete served.default_root;
385
391
  column['quac:attachment'] = served;
386
392
  }
393
+ // A rule left out already keeps its kind, but not an expression that names a hidden field.
394
+ const leftOut = Array.isArray(column['quac:rules_left_out'])
395
+ ? column['quac:rules_left_out'].map((rule) => {
396
+ if (rule.rule === 'widget' || !mentionsAny(rule.text, hidden))
397
+ return rule;
398
+ const kept = { ...rule };
399
+ delete kept.text;
400
+ return kept;
401
+ })
402
+ : [];
387
403
  const fieldDefault = column['quac:default'];
388
- if (fieldDefault?.kind === 'expression' && mentionsAny(fieldDefault.expression, hidden))
404
+ if (fieldDefault?.kind === 'expression' && mentionsAny(fieldDefault.expression, hidden)) {
389
405
  delete column['quac:default'];
406
+ leftOut.push({ rule: 'default' });
407
+ }
390
408
  const constraints = column['quac:constraints'];
391
- if (constraints && mentionsAny(constraints.expression?.expression, hidden)) {
409
+ const constraintExpression = constraints?.expression;
410
+ if (constraints && mentionsAny(constraintExpression?.expression, hidden)) {
392
411
  const rest = { ...constraints };
393
412
  delete rest.expression;
394
413
  if (Object.keys(rest).length > 0)
395
414
  column['quac:constraints'] = rest;
396
415
  else
397
416
  delete column['quac:constraints'];
417
+ leftOut.push({ rule: 'constraint', ...(constraintExpression?.strength ? { strength: constraintExpression.strength } : {}) });
398
418
  }
399
419
  const relation = column['quac:value_relation'];
400
420
  if (relation) {
@@ -403,10 +423,14 @@ function serveColumn(source, hidden, context) {
403
423
  const usesHidden = [relation.key, relation.value, relation.order_field].some((field) => field !== undefined && lookupHidden.has(field))
404
424
  || mentionsAny(relation.filter, lookupHidden)
405
425
  || mentionsAny(relation.filter, hidden);
406
- if (!lookupId || usesHidden)
426
+ if (!lookupId || usesHidden) {
407
427
  delete column['quac:value_relation'];
428
+ leftOut.push({ rule: 'value_relation' });
429
+ }
408
430
  else
409
431
  column['quac:value_relation'] = { ...relation, collection: lookupId };
410
432
  }
433
+ if (leftOut.length > 0)
434
+ column['quac:rules_left_out'] = leftOut;
411
435
  return column;
412
436
  }
@@ -52,3 +52,11 @@ export interface CatalogueDocument {
52
52
  * Throws where `rootFileName` or `childrenFolder` is not a safe relative path.
53
53
  */
54
54
  export declare function splitCatalogue(catalogue: StacCatalog, options?: SplitCatalogueOptions): CatalogueDocument[];
55
+ /**
56
+ * An id made a file or folder name that is safe on any system: each character
57
+ * a name may not hold, `/` among them, becomes `_`, as does each `.` or space
58
+ * at its end, which Windows drops; an empty name is `_`; and a name Windows
59
+ * keeps for a device, such as `con`, is given a leading `_`. So no name is
60
+ * empty, `.` or `..`.
61
+ */
62
+ export declare function safeName(id: string): string;
@@ -178,7 +178,7 @@ const RESERVED_NAME = /^(con|prn|aux|nul|com[0-9¹²³]|lpt[0-9¹²³])(\.|$)/i;
178
178
  * keeps for a device, such as `con`, is given a leading `_`. So no name is
179
179
  * empty, `.` or `..`.
180
180
  */
181
- function safeName(id) {
181
+ export function safeName(id) {
182
182
  let name = id.replace(UNSAFE_CHARACTERS, '_');
183
183
  // Counted from the end, not matched with /[. ]+$/, which takes time growing with the square of a run of spaces that does not end the id.
184
184
  let kept = name.length;
@@ -35,13 +35,44 @@ export interface StacCompanionData {
35
35
  * as if the project did not hold it, so a relation, Value Relation, filter or
36
36
  * initial active layer naming it is dropped too (`wmsExcludedLayerIds`).
37
37
  */
38
- export declare function generateStacCatalogue(project: QgsProject, companions?: StacCompanionData[], options?: {
38
+ export declare function generateStacCatalogue(project: QgsProject, companions?: StacCompanionData[], options?: StacCatalogueOptions): StacCatalog;
39
+ /** What `generateStacCatalogue` and `generateCatalogueFiles` take beyond the project. */
40
+ export interface StacCatalogueOptions {
39
41
  selfHref?: string;
40
42
  projectPath?: string;
41
43
  projectFileName?: string;
42
44
  initialView?: BoundingBox | null;
43
45
  layerWgs84Extents?: Map<string, BoundingBox>;
44
- }): StacCatalog;
46
+ }
47
+ /** A file a catalogue carries beside its documents, such as a layer's style. */
48
+ export interface CatalogueFile {
49
+ /**
50
+ * Where the file goes, relative to the top-level document's folder: names
51
+ * joined by `/`, not escaped, each safe as a file name on any system. The
52
+ * catalogue's href for it is this path, escaped, after `./`.
53
+ */
54
+ path: string;
55
+ mediaType: string;
56
+ text: string;
57
+ }
58
+ /**
59
+ * A QGIS project's catalogue with the files it carries: the twin of
60
+ * `generateStacCatalogue`, built by the same code, which gives each layer's
61
+ * styles as files of the catalogue's own rather than as addresses into the
62
+ * project file. Each style is a QGIS style document (`.qml`,
63
+ * `LayerStyle.styleDocument`) in `<filesFolder>/styles/<Collection>/`, named
64
+ * after the style, and for a Collection made from QGIS's per-shape layers,
65
+ * after the style and the shape. A folder name is made safe as
66
+ * `splitCatalogue` makes one. `filesFolder`, empty by default, is where a
67
+ * caller writing the catalogue as separate documents puts its other documents,
68
+ * `splitCatalogue`'s `childrenFolder`, so the files sit with them.
69
+ */
70
+ export declare function generateCatalogueFiles(project: QgsProject, companions?: StacCompanionData[], options?: StacCatalogueOptions & {
71
+ filesFolder?: string;
72
+ }): {
73
+ catalogue: StacCatalog;
74
+ files: CatalogueFile[];
75
+ };
45
76
  /**
46
77
  * The key a style asset takes for the field its renderer classifies by, when
47
78
  * that renderer is a categorised one. The project author's declaration.
@@ -66,6 +97,16 @@ export declare function readCollectionGeometryFilter(collection: StacCollection)
66
97
  export declare const QUAC_LAYER_NAME = "quac:layer_name";
67
98
  /** The table a Collection's data asset names, or null where it names none. */
68
99
  export declare function readCollectionLayerName(collection: StacCollection): string | null;
100
+ /** The project variables naming the map's logo, and the logo shown in a dark theme. */
101
+ export declare const LOGO_VARIABLE = "quac_logo";
102
+ export declare const LOGO_DARK_VARIABLE = "quac_logo_dark";
103
+ /**
104
+ * A path relative to the project and inside its folder, with `/` between its
105
+ * names and no `.` names, or null for anything else: an absolute path, a drive,
106
+ * a home folder or an address (`isProjectRelativeFolder`), or a path whose `..`
107
+ * leaves the folder.
108
+ */
109
+ export declare function projectRelativeFile(value: string): string | null;
69
110
  /**
70
111
  * The names QGIS Server would give the layer if it served the project
71
112
  * (`QgsWmsLayerInfos::buildWmsLayerInfos`, `src/server/services/wms/qgswmslayerinfos.cpp`,