@mailwoman/ogc 0.0.0-stage → 11.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 (52) hide show
  1. package/README.md +149 -2
  2. package/cli/main.ts +153 -0
  3. package/lib/app.ts +99 -0
  4. package/lib/collections.ts +159 -0
  5. package/lib/engine.ts +71 -0
  6. package/lib/format.ts +46 -0
  7. package/lib/html.ts +236 -0
  8. package/lib/index.ts +20 -0
  9. package/lib/projection.ts +206 -0
  10. package/lib/routes.ts +587 -0
  11. package/lib/schema.ts +296 -0
  12. package/out/app.d.ts +33 -0
  13. package/out/app.d.ts.map +1 -0
  14. package/out/app.js +67 -0
  15. package/out/app.js.map +1 -0
  16. package/out/cli/main.d.ts +3 -0
  17. package/out/cli/main.d.ts.map +1 -0
  18. package/out/cli/main.js +118 -0
  19. package/out/cli/main.js.map +1 -0
  20. package/out/collections.d.ts +72 -0
  21. package/out/collections.d.ts.map +1 -0
  22. package/out/collections.js +103 -0
  23. package/out/collections.js.map +1 -0
  24. package/out/engine.d.ts +65 -0
  25. package/out/engine.d.ts.map +1 -0
  26. package/out/engine.js +4 -0
  27. package/out/engine.js.map +1 -0
  28. package/out/format.d.ts +18 -0
  29. package/out/format.d.ts.map +1 -0
  30. package/out/format.js +31 -0
  31. package/out/format.js.map +1 -0
  32. package/out/html.d.ts +42 -0
  33. package/out/html.d.ts.map +1 -0
  34. package/out/html.js +153 -0
  35. package/out/html.js.map +1 -0
  36. package/out/index.d.ts +17 -0
  37. package/out/index.d.ts.map +1 -0
  38. package/out/index.js +19 -0
  39. package/out/index.js.map +1 -0
  40. package/out/projection.d.ts +26 -0
  41. package/out/projection.d.ts.map +1 -0
  42. package/out/projection.js +168 -0
  43. package/out/projection.js.map +1 -0
  44. package/out/routes.d.ts +93 -0
  45. package/out/routes.d.ts.map +1 -0
  46. package/out/routes.js +429 -0
  47. package/out/routes.js.map +1 -0
  48. package/out/schema.d.ts +267 -0
  49. package/out/schema.d.ts.map +1 -0
  50. package/out/schema.js +241 -0
  51. package/out/schema.js.map +1 -0
  52. package/package.json +98 -3
@@ -0,0 +1,103 @@
1
+ // SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
2
+ // SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
3
+ /**
4
+ * The table maps each collection's name to its id.
5
+ */
6
+ export const OGCCollectionID = {
7
+ Addresses: "addresses",
8
+ Streets: "streets",
9
+ Postcodes: "postcodes",
10
+ Places: "places",
11
+ PlusCodes: "plus-codes",
12
+ };
13
+ /**
14
+ * The title and description of every collection.
15
+ */
16
+ export const OGC_COLLECTION_CATALOG = {
17
+ [OGCCollectionID.Addresses]: {
18
+ title: "Addresses",
19
+ description: "House-grade coordinates: a matched address point, or a point interpolated along a street's address range.",
20
+ },
21
+ [OGCCollectionID.Streets]: {
22
+ title: "Streets",
23
+ description: "Street centroids, answering a street named without a house number.",
24
+ },
25
+ [OGCCollectionID.Postcodes]: {
26
+ title: "Postcodes",
27
+ description: "Postcode places from the gazetteer, located at the postcode's own coordinate.",
28
+ },
29
+ [OGCCollectionID.Places]: {
30
+ title: "Places",
31
+ description: "Gazetteer places: localities, districts, counties, regions and countries.",
32
+ },
33
+ [OGCCollectionID.PlusCodes]: {
34
+ title: "Plus codes",
35
+ description: "Open Location Codes the engine decodes to the center of their area. No data layer backs it.",
36
+ },
37
+ };
38
+ /**
39
+ * The collection that holds an answer the geocoder placed at `tier`.
40
+ *
41
+ * @returns Null for a tier no collection holds, such as `venue`, whose layer the OGC engine doesn't open.
42
+ */
43
+ export function collectionOfTier(tier) {
44
+ switch (tier) {
45
+ case "address_point":
46
+ case "interpolated":
47
+ return OGCCollectionID.Addresses;
48
+ case "street":
49
+ return OGCCollectionID.Streets;
50
+ case "postcode":
51
+ return OGCCollectionID.Postcodes;
52
+ case "admin":
53
+ return OGCCollectionID.Places;
54
+ case "plus_code":
55
+ return OGCCollectionID.PlusCodes;
56
+ case "venue":
57
+ return null;
58
+ }
59
+ }
60
+ /**
61
+ * The collection that holds a gazetteer place of `placetype`.
62
+ */
63
+ export function collectionOfPlacetype(placetype) {
64
+ return placetype === "postalcode" ? OGCCollectionID.Postcodes : OGCCollectionID.Places;
65
+ }
66
+ /**
67
+ * The collections an engine serves, from the layers its providers opened.
68
+ *
69
+ * The gazetteer is always open, because the engine refuses to start without one,
70
+ * so places, postcodes and plus codes are always served.
71
+ * Addresses and streets are served when some region has an address-point, interpolation
72
+ * or street-centroid layer, and their descriptions name those regions.
73
+ *
74
+ * A collection no region has a layer for is left out of the list.
75
+ *
76
+ * A provider opens a region's layers when asked for the region.
77
+ * A query for that region would open them as well.
78
+ */
79
+ export function servedCollections(probes) {
80
+ const addressRegions = new Set();
81
+ const streetRegions = new Set();
82
+ for (const { provider, keys, regionOf } of probes) {
83
+ for (const key of keys) {
84
+ const databases = provider.for(key);
85
+ if (databases.addressPoints || databases.interpolation) {
86
+ addressRegions.add(regionOf(key));
87
+ }
88
+ if (databases.streetCentroids) {
89
+ streetRegions.add(regionOf(key));
90
+ }
91
+ }
92
+ }
93
+ const served = [];
94
+ if (addressRegions.size) {
95
+ served.push({ id: OGCCollectionID.Addresses, regions: [...addressRegions].toSorted() });
96
+ }
97
+ if (streetRegions.size) {
98
+ served.push({ id: OGCCollectionID.Streets, regions: [...streetRegions].toSorted() });
99
+ }
100
+ served.push({ id: OGCCollectionID.Postcodes, regions: null }, { id: OGCCollectionID.Places, regions: null }, { id: OGCCollectionID.PlusCodes, regions: null });
101
+ return served;
102
+ }
103
+ //# sourceMappingURL=collections.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collections.js","sourceRoot":"","sources":["../lib/collections.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,kEAAkE;AAmBlE;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC9B,SAAS,EAAE,WAAW;IACtB,OAAO,EAAE,SAAS;IAClB,SAAS,EAAE,WAAW;IACtB,MAAM,EAA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,EAAE,EAC7C,EAAE,EAAE,EAAE,eAAe,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,CAChD,CAAA;IAED,OAAO,MAAM,CAAA;AACd,CAAC"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * The engine the OGC routes delegate to.
3
+ *
4
+ * The routes own validation, the collection and `bbox` filters, `limit` and the response envelope.
5
+ * The engine answers one query with every match it found, and lists the
6
+ * collections its opened layers serve.
7
+ */
8
+ import type { OGCCollectionID } from "#collections";
9
+ /**
10
+ * A collection the engine serves, and the regions its layers cover.
11
+ */
12
+ export interface OGCServedCollection {
13
+ id: OGCCollectionID;
14
+ /**
15
+ * The regions that have a layer the engine opened for this collection, such as `FR` or `US-TX`.
16
+ *
17
+ * Null when the collection isn't divided by region, as for the worldwide gazetteer.
18
+ */
19
+ regions: readonly string[] | null;
20
+ }
21
+ /**
22
+ * One match for a `/search` query.
23
+ */
24
+ export interface OGCSearchHit {
25
+ collectionID: OGCCollectionID;
26
+ lon: number;
27
+ lat: number;
28
+ displayName: string;
29
+ /**
30
+ * The engine's ranking score for the match, or null when the engine measured none.
31
+ */
32
+ score: number | null;
33
+ /**
34
+ * Why `score` is null, absent when it holds a value.
35
+ */
36
+ scoreUnmeasured?: string;
37
+ /**
38
+ * The gazetteer place ID of a place match, such as `wof:85975673`.
39
+ *
40
+ * Absent for an address, a street or a plus code, and for a place the gazetteer gave no ID.
41
+ */
42
+ placeID?: string;
43
+ /**
44
+ * The gazetteer placetype of a place match, such as `locality` or `postalcode`.
45
+ *
46
+ * Absent for an address, a street or a plus code.
47
+ */
48
+ placetype?: string;
49
+ }
50
+ /**
51
+ * The engine behind the OGC routes.
52
+ */
53
+ export interface OGCEngine {
54
+ /**
55
+ * The collections the engine serves, in the order `/collections` lists them.
56
+ */
57
+ readonly collections: readonly OGCServedCollection[];
58
+ /**
59
+ * Every match for `q`, best first.
60
+ *
61
+ * An empty array means the engine found no match.
62
+ */
63
+ search(q: string): Promise<OGCSearchHit[]>;
64
+ }
65
+ //# sourceMappingURL=engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../lib/engine.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAEnD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC,EAAE,EAAE,eAAe,CAAA;IACnB;;;;OAIG;IACH,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAAA;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B,YAAY,EAAE,eAAe,CAAA;IAC7B,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,WAAW,EAAE,MAAM,CAAA;IACnB;;OAEG;IACH,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACzB;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,SAAS,mBAAmB,EAAE,CAAA;IACpD;;;;OAIG;IACH,MAAM,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAAA;CAC1C"}
package/out/engine.js ADDED
@@ -0,0 +1,4 @@
1
+ // SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
2
+ // SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
3
+ export {};
4
+ //# sourceMappingURL=engine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine.js","sourceRoot":"","sources":["../lib/engine.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,kEAAkE"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Response encoding negotiation for the OGC API surface.
3
+ *
4
+ * OGC API Common negotiates the encoding through HTTP content negotiation
5
+ * and admits a query parameter that overrides it.
6
+ * The `f` parameter decides when present.
7
+ *
8
+ * Otherwise the `Accept` header decides, and JSON answers a request that names neither encoding.
9
+ */
10
+ import type { Context } from "hono";
11
+ import { OGCFormat } from "#schema";
12
+ /**
13
+ * The encoding a request asks for.
14
+ *
15
+ * @param f The validated `f` query parameter, absent when the request didn't send one.
16
+ */
17
+ export declare function negotiateFormat(c: Context, f: OGCFormat | undefined): OGCFormat;
18
+ //# sourceMappingURL=format.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../lib/format.ts"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAGnC,OAAO,EAAE,SAAS,EAAgB,MAAM,SAAS,CAAA;AAcjD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,CAU/E"}
package/out/format.js ADDED
@@ -0,0 +1,31 @@
1
+ // SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
2
+ // SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
3
+ import { accepts } from "hono/accepts";
4
+ import { OGCFormat, OGCMediaType } from "#schema";
5
+ /**
6
+ * The JSON media types a request may name in `Accept`, beside `text/html`.
7
+ *
8
+ * `/api` serves the OpenAPI media type and answers a request for plain JSON with it too,
9
+ * and `/search` serves GeoJSON the same way.
10
+ */
11
+ const JSON_MEDIA_TYPES = [
12
+ OGCMediaType.JSON,
13
+ OGCMediaType.GeoJSON,
14
+ "application/vnd.oai.openapi+json",
15
+ ];
16
+ /**
17
+ * The encoding a request asks for.
18
+ *
19
+ * @param f The validated `f` query parameter, absent when the request didn't send one.
20
+ */
21
+ export function negotiateFormat(c, f) {
22
+ if (f)
23
+ return f;
24
+ const matched = accepts(c, {
25
+ header: "Accept",
26
+ supports: [...JSON_MEDIA_TYPES, OGCMediaType.HTML],
27
+ default: OGCMediaType.JSON,
28
+ });
29
+ return matched === OGCMediaType.HTML ? OGCFormat.HTML : OGCFormat.JSON;
30
+ }
31
+ //# sourceMappingURL=format.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.js","sourceRoot":"","sources":["../lib/format.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,kEAAkE;AAalE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAEtC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAEjD;;;;;GAKG;AACH,MAAM,gBAAgB,GAAsB;IAC3C,YAAY,CAAC,IAAI;IACjB,YAAY,CAAC,OAAO;IACpB,kCAAkC;CAClC,CAAA;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,CAAU,EAAE,CAAwB;IACnE,IAAI,CAAC;QAAE,OAAO,CAAC,CAAA;IAEf,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,EAAE;QAC1B,MAAM,EAAE,QAAQ;QAChB,QAAQ,EAAE,CAAC,GAAG,gBAAgB,EAAE,YAAY,CAAC,IAAI,CAAC;QAClD,OAAO,EAAE,YAAY,CAAC,IAAI;KAC1B,CAAC,CAAA;IAEF,OAAO,OAAO,KAAK,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAA;AACvE,CAAC"}
package/out/html.d.ts ADDED
@@ -0,0 +1,42 @@
1
+ /**
2
+ * HTML encodings of the OGC API resources.
3
+ *
4
+ * OGC API Common's HTML class asks that an HTML response include everything the
5
+ * JSON response includes and render every link as an `<a>` element.
6
+ * Each page here renders from the same value the JSON route serves, so the two encodings can't disagree.
7
+ */
8
+ import type { OpenAPIHono } from "@hono/zod-openapi";
9
+ import type { OGCServedCollection } from "#engine";
10
+ import { type OGCCollection, type OGCCollections, type OGCConformance, type OGCLandingPage, type OGCLink, type OGCSearchResponse } from "#schema";
11
+ /**
12
+ * The OpenAPI 3.0 document the generator emits.
13
+ */
14
+ export type OpenAPI30Document = ReturnType<OpenAPIHono["getOpenAPIDocument"]>;
15
+ /**
16
+ * The landing page as HTML.
17
+ */
18
+ export declare function landingPageHTML(landing: OGCLandingPage): string;
19
+ /**
20
+ * The conformance declaration as HTML.
21
+ */
22
+ export declare function conformanceHTML(conformance: OGCConformance, links: readonly OGCLink[]): string;
23
+ /**
24
+ * The collections list as HTML.
25
+ */
26
+ export declare function collectionsHTML(body: OGCCollections): string;
27
+ /**
28
+ * One collection description as HTML.
29
+ */
30
+ export declare function collectionHTML(collection: OGCCollection): string;
31
+ /**
32
+ * The search form, with the results of a search when `body` holds one.
33
+ *
34
+ * @param collections The collections a checkbox can restrict the search to.
35
+ */
36
+ export declare function searchHTML(body: OGCSearchResponse | null, links: readonly OGCLink[], collections: readonly OGCServedCollection[], q?: string): string;
37
+ /**
38
+ * The API definition as HTML: each operation with its parameters and responses,
39
+ * read from the OpenAPI 3.0 document the JSON encoding serves.
40
+ */
41
+ export declare function apiDefinitionHTML(document: OpenAPI30Document, links: readonly OGCLink[]): string;
42
+ //# sourceMappingURL=html.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../lib/html.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAGpD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAClD,OAAO,EAEN,KAAK,aAAa,EAClB,KAAK,cAAc,EAEnB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,OAAO,EAEZ,KAAK,iBAAiB,EACtB,MAAM,SAAS,CAAA;AAEhB;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC,CAAA;AAyC7E;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,CAQ/D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,cAAc,EAAE,KAAK,EAAE,SAAS,OAAO,EAAE,GAAG,MAAM,CAe9F;AASD;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,cAAc,GAAG,MAAM,CAO5D;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,aAAa,GAAG,MAAM,CAEhE;AAaD;;;;GAIG;AACH,wBAAgB,UAAU,CACzB,IAAI,EAAE,iBAAiB,GAAG,IAAI,EAC9B,KAAK,EAAE,SAAS,OAAO,EAAE,EACzB,WAAW,EAAE,SAAS,mBAAmB,EAAE,EAC3C,CAAC,SAAK,GACJ,MAAM,CA2BR;AAoCD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,iBAAiB,EAAE,KAAK,EAAE,SAAS,OAAO,EAAE,GAAG,MAAM,CAiBhG"}
package/out/html.js ADDED
@@ -0,0 +1,153 @@
1
+ // SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
2
+ // SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
3
+ import { escapeHTML } from "@mailwoman/core/strings/escape";
4
+ import { collectionVersionParameter, OGC_COLLECTION_VERSION, } from "#schema";
5
+ const STYLE = `:root { color-scheme: light dark }
6
+ body { font: 16px/1.6 system-ui, -apple-system, sans-serif; max-width: 48rem; margin: 3rem auto; padding: 0 1.25rem }
7
+ h1 { font-size: 1.3rem; margin: 0 0 .5rem }
8
+ h2 { font-size: 1.1rem; margin: 1.5rem 0 .5rem }
9
+ code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace }
10
+ ul { padding-left: 1.2rem }
11
+ li { margin: .3rem 0 }
12
+ a { color: #2563eb }
13
+ .meta { opacity: .75; font-size: .9rem }`;
14
+ function page(title, body) {
15
+ return `<!doctype html>
16
+ <html lang="en">
17
+ <head>
18
+ <meta charset="utf-8">
19
+ <meta name="viewport" content="width=device-width, initial-scale=1">
20
+ <title>${escapeHTML(title)}</title>
21
+ <style>
22
+ ${STYLE}
23
+ </style>
24
+ </head>
25
+ <body>
26
+ ${body}
27
+ </body>
28
+ </html>
29
+ `;
30
+ }
31
+ function linkItem(link) {
32
+ const label = escapeHTML(link.title ?? link.href);
33
+ const meta = [link.rel, link.type].filter((part) => typeof part === "string").map(escapeHTML);
34
+ return `<li><a href="${escapeHTML(link.href)}" rel="${escapeHTML(link.rel)}">${label}</a> <span class="meta">${meta.join(" &middot; ")}</span></li>`;
35
+ }
36
+ function linkList(links) {
37
+ return `<ul>\n${links.map(linkItem).join("\n")}\n</ul>`;
38
+ }
39
+ /**
40
+ * The landing page as HTML.
41
+ */
42
+ export function landingPageHTML(landing) {
43
+ return page(landing.title, `<h1>${escapeHTML(landing.title)}</h1>
44
+ <p>${escapeHTML(landing.description)}</p>
45
+ <h2>Links</h2>
46
+ ${linkList(landing.links)}`);
47
+ }
48
+ /**
49
+ * The conformance declaration as HTML.
50
+ */
51
+ export function conformanceHTML(conformance, links) {
52
+ const classes = conformance.conformsTo.map((uri) => `<li><a href="${escapeHTML(uri)}"><code>${escapeHTML(uri)}</code></a></li>`);
53
+ return page("Conformance", `<h1>Conformance</h1>
54
+ <p>The API conforms to these conformance classes.</p>
55
+ <ul>
56
+ ${classes.join("\n")}
57
+ </ul>
58
+ <h2>Links</h2>
59
+ ${linkList(links)}`);
60
+ }
61
+ function collectionSection(collection, heading) {
62
+ return `<${heading}>${escapeHTML(collection.title)} <code>${escapeHTML(collection.id)}</code></${heading}>
63
+ <p>${escapeHTML(collection.description)}</p>
64
+ <p class="meta">Point features, version ${collection.version}</p>
65
+ ${linkList(collection.links)}`;
66
+ }
67
+ /**
68
+ * The collections list as HTML.
69
+ */
70
+ export function collectionsHTML(body) {
71
+ return page("Collections", `<h1>Collections</h1>
72
+ ${linkList(body.links)}
73
+ ${body.collections.map((collection) => collectionSection(collection, "h2")).join("\n")}`);
74
+ }
75
+ /**
76
+ * One collection description as HTML.
77
+ */
78
+ export function collectionHTML(collection) {
79
+ return page(collection.title, collectionSection(collection, "h1"));
80
+ }
81
+ function searchFeatureItem(feature) {
82
+ const [lon, lat] = feature.geometry.coordinates;
83
+ const { display_name, score, score_unmeasured, collection_id, place_id, placetype } = feature.properties;
84
+ const scoreText = score == null ? `score null (${score_unmeasured ?? "unmeasured"})` : `score ${score}`;
85
+ const identity = [placetype, place_id].filter((part) => typeof part === "string");
86
+ const meta = [collection_id, ...identity, `${lat}, ${lon}`, scoreText].map(escapeHTML).join(" &middot; ");
87
+ return `<li>${escapeHTML(display_name)} <span class="meta">${meta}</span></li>`;
88
+ }
89
+ /**
90
+ * The search form, with the results of a search when `body` holds one.
91
+ *
92
+ * @param collections The collections a checkbox can restrict the search to.
93
+ */
94
+ export function searchHTML(body, links, collections, q = "") {
95
+ const boxes = collections.map(({ id }) => `<label><input type="checkbox" name="${escapeHTML(collectionVersionParameter(id))}" value="${OGC_COLLECTION_VERSION}"> ${escapeHTML(id)}</label>`);
96
+ const results = body
97
+ ? `<h2>Results</h2>
98
+ <p class="meta">${body.numberReturned} returned at ${escapeHTML(body.timeStamp)}</p>
99
+ <ol>
100
+ ${body.features.map(searchFeatureItem).join("\n")}
101
+ </ol>`
102
+ : "";
103
+ return page("Search", `<h1>Search</h1>
104
+ <p>Forward geocoding. Leave every collection unchecked to search them all.</p>
105
+ <form method="get" action="search">
106
+ <input type="hidden" name="f" value="html">
107
+ <p><input type="search" name="q" value="${escapeHTML(q)}" required size="48" aria-label="Address or place"> <button type="submit">Search</button></p>
108
+ <p>${boxes.join(" ")}</p>
109
+ </form>
110
+ ${results}
111
+ <h2>Links</h2>
112
+ ${linkList(links)}`);
113
+ }
114
+ function operationHTML(method, path, operation) {
115
+ const parameters = (operation.parameters ?? []).map((parameter) => {
116
+ const required = parameter.required ? " (required)" : "";
117
+ const description = parameter.description ? `: ${escapeHTML(parameter.description)}` : "";
118
+ return `<li><code>${escapeHTML(parameter.name ?? "")}</code> in ${escapeHTML(parameter.in ?? "")}${required}${description}</li>`;
119
+ });
120
+ const responses = Object.entries(operation.responses ?? {}).map(([status, response]) => {
121
+ const mediaTypes = Object.keys(response.content ?? {}).map((type) => `<code>${escapeHTML(type)}</code>`);
122
+ return `<li><code>${escapeHTML(status)}</code> ${escapeHTML(response.description ?? "")} ${mediaTypes.join(", ")}</li>`;
123
+ });
124
+ return `<h2><code>${escapeHTML(method.toUpperCase())} ${escapeHTML(path)}</code></h2>
125
+ <p>${escapeHTML(operation.summary ?? "")}</p>
126
+ ${operation.description ? `<p>${escapeHTML(operation.description)}</p>` : ""}
127
+ <p>Parameters:</p>
128
+ <ul>
129
+ ${parameters.join("\n")}
130
+ </ul>
131
+ <p>Responses:</p>
132
+ <ul>
133
+ ${responses.join("\n")}
134
+ </ul>`;
135
+ }
136
+ /**
137
+ * The API definition as HTML: each operation with its parameters and responses,
138
+ * read from the OpenAPI 3.0 document the JSON encoding serves.
139
+ */
140
+ export function apiDefinitionHTML(document, links) {
141
+ const operations = [];
142
+ for (const [path, item] of Object.entries(document.paths ?? {})) {
143
+ for (const [method, operation] of Object.entries(item)) {
144
+ operations.push(operationHTML(method, path, operation));
145
+ }
146
+ }
147
+ return page(`${document.info.title} API definition`, `<h1>${escapeHTML(document.info.title)} API definition</h1>
148
+ <p>${escapeHTML(document.info.description ?? "")}</p>
149
+ <p class="meta">OpenAPI ${escapeHTML(document.openapi)}, version ${escapeHTML(document.info.version)}</p>
150
+ ${linkList(links)}
151
+ ${operations.join("\n")}`);
152
+ }
153
+ //# sourceMappingURL=html.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html.js","sourceRoot":"","sources":["../lib/html.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,kEAAkE;AAWlE,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,C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 @@
1
+ /**
2
+ * `@mailwoman/ogc` serves Mailwoman through the OGC API family of standards.
3
+ *
4
+ * It serves the OGC API Common Part 1 resources an OGC client reads first
5
+ * (the landing page, the conformance declaration and the API definition), the OGC API
6
+ * Common Part 2 collections, and forward geocoding at `/search` in PDOK's form.
7
+ * The conformance declaration names only the classes these routes implement.
8
+ */
9
+ export * from "#app";
10
+ export * from "#collections";
11
+ export * from "#engine";
12
+ export * from "#format";
13
+ export * from "#html";
14
+ export * from "#projection";
15
+ export * from "#routes";
16
+ export * from "#schema";
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AAEH,cAAc,MAAM,CAAA;AACpB,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA;AACvB,cAAc,OAAO,CAAA;AACrB,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA"}
package/out/index.js ADDED
@@ -0,0 +1,19 @@
1
+ // SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
2
+ // SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
3
+ /**
4
+ * `@mailwoman/ogc` serves Mailwoman through the OGC API family of standards.
5
+ *
6
+ * It serves the OGC API Common Part 1 resources an OGC client reads first
7
+ * (the landing page, the conformance declaration and the API definition), the OGC API
8
+ * Common Part 2 collections, and forward geocoding at `/search` in PDOK's form.
9
+ * The conformance declaration names only the classes these routes implement.
10
+ */
11
+ export * from "#app";
12
+ export * from "#collections";
13
+ export * from "#engine";
14
+ export * from "#format";
15
+ export * from "#html";
16
+ export * from "#projection";
17
+ export * from "#routes";
18
+ export * from "#schema";
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,kEAAkE;AAElE;;;;;;;GAOG;AAEH,cAAc,MAAM,CAAA;AACpB,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA;AACvB,cAAc,OAAO,CAAA;AACrB,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA"}
@@ -0,0 +1,26 @@
1
+ import type { GeocodeResult } from "@mailwoman/core/geocode";
2
+ import { type Ancestor } from "@mailwoman/core/resolver";
3
+ import type { OGCSearchHit } from "#engine";
4
+ /**
5
+ * Reads a gazetteer place's ancestors by WOF id, nearest first, as `ResolverBackend.ancestors` does.
6
+ */
7
+ export type AncestorsOf = (wofID: number) => readonly Ancestor[];
8
+ /**
9
+ * The `/search` matches for one geocode result, best first.
10
+ *
11
+ * The answer's own coordinate comes first.
12
+ * Its score is the resolver's score for the gazetteer place it came from.
13
+ *
14
+ * An answer placed by an address point, an interpolation or a street centroid
15
+ * has no measured score, so its score is null.
16
+ *
17
+ * The places the resolver weighed for the same span as its first candidate follow, each with its own score.
18
+ * The result lists at most 10 places for a span, so a call reads at most 10 ancestries.
19
+ *
20
+ * @param ancestorsOf The gazetteer's ancestry reader.
21
+ * The label of each place lists the region and county it returns.
22
+ * Absent, a place's label is its name and its country.
23
+ * @returns An empty array when the result has no coordinate.
24
+ */
25
+ export declare function geocodeSearchHits(result: GeocodeResult, ancestorsOf?: AncestorsOf): OGCSearchHit[];
26
+ //# sourceMappingURL=projection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projection.d.ts","sourceRoot":"","sources":["../lib/projection.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAoB,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAC9E,OAAO,EAAE,KAAK,QAAQ,EAA2C,MAAM,0BAA0B,CAAA;AAGjG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAqE3C;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,SAAS,QAAQ,EAAE,CAAA;AAqChE;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,aAAa,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,YAAY,EAAE,CA6DlG"}