@mailwoman/photon 10.0.0 → 10.1.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 (45) hide show
  1. package/README.md +2 -2
  2. package/{lib/cli.ts → cli/main.ts} +40 -54
  3. package/lib/app.ts +13 -18
  4. package/lib/engine.ts +13 -5
  5. package/lib/index.ts +6 -11
  6. package/lib/locality-postcode.ts +9 -13
  7. package/lib/projection.ts +60 -55
  8. package/lib/routes.ts +9 -21
  9. package/lib/schema.ts +31 -24
  10. package/out/app.d.ts +13 -14
  11. package/out/app.d.ts.map +1 -1
  12. package/out/app.js +4 -11
  13. package/out/app.js.map +1 -1
  14. package/out/cli/main.d.ts +12 -0
  15. package/out/cli/main.d.ts.map +1 -0
  16. package/out/{cli.js → cli/main.js} +40 -54
  17. package/out/cli/main.js.map +1 -0
  18. package/out/engine.d.ts +13 -5
  19. package/out/engine.d.ts.map +1 -1
  20. package/out/engine.js +2 -2
  21. package/out/engine.js.map +1 -1
  22. package/out/index.d.ts +6 -11
  23. package/out/index.d.ts.map +1 -1
  24. package/out/index.js +6 -11
  25. package/out/index.js.map +1 -1
  26. package/out/locality-postcode.d.ts +4 -7
  27. package/out/locality-postcode.d.ts.map +1 -1
  28. package/out/locality-postcode.js +8 -12
  29. package/out/locality-postcode.js.map +1 -1
  30. package/out/projection.d.ts +48 -38
  31. package/out/projection.d.ts.map +1 -1
  32. package/out/projection.js +37 -35
  33. package/out/projection.js.map +1 -1
  34. package/out/routes.d.ts +2 -2
  35. package/out/routes.d.ts.map +1 -1
  36. package/out/routes.js +9 -21
  37. package/out/routes.js.map +1 -1
  38. package/out/schema.d.ts +29 -22
  39. package/out/schema.d.ts.map +1 -1
  40. package/out/schema.js +31 -24
  41. package/out/schema.js.map +1 -1
  42. package/package.json +47 -31
  43. package/out/cli.d.ts +0 -17
  44. package/out/cli.d.ts.map +0 -1
  45. package/out/cli.js.map +0 -1
package/lib/routes.ts CHANGED
@@ -4,8 +4,8 @@
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
6
  * Route definitions + handlers for the Photon-compatible surface. The OpenAPI document is
7
- * emitted from these definitions — no handwritten spec. Handlers parse params from the
8
- * `legacyQuery` express-shaped view; the zod query schemas drive only the emitted document.
7
+ * emitted from these definitions, so no handwritten spec exists. Handlers parse params from
8
+ * the `legacyQuery` express-shaped view. The zod query schemas drive only the emitted document.
9
9
  */
10
10
 
11
11
  import { createRoute, type OpenAPIHono, z } from "@hono/zod-openapi"
@@ -16,24 +16,12 @@ import type { PhotonEngine, PhotonFeatureCollection, PhotonReverseParams, Photon
16
16
  import { photonToSchemaOrg } from "#projection"
17
17
  import { PhotonMessageCollectionSchema, PhotonResponseSchema, reverseQueryParams, searchQueryParams } from "#schema"
18
18
 
19
- /**
20
- * Southern limit of latitude in WGS-84 degrees.
21
- */
22
19
  const MIN_LATITUDE = -90
23
20
 
24
- /**
25
- * Northern limit of latitude in WGS-84 degrees.
26
- */
27
21
  const MAX_LATITUDE = 90
28
22
 
29
- /**
30
- * Western limit of longitude in WGS-84 degrees.
31
- */
32
23
  const MIN_LONGITUDE = -180
33
24
 
34
- /**
35
- * Eastern limit of longitude in WGS-84 degrees.
36
- */
37
25
  const MAX_LONGITUDE = 180
38
26
 
39
27
  const DEFAULT_LIMIT = 15
@@ -48,10 +36,10 @@ function asStringArray(raw: unknown): string[] | undefined {
48
36
  }
49
37
 
50
38
  /**
51
- * A friendly HTML landing page for `GET /` (#1022). Upstream komoot/photon serves no root page, so there's no wire
52
- * contract to match — this is pure courtesy: a browser visitor (or an evaluator kicking the tires) who pastes the bare
53
- * host in gets a one-glance orientation with clickable example queries instead of Express's `Cannot GET /` 404, which
54
- * reads as "the service is broken". Relative example URLs so they resolve against whatever host/port serves this.
39
+ * A friendly html landing page for `GET /`.
40
+ *
41
+ * Upstream komoot/photon serves no root page, so there is no wire interface to match.
42
+ * Relative example URLs resolve against whatever host and port serve this.
55
43
  */
56
44
  const ROOT_HTML = `<!doctype html>
57
45
  <html lang="en">
@@ -73,7 +61,7 @@ footer { margin-top: 2rem; font-size: .9rem; opacity: .8 }
73
61
  </head>
74
62
  <body>
75
63
  <h1>@mailwoman/photon</h1>
76
- <p>A Photon-compatible autocomplete geocoding API — the same <code>/api</code> and <code>/reverse</code> contract, served from a SQLite gazetteer instead of an Elasticsearch cluster.</p>
64
+ <p>A Photon-compatible autocomplete geocoding API — the same <code>/api</code> and <code>/reverse</code> interface, served from a SQLite gazetteer instead of an Elasticsearch cluster.</p>
77
65
  <p>Try a query:</p>
78
66
  <ul>
79
67
  <li><a class="q" href="/api?q=berlin&amp;limit=3">/api?q=berlin&amp;limit=3</a></li>
@@ -154,7 +142,7 @@ export function registerPhotonRoutes(app: OpenAPIHono, engine: PhotonEngine, sta
154
142
 
155
143
  const collection = await engine.search(params)
156
144
 
157
- // #1052: `format=jsonld` re-serializes the SAME FeatureCollection as schema.org `Place[]` JSON-LD.
145
+ // `format=jsonld` re-serializes the FeatureCollection as schema.org `Place[]` JSON-LD.
158
146
  if (asString(q["format"]) === "jsonld") {
159
147
  return c.json(photonToSchemaOrg(collection), 200)
160
148
  }
@@ -186,7 +174,7 @@ export function registerPhotonRoutes(app: OpenAPIHono, engine: PhotonEngine, sta
186
174
 
187
175
  const collection = await engine.reverse(params)
188
176
 
189
- // #1052: `format=jsonld` re-serializes the reverse FeatureCollection as schema.org `Place[]` JSON-LD.
177
+ // `format=jsonld` re-serializes the reverse FeatureCollection as schema.org `Place[]` JSON-LD.
190
178
  if (asString(q["format"]) === "jsonld") {
191
179
  return c.json(photonToSchemaOrg(collection), 200)
192
180
  }
package/lib/schema.ts CHANGED
@@ -3,17 +3,17 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * Zod wire schemas for the Photon-compatible surface. Key names and envelopes are the vendor
7
- * contract — immutable. Query schemas are validator-proof by construction (unions accepting
8
- * string or repeated values) with doc-exact `.openapi()` overrides: validation can never fail,
9
- * and every wire decision stays in the handlers (see routes.ts's legacyQuery adapter).
6
+ * Zod schemas for the Photon-compatible API. Key names and envelopes match Photon and must not
7
+ * change. The query schemas accept any string or string array, so validation never fails. The
8
+ * handlers in `routes.ts` do the actual parsing.
10
9
  */
11
10
 
12
11
  import { z } from "@hono/zod-openapi"
13
12
  import { featureCollectionSchema, featureSchema, stampedResponseSchema } from "@mailwoman/api-kit"
14
13
 
15
14
  /**
16
- * Photon feature properties — OSM-derived keys; tolerant of extras (`[key: string]: unknown` on the wire type).
15
+ * Photon feature properties with OSM-derived keys.
16
+ * Extra keys are allowed.
17
17
  */
18
18
  export const PhotonPropertiesSchema = z
19
19
  .object({
@@ -38,18 +38,19 @@ export const PhotonPropertiesSchema = z
38
38
  .openapi("PhotonProperties")
39
39
 
40
40
  /**
41
- * One Photon result feature — GeoJSON geometry plus Photon's property block.
41
+ * One Photon result feature with GeoJSON geometry and Photon's properties.
42
42
  */
43
43
  export const PhotonFeatureSchema = featureSchema(PhotonPropertiesSchema).openapi("PhotonFeature")
44
44
 
45
45
  /**
46
- * Response body of `/api`, a GeoJSON FeatureCollection as Photon returns it.
46
+ * A GeoJSON FeatureCollection of Photon features.
47
47
  */
48
48
  export const PhotonFeatureCollectionSchema =
49
49
  featureCollectionSchema(PhotonFeatureSchema).openapi("PhotonFeatureCollection")
50
50
 
51
51
  /**
52
- * The error/degenerate envelope: an EMPTY FeatureCollection carrying a message. Never `{error}` on this surface.
52
+ * The error envelope is an empty FeatureCollection with a message.
53
+ * Photon does not use an `{ error }` body.
53
54
  */
54
55
  export const PhotonMessageCollectionSchema = z
55
56
  .object({
@@ -60,10 +61,10 @@ export const PhotonMessageCollectionSchema = z
60
61
  .openapi("PhotonMessageCollection")
61
62
 
62
63
  /**
63
- * The schema.org [`GeoCoordinates`](https://schema.org/GeoCoordinates) node — mirrors `@mailwoman/annotations`'s
64
- * `SchemaOrgGeoCoordinates` interface. Hand-modeled locally (no import from `@mailwoman/annotations`) matching this
65
- * package's existing wire-schema convention: each surface owns its own doc-accuracy schemas rather than sharing a
66
- * schema across the package boundary.
64
+ * The schema.org [`GeoCoordinates`](https://schema.org/GeoCoordinates) node.
65
+ *
66
+ * It mirrors the `SchemaOrgGeoCoordinates` interface in `@mailwoman/annotations`.
67
+ * Each API package defines its own schemas, so this one is written out here.
67
68
  */
68
69
  export const SchemaOrgGeoCoordinatesSchema = z
69
70
  .object({
@@ -74,7 +75,8 @@ export const SchemaOrgGeoCoordinatesSchema = z
74
75
  .openapi("SchemaOrgGeoCoordinates")
75
76
 
76
77
  /**
77
- * The schema.org [`PostalAddress`](https://schema.org/PostalAddress) node — mirrors `SchemaOrgPostalAddress`.
78
+ * The schema.org [`PostalAddress`](https://schema.org/PostalAddress) node.
79
+ * It mirrors `SchemaOrgPostalAddress`.
78
80
  */
79
81
  export const SchemaOrgPostalAddressSchema = z
80
82
  .object({
@@ -89,8 +91,9 @@ export const SchemaOrgPostalAddressSchema = z
89
91
  .openapi("SchemaOrgPostalAddress")
90
92
 
91
93
  /**
92
- * The `format=jsonld` re-serialization (#1052) — mirrors `@mailwoman/annotations`'s `SchemaOrgPlace` interface, the
93
- * shape `photonToSchemaOrg` actually produces.
94
+ * The `format=jsonld` output.
95
+ *
96
+ * It mirrors the `SchemaOrgPlace` interface that `photonToSchemaOrg` produces.
94
97
  */
95
98
  export const SchemaOrgPlaceSchema = z
96
99
  .object({
@@ -103,8 +106,10 @@ export const SchemaOrgPlaceSchema = z
103
106
  .openapi("SchemaOrgPlace")
104
107
 
105
108
  /**
106
- * The FeatureCollection as a route returns it — the collection plus the optional `engine` stamp. Named because it is a
107
- * union arm: an unnamed arm is inlined, and a generated client then names the variant after its position.
109
+ * The FeatureCollection with the optional `engine` stamp.
110
+ *
111
+ * The schema has an OpenAPI name because it is a union member.
112
+ * A generated client would otherwise label an inlined member by its position.
108
113
  */
109
114
  export const StampedPhotonFeatureCollectionSchema = stampedResponseSchema(
110
115
  PhotonFeatureCollectionSchema,
@@ -112,22 +117,24 @@ export const StampedPhotonFeatureCollectionSchema = stampedResponseSchema(
112
117
  )
113
118
 
114
119
  /**
115
- * The real `/api` + `/reverse` 200 response union (#1052 doc accuracy): a GeoJSON FeatureCollection by default, or an
116
- * array of schema.org `Place` JSON-LD objects when `format=jsonld` — see `routes.ts`'s handlers (`photonToSchemaOrg`).
117
- * Doc-only; the wire behavior is unchanged.
120
+ * The `/api` and `/reverse` 200 response for the OpenAPI document.
121
+ *
122
+ * The response is a GeoJSON FeatureCollection by default or an array of schema.org
123
+ * `Place` objects for `format=jsonld`.
118
124
  */
119
125
  export const PhotonResponseSchema = z
120
126
  .union([StampedPhotonFeatureCollectionSchema, z.array(SchemaOrgPlaceSchema)])
121
127
  .openapi("PhotonResponse")
122
128
 
123
129
  /**
124
- * A query param that may legally repeat (or that a client may repeat without the validator being allowed to answer for
125
- * us). Validator-proof: accepts one value or many; the doc override keeps the emitted parameter schema exact.
130
+ * A query parameter that accepts one value or a repeated value.
131
+ * Each use sets its documented type with `.openapi()`.
126
132
  */
127
133
  const tolerantParam = z.union([z.string(), z.array(z.string())]).optional()
128
134
 
129
135
  /**
130
- * `GET /api` query — documented shape; presence/parsing enforced in-handler.
136
+ * The documented query parameters of `GET /api`.
137
+ * The handler checks and parses them.
131
138
  */
132
139
  export const searchQueryParams = z.object({
133
140
  q: tolerantParam.openapi({ type: "string", description: "The query string to search for." }),
@@ -145,7 +152,7 @@ export const searchQueryParams = z.object({
145
152
  })
146
153
 
147
154
  /**
148
- * `GET /reverse` query.
155
+ * The documented query parameters of `GET /reverse`.
149
156
  */
150
157
  export const reverseQueryParams = z.object({
151
158
  lat: tolerantParam.openapi({ type: "number", description: "Latitude." }),
package/out/app.d.ts CHANGED
@@ -2,9 +2,6 @@
2
2
  * @copyright Sister Software
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
- *
6
- * The Photon-compatible Hono app: CORS + error safety net + routes + the emitted OpenAPI
7
- * document. Engine-agnostic — the CLI wires the real engine; tests inject fixtures.
8
5
  */
9
6
  import { OpenAPIHono } from "@hono/zod-openapi";
10
7
  import { type OpenAPIDocInfo } from "@mailwoman/api-kit";
@@ -15,27 +12,29 @@ import type { PhotonEngine } from "#engine";
15
12
  */
16
13
  export interface PhotonAppOptions {
17
14
  /**
18
- * Emit permissive CORS headers (`Access-Control-Allow-Origin: *`) on every response and answer preflight `OPTIONS`
19
- * with `204`. Default `true` — upstream komoot/photon serves permissive CORS, and the map-widget use case
20
- * (leaflet-control-geocoder, @openrunner/photon-geocoder, …) needs it: a browser's cross-origin XHR is blocked
21
- * without it (#1017). Set `false` when a reverse proxy already owns the CORS headers.
15
+ * Whether to send permissive CORS headers and answer preflight `OPTIONS` requests.
16
+ *
17
+ * It defaults to true because browser map widgets call Photon from other origins.
18
+ * Set it to `false` when a reverse proxy already sets the CORS headers.
22
19
  */
23
20
  cors?: boolean;
24
21
  /**
25
- * The engine stamp to carry on every response: `engine` as a foreign member of each FeatureCollection, and the
26
- * `Server` + `Link: rel="license"` headers everywhere. Absent when an embedding application builds the app without
27
- * the `mailwoman` package; the `photon` bin always passes one.
22
+ * The engine stamp added to every FeatureCollection and sent in the `Server`
23
+ * and `Link: rel="license"` headers.
24
+ *
25
+ * The `photon` command always passes one.
26
+ * An embedding application may omit it.
28
27
  */
29
28
  engine?: EngineStamp;
30
29
  }
31
30
  /**
32
- * The document info stamped into the emitted OpenAPI document. Exported (not inlined) so the CLI's `openapi` subcommand
33
- * can call `emitOpenAPIDocuments` with the SAME info the mounted `/openapi.json` route (below, via
34
- * {@link attachOpenAPIDocs}) uses — one source of truth, no risk of the two drifting.
31
+ * The OpenAPI document info for the Photon API.
32
+ *
33
+ * The served `/openapi.json` route and the CLI's `openapi` subcommand both use it.
35
34
  */
36
35
  export declare const PHOTON_DOC_INFO: OpenAPIDocInfo;
37
36
  /**
38
- * Build the Photon-compatible app around an injected {@link PhotonEngine}.
37
+ * Builds the Photon-compatible app around the given {@link PhotonEngine}.
39
38
  */
40
39
  export declare function createPhotonApp(engine: PhotonEngine, options?: PhotonAppOptions): OpenAPIHono;
41
40
  //# sourceMappingURL=app.d.ts.map
package/out/app.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../lib/app.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAoC,KAAK,cAAc,EAA0B,MAAM,oBAAoB,CAAA;AAClH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAG1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAG3C;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC;;;;;OAKG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;IAEd;;;;OAIG;IACH,MAAM,CAAC,EAAE,WAAW,CAAA;CACpB;AAED;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAE,cAmB7B,CAAA;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,GAAE,gBAAqB,GAAG,WAAW,CAqBjG"}
1
+ {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../lib/app.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAoC,KAAK,cAAc,EAA0B,MAAM,oBAAoB,CAAA;AAClH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAG1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAG3C;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC;;;;;OAKG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;IAEd;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,WAAW,CAAA;CACpB;AAED;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAE,cAmB7B,CAAA;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,GAAE,gBAAqB,GAAG,WAAW,CAiBjG"}
package/out/app.js CHANGED
@@ -2,18 +2,15 @@
2
2
  * @copyright Sister Software
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
- *
6
- * The Photon-compatible Hono app: CORS + error safety net + routes + the emitted OpenAPI
7
- * document. Engine-agnostic — the CLI wires the real engine; tests inject fixtures.
8
5
  */
9
6
  import { OpenAPIHono } from "@hono/zod-openapi";
10
7
  import { attachOpenAPIDocs, engineHeaders, readServedDocumentInfo } from "@mailwoman/api-kit";
11
8
  import { cors } from "hono/cors";
12
9
  import { registerPhotonRoutes } from "#routes";
13
10
  /**
14
- * The document info stamped into the emitted OpenAPI document. Exported (not inlined) so the CLI's `openapi` subcommand
15
- * can call `emitOpenAPIDocuments` with the SAME info the mounted `/openapi.json` route (below, via
16
- * {@link attachOpenAPIDocs}) uses — one source of truth, no risk of the two drifting.
11
+ * The OpenAPI document info for the Photon API.
12
+ *
13
+ * The served `/openapi.json` route and the CLI's `openapi` subcommand both use it.
17
14
  */
18
15
  export const PHOTON_DOC_INFO = {
19
16
  ...(await readServedDocumentInfo(import.meta.url, "@mailwoman/photon")),
@@ -36,20 +33,16 @@ export const PHOTON_DOC_INFO = {
36
33
  ],
37
34
  };
38
35
  /**
39
- * Build the Photon-compatible app around an injected {@link PhotonEngine}.
36
+ * Builds the Photon-compatible app around the given {@link PhotonEngine}.
40
37
  */
41
38
  export function createPhotonApp(engine, options = {}) {
42
39
  const app = new OpenAPIHono();
43
- // Browser-embedded widgets need CORS or their cross-origin XHR is blocked before the request completes (#1017).
44
- // GET-only — photon has no mutating routes, so unlike libpostal's CORS there is no POST in the methods list.
45
40
  if (options.cors !== false) {
46
41
  app.use(cors({ origin: "*", allowMethods: ["GET", "OPTIONS"], allowHeaders: ["*"], maxAge: 86_400 }));
47
42
  }
48
43
  if (options.engine) {
49
44
  app.use(engineHeaders(options.engine));
50
45
  }
51
- // Safety net: malformed input or an engine fault returns an empty FeatureCollection, never a crash (photon's
52
- // envelope — NOT `{error}`, which is the libpostal/nominatim shape).
53
46
  app.onError((_error, c) => c.json({ type: "FeatureCollection", features: [], message: "internal error" }, 500));
54
47
  registerPhotonRoutes(app, engine, options.engine);
55
48
  attachOpenAPIDocs(app, PHOTON_DOC_INFO);
package/out/app.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"app.js","sourceRoot":"","sources":["../lib/app.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAuB,sBAAsB,EAAE,MAAM,oBAAoB,CAAA;AAElH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAGhC,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAsB9C;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAmB;IAC9C,GAAG,CAAC,MAAM,sBAAsB,CAAC,OAAO,IAAI,CAAC,GAAG,EAAE,mBAAmB,CAAC,CAAC;IACvE,OAAO,EAAE,EAAE,IAAI,EAAE,wCAAwC,EAAE,UAAU,EAAE,eAAe,EAAE;IACxF,OAAO,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE,GAAG,EAAE,sBAAsB,EAAE;IACjE,YAAY,EAAE;QACb,WAAW,EAAE,mBAAmB;QAChC,GAAG,EAAE,oEAAoE;KACzE;IACD,OAAO,EAAE;QACR;YACC,GAAG,EAAE,sBAAsB;YAC3B,SAAS,EAAE,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE;SACxE;KACD;IACD,QAAQ,EAAE,EAAE;IACZ,IAAI,EAAE;QACL,EAAE,IAAI,EAAE,WAAW,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AAE,CAAC,CAAC,CAAA;IACtG,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACpB,GAAG,CAAC,GAAG,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;IACvC,CAAC;IAED,GAAG,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,mBAAmB,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,gBAAgB,EAAE,EAAE,GAAG,CAAC,CAAC,CAAA;IAE/G,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;IACjD,iBAAiB,CAAC,GAAG,EAAE,eAAe,CAAC,CAAA;IAEvC,OAAO,GAAG,CAAA;AACX,CAAC"}
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @copyright Sister Software
4
+ * @license AGPL-3.0
5
+ * @author Teffen Ellis, et al.
6
+ *
7
+ * `mailwoman-photon` — boot a Photon-compatible autocomplete endpoint via the `serve` command, wiring
8
+ * `/api` over `geocodeAddress` (parse → resolve) and `/reverse` over `WOFReverseGeocoder` into Photon's
9
+ * GeoJSON FeatureCollection.
10
+ */
11
+ export {};
12
+ //# sourceMappingURL=main.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../cli/main.ts"],"names":[],"mappings":";AACA;;;;;;;;GAQG"}
@@ -4,24 +4,19 @@
4
4
  * @license AGPL-3.0
5
5
  * @author Teffen Ellis, et al.
6
6
  *
7
- * `mailwoman-photon` — boot a Photon-compatible autocomplete endpoint via the `serve` command.
8
- * Usage
9
- *
10
- * - Examples live in the package README.
11
- *
12
- * Wires the real engine: `/api` over `geocodeAddress` (parse → resolve), `/reverse` over
13
- * `WOFReverseGeocoder`, projecting results into Photon's GeoJSON FeatureCollection. The FST
14
- * autocomplete tier is the eventual front for `/api`; geocode resolution is the MVP path.
7
+ * `mailwoman-photon` — boot a Photon-compatible autocomplete endpoint via the `serve` command, wiring
8
+ * `/api` over `geocodeAddress` (parse → resolve) and `/reverse` over `WOFReverseGeocoder` into Photon's
9
+ * GeoJSON FeatureCollection.
15
10
  */
16
11
  import { serveNode } from "@mailwoman/api-kit";
17
12
  import { matchCountry } from "@mailwoman/codex/country";
18
- import { pyTitle } from "@mailwoman/core";
13
+ import { dataRootPath } from "@mailwoman/core/data-root";
19
14
  import { parseArguments } from "@mailwoman/core/scripting/arguments";
20
- import { mailwomanDataRoot } from "@mailwoman/core/utils";
21
15
  import { createWOFResolver } from "@mailwoman/resolver";
22
- import { corsBannerLine, gazetteerBannerLines, loadClassifierOrExit, openAPICommand, resolveGazetteerOrExit, runDropInCLI, } from "mailwoman/cli-kit/dropin";
23
- import { geocodeAddress, RegionDatabaseProvider } from "mailwoman/geocode";
16
+ import { corsBannerLine, gazetteerBannerLines, loadClassifierOrExit, openAPICommand, resolveGazetteerOrExit, runDropInCLI, } from "mailwoman/cli/kit/dropin";
17
+ import { geocodeAddress, USStateDatabaseProvider } from "mailwoman/geocode";
24
18
  import { createResolverBackend } from "mailwoman/resolver-backend";
19
+ import { titleCase } from "spliterator";
25
20
  import { createPhotonApp, PHOTON_DOC_INFO, photonCollection, photonFeature, photonForwardCollection, photonOSMTags, } from "#index";
26
21
  import { createLocalityPostcodeLookup } from "#locality-postcode";
27
22
  /**
@@ -36,7 +31,9 @@ const PLACETYPE_TO_KEY = {
36
31
  country: "country",
37
32
  };
38
33
  /**
39
- * A real address fits comfortably; longer is malformed input (and would exceed the model's window).
34
+ * A real address fits comfortably.
35
+ *
36
+ * Longer input is malformed and would exceed the model's window.
40
37
  */
41
38
  const MAX_QUERY_LEN = 512;
42
39
  const BINARY_NAME = "mailwoman-photon";
@@ -46,8 +43,8 @@ async function serve(engineStamp) {
46
43
  port: { type: "string", default: "2322" },
47
44
  host: { type: "string", default: "0.0.0.0" },
48
45
  "candidate-db": { type: "string" },
49
- // Permissive CORS is on by default (upstream Photon parity — browser widgets need it). `--no-cors`
50
- // turns it off for deployments where a reverse proxy already sets the headers.
46
+ // Permissive CORS is on by default for upstream Photon parity; `--no-cors` turns it off
47
+ // where a reverse proxy already sets the headers.
51
48
  cors: { type: "boolean", default: true },
52
49
  },
53
50
  allowNegative: true,
@@ -61,66 +58,56 @@ async function serve(engineStamp) {
61
58
  const classifier = await loadClassifierOrExit();
62
59
  const backend = await createResolverBackend(resolverMod, { wofPaths, candidateDB });
63
60
  const resolver = createWOFResolver(backend);
64
- const extracts = await RegionDatabaseProvider.create(resolverMod, mailwomanDataRoot());
61
+ const extracts = await USStateDatabaseProvider.create(resolverMod, dataRootPath());
65
62
  const postcodeOfLocality = await createLocalityPostcodeLookup();
66
- // National open-register rooftop tier (#1012): BAN-FR ahead of the OSM tier for a non-US parse. A no-op
67
- // when the extract isn't on disk (conditioned on existsSync inside the provider), so the endpoint degrades cleanly.
68
- const { BANRegionDatabaseProvider } = await import("@mailwoman/ban/sdk");
69
- const banExtracts = await BANRegionDatabaseProvider.create(mailwomanDataRoot());
63
+ // National open-register rooftop tier: BAN-FR ahead of the OSM tier for a non-US parse,
64
+ // a no-op when the extract is absent.
65
+ const { BANRegionDatabaseProvider } = await import("@mailwoman/ban/region-database-provider");
66
+ const banExtracts = await BANRegionDatabaseProvider.create(dataRootPath());
70
67
  const reverseGeo = adminDBPath ? new resolverMod.WOFReverseGeocoder({ adminDBPath }) : undefined;
71
68
  const engine = {
72
69
  async search(params) {
73
- // Empty/whitespace → no query; absurdly long → not an address (and would blow the model's input).
74
70
  const query = params.q?.trim();
75
71
  if (!query || query.length > MAX_QUERY_LEN)
76
72
  return photonCollection([]);
77
- // #1016: forward the client's viewport/user location as a proximity bias — a SOFT re-rank the resolver
78
- // folds into candidate scoring (Springfield near the map center wins). Only when both coords are present.
73
+ // Forward the client's viewport as a proximity bias, a soft re-rank the resolver
74
+ // folds into candidate scoring, only when both coords are present.
79
75
  const bias = params.lat != null && params.lon != null ? [{ lat: params.lat, lon: params.lon }] : undefined;
80
- // No country constraint: the default-on #244 placer routes the query's country (Berlin→DE,
81
- // Boston→US). Forcing "US" here is a HARD override (geocode-core.ts:102) that resolved every
82
- // non-US query to its US namesake — wrong for a global autocomplete front.
76
+ // No country constraint lets the placer route the query's own country.
77
+ // A hard-coded `US` value here would resolve every non-US query to its US namesake.
83
78
  const result = await geocodeAddress(query, {
84
79
  classifier,
85
80
  resolver,
86
81
  databases: extracts.for,
87
82
  nationalDatabases: banExtracts.for,
88
83
  bias,
89
- // Decision A endpoint default: Photon is an autocomplete front — a human typing fragments.
84
+ // Photon is an autocomplete front where a human types fragments.
90
85
  inputMode: "fragmented",
91
86
  });
92
87
  if (result.lat == null || result.lon == null)
93
88
  return photonCollection([]);
94
- // #1014: decorate from the RESOLVED gazetteer place — proper-cased ancestry names (`hierarchy[].name`,
95
- // not the parsed span) + the resolved country (ISO2 → canonical name via codex) + osm_key/value/type so
96
- // Photon clients don't TypeError. The candidate backend fills only the locality (no ancestors() table),
97
- // so state/county come through only on an ancestry-capable backend — country still lands from the code.
89
+ // Decorate from the resolved place using proper-cased ancestry names,
90
+ // the resolved country and osm_key/value/type.
91
+ // Include state/county only on an ancestry-capable backend.
98
92
  const country = matchCountry(result.countryCode);
99
- // #1041: a rooftop (`address_point`) or house-number-estimate (`interpolated`) tier is HOUSE-GRADE — carry the
100
- // parsed housenumber + street so photonForwardProperties decorates it `type: house` (matching upstream Photon)
101
- // instead of inheriting the admin locality's `type: city`. The admin tier (a locality centroid) never does.
93
+ // A rooftop or interpolated tier is house-grade: include the parsed housenumber
94
+ // and street so photonForwardProperties decorates it `type: house`
95
+ // rather than the admin locality's `type: city`.
102
96
  const houseGrade = result.resolution_tier === "address_point" ||
103
97
  result.resolution_tier === "interpolated" ||
104
98
  result.resolution_tier === "plus_code";
105
- // #1050: the street-centroid tier is STREET-GRADE — full assembled street name in `name`,
106
- // highway/street osm tags (the parallel of the #1041 house treatment).
99
+ // The street-centroid tier is street-grade: the full assembled street name
100
+ // in `name` plus highway/street osm tags.
107
101
  const streetGrade = result.resolution_tier === "street";
108
- // The register row's own scope tags (result.rooftop) decorate a house-grade answer whose
109
- // hierarchy carries no locality/postcode — the register ATTESTS the rooftop's commune and
110
- // postcode even when the query never named them, and #1014's decorate-from-the-resolved-place
111
- // doctrine covers register attestations exactly as it covers gazetteer rows. The key form is
112
- // normalized; title-case it for display (the extracts store no display-cased locality).
102
+ // The register row's own locality decorates a house-grade answer whose hierarchy
103
+ // has no locality, title-cased because extracts store no display-cased locality.
113
104
  const places = result.hierarchy.map((h) => ({ tag: h.tag, name: h.name }));
114
105
  if (result.rooftop?.localityNorm && !places.some((p) => p.tag === "locality")) {
115
- // The key form is normalized lowercase (the extracts store no display-cased locality);
116
- // pyTitle display-cases it particle-and-apostrophe-aware.
117
- places.push({ tag: "locality", name: pyTitle(result.rooftop.localityNorm) });
106
+ places.push({ tag: "locality", name: titleCase(result.rooftop.localityNorm) });
118
107
  }
119
- // Locality→postcode enrichment: an admin answer for a place whose CONTAINING postcode is
120
- // unambiguous (exactly one) carries that postcode — the register/WOF attests it, the query
121
- // simply never said it. Multi-postcode cities (Paris) get NOTHING: the exactly-one rule is
122
- // the abstention, per the registry doctrine. Keyed by the resolved place's WOF id, so no
123
- // name matching is involved.
108
+ // Locality→postcode enrichment: an admin answer whose containing postcode is
109
+ // unambiguous (exactly one, keyed by the resolved place's WOF ID) includes it.
110
+ // A multi-postcode city gets no postcode.
124
111
  let enrichedPostcode;
125
112
  if (!result.postcode && !result.rooftop?.postcode) {
126
113
  const localityID = result.hierarchy.find((h) => (h.tag === "locality" || h.tag === "localadmin") && h.placeID?.startsWith("wof:"))?.placeID;
@@ -137,8 +124,8 @@ async function serve(engineStamp) {
137
124
  ...(houseGrade ? { house: { number: result.house_number, street: result.street } } : {}),
138
125
  ...(streetGrade ? { street: { name: result.street } } : {}),
139
126
  };
140
- // #1016: candidates[0] is the primary itself; its ranked alternatives (Springfield MA/IL/…) become the
141
- // extra features, up to the requested `limit`. Each alternative is a single resolved place.
127
+ // candidates[0] is the primary.
128
+ // Its ranked alternatives become extra features up to the requested `limit`.
142
129
  const alternatives = result.candidates.slice(1).map((c) => {
143
130
  const cc = matchCountry(c.countryCode);
144
131
  return {
@@ -157,8 +144,7 @@ async function serve(engineStamp) {
157
144
  if (!hierarchy.length)
158
145
  return photonCollection([]);
159
146
  const deepest = hierarchy[0];
160
- // #1014: carry osm_key/osm_value/type (from the deepest placetype) so /reverse matches /api's schema —
161
- // no Photon client should dereference an undefined osm_key on a reverse result either.
147
+ // Include osm_key/osm_value/type from the deepest placetype so `/reverse` matches `/api`'s schema.
162
148
  const properties = {
163
149
  name: deepest.name,
164
150
  countrycode: deepest.country?.toLowerCase(),
@@ -197,4 +183,4 @@ await runDropInCLI({
197
183
  " openapi [--flavor 3.1|3.0] [--out <path>]",
198
184
  ],
199
185
  });
200
- //# sourceMappingURL=cli.js.map
186
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../../cli/main.ts"],"names":[],"mappings":";AACA;;;;;;;;GAQG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAA;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EACN,cAAc,EACd,oBAAoB,EACpB,oBAAoB,EACpB,cAAc,EACd,sBAAsB,EACtB,YAAY,GACZ,MAAM,0BAA0B,CAAA;AAEjC,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAA;AAC3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAA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AAC;AAED,MAAM,YAAY,CAAC;IAClB,UAAU,EAAE,WAAW;IACvB,OAAO,EAAE,cAAc,CAAC,WAAW,EAAE,eAAe,EAAE,eAAe,EAAE,EAAE,CAAC;IAC1E,KAAK;IACL,KAAK,EAAE;QACN,4EAA4E;QAC5E,6CAA6C;KAC7C;CACD,CAAC,CAAA"}
package/out/engine.d.ts CHANGED
@@ -3,13 +3,16 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * The Photon engine contract + wire types the router delegates to. Feature/collection
6
+ * The Photon engine interface + wire types the router delegates to. Feature/collection
7
7
  * construction lives here too (`photonFeature`, `photonCollection`) since every projection
8
- * builds on them; the RESOLVED-place → {@link PhotonProperties} projection itself lives in
8
+ * builds on them. the resolved-place → {@link PhotonProperties} projection itself lives in
9
9
  * `projection.ts`.
10
10
  */
11
11
  /**
12
- * Photon feature properties — OSM-derived tag names, populated from Mailwoman's `ComponentTag` / resolved place.
12
+ * Photon feature properties.
13
+ *
14
+ * OSM-derived tag names, populated from Mailwoman's `ComponentTag` / resolved place.
15
+ *
13
16
  * `extent` is `[minLon, maxLat, maxLon, minLat]` per Photon's convention.
14
17
  */
15
18
  export interface PhotonProperties {
@@ -76,8 +79,13 @@ export interface PhotonReverseParams {
76
79
  radius?: number;
77
80
  }
78
81
  /**
79
- * The engine the router delegates to. Each method is optional; a missing one answers `501`. The real implementation
80
- * backs `/api` with the FST autocomplete tier + parse→resolve, and `/reverse` with the `WOFReverseGeocoder`.
82
+ * The engine the router delegates to.
83
+ *
84
+ * Each method is optional.
85
+ * A missing one answers `501`.
86
+ *
87
+ * The real implementation backs `/api` with the FST autocomplete tier + parse→resolve.
88
+ * and `/reverse` with the `WOFReverseGeocoder`.
81
89
  */
82
90
  export interface PhotonEngine {
83
91
  search?(params: PhotonSearchParams): Promise<PhotonFeatureCollection>;
@@ -1 +1 @@
1
- {"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../lib/engine.ts"],"names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,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;CACf;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,YAAY;IAC5B,MAAM,CAAC,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAA;IACrE,OAAO,CAAC,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAA;CACvE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,gBAAgB,GAAG,aAAa,CAEnG;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,aAAa,EAAE,GAAG,uBAAuB,CAEnF"}
package/out/engine.js CHANGED
@@ -3,9 +3,9 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * The Photon engine contract + wire types the router delegates to. Feature/collection
6
+ * The Photon engine interface + wire types the router delegates to. Feature/collection
7
7
  * construction lives here too (`photonFeature`, `photonCollection`) since every projection
8
- * builds on them; the RESOLVED-place → {@link PhotonProperties} projection itself lives in
8
+ * builds on them. the resolved-place → {@link PhotonProperties} projection itself lives in
9
9
  * `projection.ts`.
10
10
  */
11
11
  /**
package/out/engine.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"engine.js","sourceRoot":"","sources":["../lib/engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAmFH;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,GAAW,EAAE,GAAW,EAAE,UAA4B;IACnF,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,UAAU,EAAE,CAAA;AAC7F,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAyB;IACzD,OAAO,EAAE,IAAI,EAAE,mBAAmB,EAAE,QAAQ,EAAE,CAAA;AAC/C,CAAC"}
1
+ {"version":3,"file":"engine.js","sourceRoot":"","sources":["../lib/engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AA2FH;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,GAAW,EAAE,GAAW,EAAE,UAA4B;IACnF,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,UAAU,EAAE,CAAA;AAC7F,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAyB;IACzD,OAAO,EAAE,IAAI,EAAE,mBAAmB,EAAE,QAAQ,EAAE,CAAA;AAC/C,CAAC"}