@vectoriahq/quac 0.0.0-stage → 0.2.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.
Files changed (134) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +35 -2
  3. package/dist/generate/arcgisStacCatalogue.d.ts +46 -0
  4. package/dist/generate/arcgisStacCatalogue.js +189 -0
  5. package/dist/generate/externalStacCatalogue.d.ts +53 -0
  6. package/dist/generate/externalStacCatalogue.js +143 -0
  7. package/dist/generate/fileLayerCollection.d.ts +44 -0
  8. package/dist/generate/fileLayerCollection.js +72 -0
  9. package/dist/generate/folderStacCatalogue.d.ts +48 -0
  10. package/dist/generate/folderStacCatalogue.js +69 -0
  11. package/dist/generate/normalizedProject.d.ts +452 -0
  12. package/dist/generate/normalizedProject.js +877 -0
  13. package/dist/generate/ogcFeaturesStacCatalogue.d.ts +49 -0
  14. package/dist/generate/ogcFeaturesStacCatalogue.js +207 -0
  15. package/dist/generate/qmlForLayer.d.ts +17 -0
  16. package/dist/generate/qmlForLayer.js +36 -0
  17. package/dist/generate/serverLayerTree.d.ts +44 -0
  18. package/dist/generate/serverLayerTree.js +50 -0
  19. package/dist/generate/serverStacCatalogue.d.ts +84 -0
  20. package/dist/generate/serverStacCatalogue.js +327 -0
  21. package/dist/generate/stacCatalogue.d.ts +110 -0
  22. package/dist/generate/stacCatalogue.js +887 -0
  23. package/dist/generate/wfsStacCatalogue.d.ts +37 -0
  24. package/dist/generate/wfsStacCatalogue.js +127 -0
  25. package/dist/generate/wmsStacCatalogue.d.ts +46 -0
  26. package/dist/generate/wmsStacCatalogue.js +229 -0
  27. package/dist/index.d.ts +77 -0
  28. package/dist/index.js +52 -0
  29. package/dist/model/QgsProject.d.ts +724 -0
  30. package/dist/model/QgsProject.js +15 -0
  31. package/dist/model/Stac.d.ts +322 -0
  32. package/dist/model/Stac.js +16 -0
  33. package/dist/model/WmsProject.d.ts +105 -0
  34. package/dist/model/WmsProject.js +1 -0
  35. package/dist/model/arcgis.d.ts +134 -0
  36. package/dist/model/arcgis.js +1 -0
  37. package/dist/model/delimitedText.d.ts +38 -0
  38. package/dist/model/delimitedText.js +46 -0
  39. package/dist/model/featureFilter.d.ts +41 -0
  40. package/dist/model/featureFilter.js +24 -0
  41. package/dist/model/fieldIconAddress.d.ts +27 -0
  42. package/dist/model/fieldIconAddress.js +93 -0
  43. package/dist/model/ogcFeatures.d.ts +40 -0
  44. package/dist/model/ogcFeatures.js +6 -0
  45. package/dist/model/quacExtension.d.ts +28 -0
  46. package/dist/model/quacExtension.js +75 -0
  47. package/dist/model/stacAssetRoles.d.ts +33 -0
  48. package/dist/model/stacAssetRoles.js +44 -0
  49. package/dist/model/stacCollectionNotes.d.ts +21 -0
  50. package/dist/model/stacCollectionNotes.js +44 -0
  51. package/dist/model/stacHref.d.ts +56 -0
  52. package/dist/model/stacHref.js +93 -0
  53. package/dist/model/stacPmtiles.d.ts +38 -0
  54. package/dist/model/stacPmtiles.js +69 -0
  55. package/dist/model/stacSizeAndCount.d.ts +14 -0
  56. package/dist/model/stacSizeAndCount.js +20 -0
  57. package/dist/model/stacStyles.d.ts +93 -0
  58. package/dist/model/stacStyles.js +87 -0
  59. package/dist/model/stacTreeWalk.d.ts +36 -0
  60. package/dist/model/stacTreeWalk.js +76 -0
  61. package/dist/model/stacWms.d.ts +18 -0
  62. package/dist/model/stacWms.js +73 -0
  63. package/dist/model/stacWmts.d.ts +34 -0
  64. package/dist/model/stacWmts.js +90 -0
  65. package/dist/model/stacXyz.d.ts +24 -0
  66. package/dist/model/stacXyz.js +46 -0
  67. package/dist/model/wfs.d.ts +136 -0
  68. package/dist/model/wfs.js +1 -0
  69. package/dist/parse/collectLayerVisibility.d.ts +10 -0
  70. package/dist/parse/collectLayerVisibility.js +22 -0
  71. package/dist/parse/customProperties.d.ts +18 -0
  72. package/dist/parse/customProperties.js +43 -0
  73. package/dist/parse/geometrySiblings.d.ts +25 -0
  74. package/dist/parse/geometrySiblings.js +83 -0
  75. package/dist/parse/parseBrandColour.d.ts +14 -0
  76. package/dist/parse/parseBrandColour.js +25 -0
  77. package/dist/parse/parseDataDefinedEditable.d.ts +38 -0
  78. package/dist/parse/parseDataDefinedEditable.js +76 -0
  79. package/dist/parse/parseDataSource.d.ts +53 -0
  80. package/dist/parse/parseDataSource.js +484 -0
  81. package/dist/parse/parseExtent.d.ts +17 -0
  82. package/dist/parse/parseExtent.js +49 -0
  83. package/dist/parse/parseFormLayout.d.ts +26 -0
  84. package/dist/parse/parseFormLayout.js +60 -0
  85. package/dist/parse/parseGetProjectSettings.d.ts +15 -0
  86. package/dist/parse/parseGetProjectSettings.js +172 -0
  87. package/dist/parse/parseLayers.d.ts +23 -0
  88. package/dist/parse/parseLayers.js +1125 -0
  89. package/dist/parse/parseLegendTree.d.ts +20 -0
  90. package/dist/parse/parseLegendTree.js +66 -0
  91. package/dist/parse/parseMeasurement.d.ts +20 -0
  92. package/dist/parse/parseMeasurement.js +66 -0
  93. package/dist/parse/parseMergin.d.ts +19 -0
  94. package/dist/parse/parseMergin.js +51 -0
  95. package/dist/parse/parseProjectVariables.d.ts +9 -0
  96. package/dist/parse/parseProjectVariables.js +19 -0
  97. package/dist/parse/parseQfieldSync.d.ts +47 -0
  98. package/dist/parse/parseQfieldSync.js +95 -0
  99. package/dist/parse/parseQgsXml.d.ts +15 -0
  100. package/dist/parse/parseQgsXml.js +100 -0
  101. package/dist/parse/parseRelations.d.ts +19 -0
  102. package/dist/parse/parseRelations.js +64 -0
  103. package/dist/parse/parseStyle.d.ts +33 -0
  104. package/dist/parse/parseStyle.js +128 -0
  105. package/dist/parse/parseWmsPublishing.d.ts +21 -0
  106. package/dist/parse/parseWmsPublishing.js +38 -0
  107. package/dist/parse/projectProperties.d.ts +15 -0
  108. package/dist/parse/projectProperties.js +27 -0
  109. package/dist/parse/qgisExpression.d.ts +194 -0
  110. package/dist/parse/qgisExpression.js +859 -0
  111. package/dist/parse/qtDateFormat.d.ts +74 -0
  112. package/dist/parse/qtDateFormat.js +324 -0
  113. package/dist/parse/qtRegex.d.ts +67 -0
  114. package/dist/parse/qtRegex.js +397 -0
  115. package/dist/parse/readProjectFile.d.ts +7 -0
  116. package/dist/parse/readProjectFile.js +27 -0
  117. package/dist/sources/qgisServerUrl.d.ts +6 -0
  118. package/dist/sources/qgisServerUrl.js +17 -0
  119. package/dist/sources/stacDocuments.d.ts +40 -0
  120. package/dist/sources/stacDocuments.js +85 -0
  121. package/dist/sources/stacItems.d.ts +109 -0
  122. package/dist/sources/stacItems.js +287 -0
  123. package/dist/util/catalogueFileFormats.d.ts +58 -0
  124. package/dist/util/catalogueFileFormats.js +64 -0
  125. package/dist/util/devLog.d.ts +10 -0
  126. package/dist/util/devLog.js +22 -0
  127. package/dist/util/fileName.d.ts +18 -0
  128. package/dist/util/fileName.js +45 -0
  129. package/dist/util/nonBlankText.d.ts +2 -0
  130. package/dist/util/nonBlankText.js +4 -0
  131. package/dist/util/wfsVersions.d.ts +9 -0
  132. package/dist/util/wfsVersions.js +13 -0
  133. package/package.json +55 -4
  134. package/src/schema/quac.schema.json +939 -0
@@ -0,0 +1,44 @@
1
+ import type { StacCollection } from '../model/Stac.ts';
2
+ /**
3
+ * The fields a Collection for a file dropped onto the map is built from.
4
+ */
5
+ export interface DroppedFileCollectionOptions {
6
+ /** The layer's collection id. */
7
+ collectionId: string;
8
+ /** The file's path as dropped: its name for a loose file, or its folder path. */
9
+ relativePath: string;
10
+ /** When the file was dropped, as an ISO 8601 UTC time. */
11
+ uploadedAt: string;
12
+ /** The table read, where the file is a GeoPackage. */
13
+ layerName?: string | null;
14
+ }
15
+ /**
16
+ * The fields a Collection for a GeoJSON file loaded from a pasted link is built from.
17
+ */
18
+ export interface LinkedFileCollectionOptions {
19
+ /** The layer's collection id. */
20
+ collectionId: string;
21
+ /** The link the file was loaded from. */
22
+ url: string;
23
+ /** The file's name, taken from the link. */
24
+ filename: string;
25
+ /** When the file was loaded, as an ISO 8601 UTC time. */
26
+ loadedAt: string;
27
+ }
28
+ /**
29
+ * Generates the Collection for one dropped file: a `data` asset naming the file
30
+ * and its media type, `created` set to the drop time, and the world extent, which
31
+ * a Collection with no declared box takes. The file is not opened, so nothing
32
+ * here describes its contents, and it declares no title of its own.
33
+ *
34
+ * Pure function — no side effects, no I/O.
35
+ */
36
+ export declare function generateCollectionForDroppedFile(options: DroppedFileCollectionOptions): StacCollection;
37
+ /**
38
+ * Generates the Collection for one GeoJSON file loaded from a pasted link: the
39
+ * same as a dropped file's, with the link as the `data` asset's address. The
40
+ * link is only ever read as GeoJSON, whatever its file name says.
41
+ *
42
+ * Pure function — no side effects, no I/O.
43
+ */
44
+ export declare function generateCollectionForLinkedFile(options: LinkedFileCollectionOptions): StacCollection;
@@ -0,0 +1,72 @@
1
+ import { generateStacFromNormalized, slugify } from "./normalizedProject.js";
2
+ import { QUAC_LAYER_NAME } from "./stacCatalogue.js";
3
+ import { encodeAssetPath } from "../model/stacHref.js";
4
+ import { declaredMediaTypeForFile, GEOJSON_MEDIA_TYPE } from "../util/catalogueFileFormats.js";
5
+ /**
6
+ * Generates the Collection for one dropped file: a `data` asset naming the file
7
+ * and its media type, `created` set to the drop time, and the world extent, which
8
+ * a Collection with no declared box takes. The file is not opened, so nothing
9
+ * here describes its contents, and it declares no title of its own.
10
+ *
11
+ * Pure function — no side effects, no I/O.
12
+ */
13
+ export function generateCollectionForDroppedFile(options) {
14
+ const name = options.relativePath.split('/').pop() ?? options.relativePath;
15
+ return buildFileCollection({
16
+ collectionId: options.collectionId,
17
+ name,
18
+ href: `./${encodeAssetPath(options.relativePath)}`,
19
+ mediaType: declaredMediaTypeForFile(name, 'data'),
20
+ createdAt: options.uploadedAt,
21
+ layerName: options.layerName ?? null
22
+ });
23
+ }
24
+ /**
25
+ * Generates the Collection for one GeoJSON file loaded from a pasted link: the
26
+ * same as a dropped file's, with the link as the `data` asset's address. The
27
+ * link is only ever read as GeoJSON, whatever its file name says.
28
+ *
29
+ * Pure function — no side effects, no I/O.
30
+ */
31
+ export function generateCollectionForLinkedFile(options) {
32
+ return buildFileCollection({
33
+ collectionId: options.collectionId,
34
+ name: options.filename,
35
+ href: options.url,
36
+ mediaType: GEOJSON_MEDIA_TYPE,
37
+ createdAt: options.loadedAt
38
+ });
39
+ }
40
+ function buildFileCollection(file) {
41
+ const catalogue = generateStacFromNormalized({
42
+ id: slugify(file.name) || 'file',
43
+ title: file.name,
44
+ description: '',
45
+ bbox: null,
46
+ nodes: [{
47
+ kind: 'layer',
48
+ id: file.collectionId,
49
+ title: file.name,
50
+ description: '',
51
+ bbox: null,
52
+ geometryType: null,
53
+ tableColumns: [],
54
+ assets: {
55
+ data: {
56
+ href: file.href,
57
+ type: file.mediaType,
58
+ title: file.name,
59
+ roles: ['data'],
60
+ ...(file.layerName ? { [QUAC_LAYER_NAME]: file.layerName } : {})
61
+ }
62
+ },
63
+ created: file.createdAt,
64
+ displayField: null,
65
+ visibilityChecked: null,
66
+ editable: null
67
+ }]
68
+ });
69
+ const collection = catalogue.collections[0];
70
+ delete collection.title;
71
+ return collection;
72
+ }
@@ -0,0 +1,48 @@
1
+ import type { StacCatalog } from '../model/Stac.ts';
2
+ /**
3
+ * Generates a STAC Catalog for a cloud folder that holds layer files and no
4
+ * catalogue file of its own:
5
+ * the folder → top-level Catalog
6
+ * each data file → a Collection with a `data` asset
7
+ *
8
+ * Built from the folder's listing alone — no file is opened. A layer file
9
+ * has no header describing itself, so its extent and field schema can only
10
+ * be had by downloading and parsing the whole thing, which for a folder of
11
+ * large files would be paid on every visit whether or not those layers are ever
12
+ * switched on. Both are therefore left absent, which the profile already covers:
13
+ * a Collection with no declared box takes the world extent, and one with no
14
+ * declared schema simply has no `table:columns`. Both are read as each layer
15
+ * loads, exactly as they do for a WFS service.
16
+ *
17
+ * The folder declares no author intent, so the shared presentation fields are left off
18
+ * rather than invented — including `quac:editable`, which means nothing here forbids
19
+ * editing a layer.
20
+ *
21
+ * Pure function — no side effects, no I/O.
22
+ */
23
+ /** One data file the folder holds, as the caller read it from the listing. */
24
+ export interface FolderCatalogueFile {
25
+ /** Path inside the published folder — the Collection's id. */
26
+ relPath: string;
27
+ /** File name only, used as the asset's title. */
28
+ name: string;
29
+ /** Display name derived from the file name. */
30
+ layerName: string;
31
+ /** Media type for the `data` asset. */
32
+ mediaType: string;
33
+ /** Path of the sibling style file, when the folder holds one for this layer. */
34
+ styleRelPath: string | null;
35
+ /** The file's size in bytes from the listing, or null where the listing gives none. */
36
+ size: number | null;
37
+ }
38
+ export interface FolderStacCatalogueOptions {
39
+ /** The published folder's name, used as the Catalog's title. */
40
+ folderName: string;
41
+ /**
42
+ * The folder's own share link, recorded as the Catalog's `self` link. For a
43
+ * folder catalogue this is the only thing identifying where the layers come
44
+ * from, since no project file speaks for them.
45
+ */
46
+ selfHref?: string;
47
+ }
48
+ export declare function generateStacCatalogueFromFolder(files: FolderCatalogueFile[], options: FolderStacCatalogueOptions): StacCatalog;
@@ -0,0 +1,69 @@
1
+ import { generateStacFromNormalized, slugify, withSelfLink } from "./normalizedProject.js";
2
+ import { encodeAssetPath } from "../model/stacHref.js";
3
+ import { FILE_EXTENSION, FILE_SIZE_FIELD } from "../model/stacSizeAndCount.js";
4
+ import { DEFAULT_STYLE_ROLE, styleAssetKey } from "../model/stacStyles.js";
5
+ import { declaredMediaTypeForFile } from "../util/catalogueFileFormats.js";
6
+ export function generateStacCatalogueFromFolder(files, options) {
7
+ return withSelfLink(generateStacFromNormalized(folderToNormalized(files, options)), options.selfHref);
8
+ }
9
+ function folderToNormalized(files, options) {
10
+ return {
11
+ id: slugify(options.folderName) || 'folder',
12
+ title: options.folderName,
13
+ description: 'Layers published from a cloud folder.',
14
+ bbox: null,
15
+ nodes: files.map(fileToNormalized)
16
+ };
17
+ }
18
+ /** The style's name — the style file's own name, without folders or extension. */
19
+ function styleNameFromPath(relPath) {
20
+ const filename = relPath.split('/').pop() ?? relPath;
21
+ const dot = filename.lastIndexOf('.');
22
+ return dot > 0 ? filename.slice(0, dot) : filename;
23
+ }
24
+ function fileToNormalized(file) {
25
+ const assets = {
26
+ data: {
27
+ // The file's path in the folder, escaped: `#` and `?` are legal in a file
28
+ // name and would otherwise end the path when the href is read back.
29
+ href: `./${encodeAssetPath(file.relPath)}`,
30
+ type: file.mediaType,
31
+ title: file.name,
32
+ roles: ['data']
33
+ }
34
+ };
35
+ const hasSize = Number.isSafeInteger(file.size) && file.size > 0;
36
+ if (hasSize)
37
+ assets.data[FILE_SIZE_FIELD] = file.size;
38
+ // A style is declared, never embedded — a reader fetches it live on every load,
39
+ // the same as a style a project file refers to. Keyed by the style file's name so
40
+ // it reads as one entry in a style set, like every other source's styles.
41
+ if (file.styleRelPath) {
42
+ const styleName = styleNameFromPath(file.styleRelPath);
43
+ // `data.qml` beside `data.geojson` names its style after the data asset;
44
+ // keyed straight in, it would replace it and leave the layer unloadable.
45
+ assets[styleAssetKey(assets, styleName)] = {
46
+ href: `./${encodeAssetPath(file.styleRelPath)}`,
47
+ type: declaredMediaTypeForFile(file.styleRelPath, 'style'),
48
+ title: styleName,
49
+ // The folder has one style per layer, so it is that layer's default.
50
+ roles: ['style', DEFAULT_STYLE_ROLE]
51
+ };
52
+ }
53
+ return {
54
+ kind: 'layer',
55
+ id: file.relPath,
56
+ title: file.layerName,
57
+ description: `Layer from ${file.name}.`,
58
+ // Both read from the file at load time, not from the listing.
59
+ bbox: null,
60
+ geometryType: null,
61
+ tableColumns: [],
62
+ ...(hasSize ? { extensions: [FILE_EXTENSION] } : {}),
63
+ assets,
64
+ displayField: null,
65
+ // The folder declares no author intent, so none of these are invented.
66
+ visibilityChecked: null,
67
+ editable: null
68
+ };
69
+ }