@mailwoman/photon 5.10.1 → 6.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.
- package/README.md +11 -11
- package/out/app.d.ts +30 -0
- package/out/app.d.ts.map +1 -0
- package/out/app.js +56 -0
- package/out/app.js.map +1 -0
- package/out/cli.js +47 -13
- package/out/cli.js.map +1 -1
- package/out/engine.d.ts +80 -0
- package/out/engine.d.ts.map +1 -0
- package/out/engine.js +19 -0
- package/out/engine.js.map +1 -0
- package/out/index.d.ts +11 -162
- package/out/index.d.ts.map +1 -1
- package/out/index.js +11 -256
- package/out/index.js.map +1 -1
- package/out/projection.d.ts +97 -0
- package/out/projection.d.ts.map +1 -0
- package/out/projection.js +143 -0
- package/out/projection.js.map +1 -0
- package/out/routes.d.ts +14 -0
- package/out/routes.d.ts.map +1 -0
- package/out/routes.js +174 -0
- package/out/routes.js.map +1 -0
- package/out/schema.d.ts +229 -0
- package/out/schema.d.ts.map +1 -0
- package/out/schema.js +120 -0
- package/out/schema.js.map +1 -0
- package/package.json +13 -9
package/README.md
CHANGED
|
@@ -23,28 +23,28 @@ curl "http://localhost:2322/reverse?lat=38.8977&lon=-77.0365"
|
|
|
23
23
|
|
|
24
24
|
## Endpoints
|
|
25
25
|
|
|
26
|
-
| Endpoint
|
|
27
|
-
|
|
|
28
|
-
| `/api`
|
|
29
|
-
| `/reverse`
|
|
26
|
+
| Endpoint | Photon contract |
|
|
27
|
+
| --------------- | ---------------------------------------------------- |
|
|
28
|
+
| `/api` | forward / autocomplete → GeoJSON FeatureCollection |
|
|
29
|
+
| `/reverse` | `lat`/`lon` → GeoJSON FeatureCollection |
|
|
30
|
+
| `/openapi.json` | emitted OpenAPI 3.1 document for `/api` + `/reverse` |
|
|
30
31
|
|
|
31
32
|
Backed by Mailwoman's FST autocomplete tier (#190/#587) + parse → resolve.
|
|
32
33
|
|
|
33
34
|
## Library use
|
|
34
35
|
|
|
35
36
|
```ts
|
|
36
|
-
import
|
|
37
|
-
import {
|
|
37
|
+
import { serveNode } from "@mailwoman/api-kit"
|
|
38
|
+
import { createPhotonApp, type PhotonEngine } from "@mailwoman/photon"
|
|
38
39
|
|
|
39
|
-
const engine: PhotonEngine = {
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
express().use(createPhotonRouter(engine)).listen(2322)
|
|
40
|
+
const engine: PhotonEngine = {/* search, reverse — backed by your Mailwoman pipeline */}
|
|
41
|
+
const app = createPhotonApp(engine)
|
|
42
|
+
serveNode({ fetch: app.fetch, port: 2322, hostname: "0.0.0.0" })
|
|
43
43
|
```
|
|
44
44
|
|
|
45
45
|
## CORS
|
|
46
46
|
|
|
47
|
-
Map widgets (`leaflet-control-geocoder`, `@openrunner/photon-geocoder`) call this cross-origin from the browser, so the server sends permissive CORS by default — `Access-Control-Allow-Origin: *` and a `204` answer to preflight `OPTIONS`, matching upstream Photon. Behind a reverse proxy that already sets the headers, turn it off with `--no-cors` (or `
|
|
47
|
+
Map widgets (`leaflet-control-geocoder`, `@openrunner/photon-geocoder`) call this cross-origin from the browser, so the server sends permissive CORS by default — `Access-Control-Allow-Origin: *` and a `204` answer to preflight `OPTIONS`, matching upstream Photon. Behind a reverse proxy that already sets the headers, turn it off with `--no-cors` (or `createPhotonApp(engine, { cors: false })`).
|
|
48
48
|
|
|
49
49
|
## Status
|
|
50
50
|
|
package/out/app.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
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
|
+
*/
|
|
9
|
+
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
10
|
+
import { type OpenAPIDocInfo } from "@mailwoman/api-kit";
|
|
11
|
+
import type { PhotonEngine } from "./engine.ts";
|
|
12
|
+
/** Options for {@link createPhotonApp}. */
|
|
13
|
+
export interface PhotonAppOptions {
|
|
14
|
+
/**
|
|
15
|
+
* Emit permissive CORS headers (`Access-Control-Allow-Origin: *`) on every response and answer preflight `OPTIONS`
|
|
16
|
+
* with `204`. Default `true` — upstream komoot/photon serves permissive CORS, and the map-widget use case
|
|
17
|
+
* (leaflet-control-geocoder, @openrunner/photon-geocoder, …) needs it: a browser's cross-origin XHR is blocked
|
|
18
|
+
* without it (#1017). Set `false` when a reverse proxy already owns the CORS headers.
|
|
19
|
+
*/
|
|
20
|
+
cors?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The document info stamped into the emitted OpenAPI document. Exported (not inlined) so the CLI's `openapi` subcommand
|
|
24
|
+
* can call `emitOpenAPIDocuments` with the SAME info the mounted `/openapi.json` route (below, via
|
|
25
|
+
* {@link attachOpenAPIDocs}) uses — one source of truth, no risk of the two drifting.
|
|
26
|
+
*/
|
|
27
|
+
export declare const PHOTON_DOC_INFO: OpenAPIDocInfo;
|
|
28
|
+
/** Build the Photon-compatible app around an injected {@link PhotonEngine}. */
|
|
29
|
+
export declare function createPhotonApp(engine: PhotonEngine, options?: PhotonAppOptions): OpenAPIHono;
|
|
30
|
+
//# sourceMappingURL=app.d.ts.map
|
package/out/app.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../app.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAqB,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAI3E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAG/C,2CAA2C;AAC3C,MAAM,WAAW,gBAAgB;IAChC;;;;;OAKG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;CACd;AAED;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAE,cAqB7B,CAAA;AAED,+EAA+E;AAC/E,wBAAgB,eAAe,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,GAAE,gBAAqB,GAAG,WAAW,CAiBjG"}
|
package/out/app.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
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
|
+
*/
|
|
9
|
+
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
10
|
+
import { attachOpenAPIDocs } from "@mailwoman/api-kit";
|
|
11
|
+
import packageJson from "@mailwoman/photon/package.json" with { type: "json" };
|
|
12
|
+
import { cors } from "hono/cors";
|
|
13
|
+
import { registerPhotonRoutes } from "./routes.js";
|
|
14
|
+
/**
|
|
15
|
+
* The document info stamped into the emitted OpenAPI document. Exported (not inlined) so the CLI's `openapi` subcommand
|
|
16
|
+
* can call `emitOpenAPIDocuments` with the SAME info the mounted `/openapi.json` route (below, via
|
|
17
|
+
* {@link attachOpenAPIDocs}) uses — one source of truth, no risk of the two drifting.
|
|
18
|
+
*/
|
|
19
|
+
export const PHOTON_DOC_INFO = {
|
|
20
|
+
title: packageJson.name,
|
|
21
|
+
version: packageJson.version,
|
|
22
|
+
description: packageJson.description,
|
|
23
|
+
license: { name: "AGPL-3.0-only OR LicenseRef-Commercial", identifier: "AGPL-3.0-only" },
|
|
24
|
+
contact: { name: "Sister Software", url: "https://mailwoman.sister.software" },
|
|
25
|
+
externalDocs: {
|
|
26
|
+
description: "Switching from Photon",
|
|
27
|
+
url: "https://mailwoman.sister.software/docs/concepts/switching-from-photon",
|
|
28
|
+
},
|
|
29
|
+
servers: [
|
|
30
|
+
{
|
|
31
|
+
url: "http://{host}:{port}",
|
|
32
|
+
variables: { host: { default: "127.0.0.1" }, port: { default: "2322" } },
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
security: [],
|
|
36
|
+
tags: [
|
|
37
|
+
{ name: "geocoding", description: "Forward autocomplete and reverse geocoding." },
|
|
38
|
+
{ name: "meta", description: "Health and deploy-time operations." },
|
|
39
|
+
],
|
|
40
|
+
};
|
|
41
|
+
/** Build the Photon-compatible app around an injected {@link PhotonEngine}. */
|
|
42
|
+
export function createPhotonApp(engine, options = {}) {
|
|
43
|
+
const app = new OpenAPIHono();
|
|
44
|
+
// Browser-embedded widgets need CORS or their cross-origin XHR is blocked before the request completes (#1017).
|
|
45
|
+
// GET-only — photon has no mutating routes, so unlike libpostal's CORS there is no POST in the methods list.
|
|
46
|
+
if (options.cors !== false) {
|
|
47
|
+
app.use(cors({ origin: "*", allowMethods: ["GET", "OPTIONS"], allowHeaders: ["*"], maxAge: 86400 }));
|
|
48
|
+
}
|
|
49
|
+
// Safety net: malformed input or an engine fault returns an empty FeatureCollection, never a crash (photon's
|
|
50
|
+
// envelope — NOT `{error}`, which is the libpostal/nominatim shape).
|
|
51
|
+
app.onError((_error, c) => c.json({ type: "FeatureCollection", features: [], message: "internal error" }, 500));
|
|
52
|
+
registerPhotonRoutes(app, engine);
|
|
53
|
+
attachOpenAPIDocs(app, PHOTON_DOC_INFO);
|
|
54
|
+
return app;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=app.js.map
|
package/out/app.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../app.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,iBAAiB,EAAuB,MAAM,oBAAoB,CAAA;AAC3E,OAAO,WAAW,MAAM,gCAAgC,CAAC,OAAO,IAAI,EAAE,MA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,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,CAAA;IACrG,CAAC;IAED,6GAA6G;IAC7G,qEAAqE;IACrE,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,CAAC,CAAA;IACjC,iBAAiB,CAAC,GAAG,EAAE,eAAe,CAAC,CAAA;IAEvC,OAAO,GAAG,CAAA;AACX,CAAC"}
|
package/out/cli.js
CHANGED
|
@@ -16,12 +16,13 @@
|
|
|
16
16
|
import { existsSync } from "node:fs";
|
|
17
17
|
import { join } from "node:path";
|
|
18
18
|
import { parseArgs } from "node:util";
|
|
19
|
+
import { printOpenAPIDocument, serveNode } from "@mailwoman/api-kit";
|
|
19
20
|
import { matchCountry } from "@mailwoman/codex/country";
|
|
20
21
|
import { NeuralAddressClassifier } from "@mailwoman/neural";
|
|
21
22
|
import { createWOFResolver } from "@mailwoman/resolver";
|
|
22
23
|
import { geocodeAddress, ShardProvider } from "mailwoman/geocode-core";
|
|
23
24
|
import { createResolverBackend, mailwomanDataRoot, resolveCandidateDBPath, wofShardPaths, } from "mailwoman/resolver-backend";
|
|
24
|
-
import {
|
|
25
|
+
import { createPhotonApp, PHOTON_DOC_INFO, photonCollection, photonFeature, photonForwardCollection, photonOSMTags, } from "./index.js";
|
|
25
26
|
/** WOF placetype → Photon property key. */
|
|
26
27
|
const PLACETYPE_TO_KEY = {
|
|
27
28
|
street: "street",
|
|
@@ -171,18 +172,44 @@ async function serve() {
|
|
|
171
172
|
return photonCollection([photonFeature(deepest.lon, deepest.lat, properties)]);
|
|
172
173
|
},
|
|
173
174
|
};
|
|
174
|
-
const
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
175
|
+
const app = createPhotonApp(engine, { cors: values.cors });
|
|
176
|
+
serveNode({
|
|
177
|
+
fetch: app.fetch,
|
|
178
|
+
port,
|
|
179
|
+
hostname: host,
|
|
180
|
+
onListen: () => {
|
|
181
|
+
console.error(`[@mailwoman/photon] listening on http://${host}:${port}`);
|
|
182
|
+
console.error(` wof: ${adminDBPath ?? "(none found — set MAILWOMAN_WOF_DB)"}`);
|
|
183
|
+
console.error(candidateDb
|
|
184
|
+
? ` resolver: candidate gazetteer (worldwide) — ${candidateDb}`
|
|
185
|
+
: ` resolver: admin-only (US-optimized) — point --candidate-db / $MAILWOMAN_CANDIDATE_DB at a candidate gazetteer for worldwide`);
|
|
186
|
+
console.error(` cors: ${values.cors ? "enabled (Access-Control-Allow-Origin: *)" : "disabled (--no-cors)"}`);
|
|
187
|
+
console.error(` endpoints: GET /api GET /reverse GET /openapi.json`);
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* `openapi` — print (or `--out`-write) the emitted OpenAPI document for this surface. Builds the app around an
|
|
193
|
+
* all-optional stub {@link PhotonEngine} (`{}` — every route answers 501 under this stub, but the document itself only
|
|
194
|
+
* reflects the ROUTE TABLE, not handler behavior) so this NEVER boots the neural classifier or opens a gazetteer DB:
|
|
195
|
+
* pure route-table introspection, fast regardless of data-root state. `--flavor 3.0` prints the 3.0.3 diet instead of
|
|
196
|
+
* the default 3.1.0.
|
|
197
|
+
*/
|
|
198
|
+
function openapi() {
|
|
199
|
+
const { values } = parseArgs({
|
|
200
|
+
options: {
|
|
201
|
+
flavor: { type: "string", default: "3.1" },
|
|
202
|
+
out: { type: "string" },
|
|
203
|
+
},
|
|
204
|
+
allowPositionals: true,
|
|
185
205
|
});
|
|
206
|
+
if (values.flavor !== "3.1" && values.flavor !== "3.0") {
|
|
207
|
+
console.error(`✗ --flavor must be "3.1" or "3.0" (got "${values.flavor}")`);
|
|
208
|
+
console.error("Usage: mailwoman-photon openapi [--flavor 3.1|3.0] [--out <path>]");
|
|
209
|
+
process.exit(1);
|
|
210
|
+
}
|
|
211
|
+
const app = createPhotonApp({});
|
|
212
|
+
printOpenAPIDocument(app, PHOTON_DOC_INFO, values);
|
|
186
213
|
}
|
|
187
214
|
// Subcommand dispatch via parseArgs (strict:false — the per-command parsers own their flags).
|
|
188
215
|
const command = parseArgs({ strict: false, allowPositionals: true }).positionals[0];
|
|
@@ -190,8 +217,15 @@ switch (command) {
|
|
|
190
217
|
case "serve":
|
|
191
218
|
await serve();
|
|
192
219
|
break;
|
|
220
|
+
case "openapi":
|
|
221
|
+
openapi();
|
|
222
|
+
break;
|
|
193
223
|
default:
|
|
194
|
-
console.error(
|
|
224
|
+
console.error([
|
|
225
|
+
"Usage: mailwoman-photon <command>",
|
|
226
|
+
" serve [--port 2322] [--host 0.0.0.0] [--candidate-db <path>] [--no-cors]",
|
|
227
|
+
" openapi [--flavor 3.1|3.0] [--out <path>]",
|
|
228
|
+
].join("\n"));
|
|
195
229
|
process.exit(command ? 1 : 0);
|
|
196
230
|
}
|
|
197
231
|
//# sourceMappingURL=cli.js.map
|
package/out/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAErC,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,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AED,MAAM,GAAG,GAAG,eAAe,CAAC,EAAE,CAAC,CAAA;IAE/B,oBAAoB,CAAC,GAAG,EAAE,eAAe,EAAE,MAAM,CAAC,CAAA;AACnD,CAAC;AAED,8FAA8F;AAC9F,MAAM,OAAO,GAAG,SAAS,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAA;AAEnF,QAAQ,OAAO,EAAE,CAAC;IACjB,KAAK,OAAO;QACX,MAAM,KAAK,EAAE,CAAA;QACb,MAAK;IACN,KAAK,SAAS;QACb,OAAO,EAAE,CAAA;QACT,MAAK;IACN;QACC,OAAO,CAAC,KAAK,CACZ;YACC,mCAAmC;YACnC,4EAA4E;YAC5E,6CAA6C;SAC7C,CAAC,IAAI,CAAC,IAAI,CAAC,CACZ,CAAA;QACD,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAC/B,CAAC"}
|
package/out/engine.d.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* The Photon engine contract + wire types the router delegates to. Feature/collection
|
|
7
|
+
* construction lives here too (`photonFeature`, `photonCollection`) since every projection
|
|
8
|
+
* builds on them; the RESOLVED-place → {@link PhotonProperties} projection itself lives in
|
|
9
|
+
* `projection.ts`.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Photon feature properties — OSM-derived tag names, populated from Mailwoman's `ComponentTag` / resolved place.
|
|
13
|
+
* `extent` is `[minLon, maxLat, maxLon, minLat]` per Photon's convention.
|
|
14
|
+
*/
|
|
15
|
+
export interface PhotonProperties {
|
|
16
|
+
osm_id?: number | string;
|
|
17
|
+
osm_type?: string;
|
|
18
|
+
osm_key?: string;
|
|
19
|
+
osm_value?: string;
|
|
20
|
+
type?: string;
|
|
21
|
+
name?: string;
|
|
22
|
+
housenumber?: string;
|
|
23
|
+
street?: string;
|
|
24
|
+
postcode?: string;
|
|
25
|
+
city?: string;
|
|
26
|
+
district?: string;
|
|
27
|
+
county?: string;
|
|
28
|
+
state?: string;
|
|
29
|
+
country?: string;
|
|
30
|
+
countrycode?: string;
|
|
31
|
+
extent?: [number, number, number, number];
|
|
32
|
+
[key: string]: unknown;
|
|
33
|
+
}
|
|
34
|
+
/** A Photon result feature: a GeoJSON Point with {@link PhotonProperties}. */
|
|
35
|
+
export interface PhotonFeature {
|
|
36
|
+
type: "Feature";
|
|
37
|
+
geometry: {
|
|
38
|
+
type: "Point";
|
|
39
|
+
coordinates: [number, number];
|
|
40
|
+
};
|
|
41
|
+
properties: PhotonProperties;
|
|
42
|
+
}
|
|
43
|
+
/** The Photon response envelope — a GeoJSON FeatureCollection. */
|
|
44
|
+
export interface PhotonFeatureCollection {
|
|
45
|
+
type: "FeatureCollection";
|
|
46
|
+
features: PhotonFeature[];
|
|
47
|
+
}
|
|
48
|
+
/** Parsed `/api` (forward / autocomplete) parameters. */
|
|
49
|
+
export interface PhotonSearchParams {
|
|
50
|
+
q: string;
|
|
51
|
+
limit: number;
|
|
52
|
+
lang?: string;
|
|
53
|
+
/** Location bias. */
|
|
54
|
+
lat?: number;
|
|
55
|
+
lon?: number;
|
|
56
|
+
bbox?: [number, number, number, number];
|
|
57
|
+
osmTag?: string[];
|
|
58
|
+
layer?: string[];
|
|
59
|
+
}
|
|
60
|
+
/** Parsed `/reverse` parameters. */
|
|
61
|
+
export interface PhotonReverseParams {
|
|
62
|
+
lat: number;
|
|
63
|
+
lon: number;
|
|
64
|
+
limit: number;
|
|
65
|
+
lang?: string;
|
|
66
|
+
radius?: number;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The engine the router delegates to. Each method is optional; a missing one answers `501`. The real implementation
|
|
70
|
+
* backs `/api` with the FST autocomplete tier + parse→resolve, and `/reverse` with the `WOFReverseGeocoder`.
|
|
71
|
+
*/
|
|
72
|
+
export interface PhotonEngine {
|
|
73
|
+
search?(params: PhotonSearchParams): Promise<PhotonFeatureCollection>;
|
|
74
|
+
reverse?(params: PhotonReverseParams): Promise<PhotonFeatureCollection>;
|
|
75
|
+
}
|
|
76
|
+
/** Build a Photon `Feature` from a coordinate + properties. */
|
|
77
|
+
export declare function photonFeature(lon: number, lat: number, properties: PhotonProperties): PhotonFeature;
|
|
78
|
+
/** Wrap features in a Photon `FeatureCollection`. */
|
|
79
|
+
export declare function photonCollection(features: PhotonFeature[]): PhotonFeatureCollection;
|
|
80
|
+
//# sourceMappingURL=engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAChC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE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/D,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,gBAAgB,GAAG,aAAa,CAEnG;AAED,qDAAqD;AACrD,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,aAAa,EAAE,GAAG,uBAAuB,CAEnF"}
|
package/out/engine.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* The Photon engine contract + wire types the router delegates to. Feature/collection
|
|
7
|
+
* construction lives here too (`photonFeature`, `photonCollection`) since every projection
|
|
8
|
+
* builds on them; the RESOLVED-place → {@link PhotonProperties} projection itself lives in
|
|
9
|
+
* `projection.ts`.
|
|
10
|
+
*/
|
|
11
|
+
/** Build a Photon `Feature` from a coordinate + properties. */
|
|
12
|
+
export function photonFeature(lon, lat, properties) {
|
|
13
|
+
return { type: "Feature", geometry: { type: "Point", coordinates: [lon, lat] }, properties };
|
|
14
|
+
}
|
|
15
|
+
/** Wrap features in a Photon `FeatureCollection`. */
|
|
16
|
+
export function photonCollection(features) {
|
|
17
|
+
return { type: "FeatureCollection", features };
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAyEH,+DAA+D;AAC/D,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,qDAAqD;AACrD,MAAM,UAAU,gBAAgB,CAAC,QAAyB;IACzD,OAAO,EAAE,IAAI,EAAE,mBAAmB,EAAE,QAAQ,EAAE,CAAA;AAC/C,CAAC"}
|
package/out/index.d.ts
CHANGED
|
@@ -9,168 +9,17 @@
|
|
|
9
9
|
* prefixes. It maps onto Mailwoman's shipped FST autocomplete tier (#190/#587) + parse →
|
|
10
10
|
* resolve.
|
|
11
11
|
*
|
|
12
|
-
* Like its
|
|
12
|
+
* Like its siblings, the package is engine-agnostic: {@link createPhotonApp} takes a
|
|
13
13
|
* {@link PhotonEngine}; the CLI wires the real engine. Implementation is staged on the epic (#801
|
|
14
14
|
* / the Photon child); routes whose engine method is absent answer `501`.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
* Photon
|
|
19
|
-
*
|
|
20
|
-
*/
|
|
21
|
-
export
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
osm_value?: string;
|
|
26
|
-
type?: string;
|
|
27
|
-
name?: string;
|
|
28
|
-
housenumber?: string;
|
|
29
|
-
street?: string;
|
|
30
|
-
postcode?: string;
|
|
31
|
-
city?: string;
|
|
32
|
-
district?: string;
|
|
33
|
-
county?: string;
|
|
34
|
-
state?: string;
|
|
35
|
-
country?: string;
|
|
36
|
-
countrycode?: string;
|
|
37
|
-
extent?: [number, number, number, number];
|
|
38
|
-
[key: string]: unknown;
|
|
39
|
-
}
|
|
40
|
-
/** A Photon result feature: a GeoJSON Point with {@link PhotonProperties}. */
|
|
41
|
-
export interface PhotonFeature {
|
|
42
|
-
type: "Feature";
|
|
43
|
-
geometry: {
|
|
44
|
-
type: "Point";
|
|
45
|
-
coordinates: [number, number];
|
|
46
|
-
};
|
|
47
|
-
properties: PhotonProperties;
|
|
48
|
-
}
|
|
49
|
-
/** The Photon response envelope — a GeoJSON FeatureCollection. */
|
|
50
|
-
export interface PhotonFeatureCollection {
|
|
51
|
-
type: "FeatureCollection";
|
|
52
|
-
features: PhotonFeature[];
|
|
53
|
-
}
|
|
54
|
-
/** Parsed `/api` (forward / autocomplete) parameters. */
|
|
55
|
-
export interface PhotonSearchParams {
|
|
56
|
-
q: string;
|
|
57
|
-
limit: number;
|
|
58
|
-
lang?: string;
|
|
59
|
-
/** Location bias. */
|
|
60
|
-
lat?: number;
|
|
61
|
-
lon?: number;
|
|
62
|
-
bbox?: [number, number, number, number];
|
|
63
|
-
osmTag?: string[];
|
|
64
|
-
layer?: string[];
|
|
65
|
-
}
|
|
66
|
-
/** Parsed `/reverse` parameters. */
|
|
67
|
-
export interface PhotonReverseParams {
|
|
68
|
-
lat: number;
|
|
69
|
-
lon: number;
|
|
70
|
-
limit: number;
|
|
71
|
-
lang?: string;
|
|
72
|
-
radius?: number;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* The engine the router delegates to. Each method is optional; a missing one answers `501`. The real implementation
|
|
76
|
-
* backs `/api` with the FST autocomplete tier + parse→resolve, and `/reverse` with the `WOFReverseGeocoder`.
|
|
77
|
-
*/
|
|
78
|
-
export interface PhotonEngine {
|
|
79
|
-
search?(params: PhotonSearchParams): Promise<PhotonFeatureCollection>;
|
|
80
|
-
reverse?(params: PhotonReverseParams): Promise<PhotonFeatureCollection>;
|
|
81
|
-
}
|
|
82
|
-
/** Options for {@link createPhotonRouter}. */
|
|
83
|
-
export interface PhotonRouterOptions {
|
|
84
|
-
/**
|
|
85
|
-
* Emit permissive CORS headers (`Access-Control-Allow-Origin: *`) on every response and answer preflight `OPTIONS`
|
|
86
|
-
* with `204`. Default `true` — upstream komoot/photon serves permissive CORS, and the map-widget use case
|
|
87
|
-
* (leaflet-control-geocoder, @openrunner/photon-geocoder, …) needs it: a browser's cross-origin XHR is blocked
|
|
88
|
-
* without it (#1017). Set `false` when a reverse proxy already owns the CORS headers.
|
|
89
|
-
*/
|
|
90
|
-
cors?: boolean;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Build the Photon-compatible router around an injected {@link PhotonEngine}. Param parsing lives here; the feature
|
|
94
|
-
* _projection_ (resolved place → {@link PhotonProperties}) is the staged work.
|
|
95
|
-
*/
|
|
96
|
-
export declare function createPhotonRouter(engine: PhotonEngine, options?: PhotonRouterOptions): Router;
|
|
97
|
-
/** Build a Photon `Feature` from a coordinate + properties. */
|
|
98
|
-
export declare function photonFeature(lon: number, lat: number, properties: PhotonProperties): PhotonFeature;
|
|
99
|
-
/** Wrap features in a Photon `FeatureCollection`. */
|
|
100
|
-
export declare function photonCollection(features: PhotonFeature[]): PhotonFeatureCollection;
|
|
101
|
-
/**
|
|
102
|
-
* The resolved-place info a forward `/api` result carries: the admin ladder (MOST-SPECIFIC first) with GAZETTEER names,
|
|
103
|
-
* the coordinate, the resolved country, and the postcode. {@link photonForwardProperties} projects it onto Photon's
|
|
104
|
-
* schema. #1014 — decorate from the resolved place, not the parsed input span.
|
|
105
|
-
*/
|
|
106
|
-
export interface PhotonForwardInput {
|
|
107
|
-
lat: number;
|
|
108
|
-
lon: number;
|
|
109
|
-
postcode?: string | null;
|
|
110
|
-
/** The resolved country, mapped by the caller (ISO2 → canonical name via `@mailwoman/codex`). */
|
|
111
|
-
country?: {
|
|
112
|
-
name?: string;
|
|
113
|
-
code?: string;
|
|
114
|
-
} | null;
|
|
115
|
-
/** Resolved admin ancestry, most-specific first, each carrying the gazetteer's canonical name (not the parsed span). */
|
|
116
|
-
places: ReadonlyArray<{
|
|
117
|
-
tag: string;
|
|
118
|
-
name: string;
|
|
119
|
-
}>;
|
|
120
|
-
/**
|
|
121
|
-
* A HOUSE-GRADE result (#1041): set only when the resolver produced a specific building coordinate — the
|
|
122
|
-
* `address_point` (rooftop) or `interpolated` tier fired, NOT an admin centroid. {@link photonForwardProperties} then
|
|
123
|
-
* re-tags the schema `osm_key: place` / `osm_value: house` / `type: house` and surfaces the parsed `housenumber` +
|
|
124
|
-
* `street`, matching upstream komoot/photon's own bare-address-point shape (verified against `photon.komoot.io`: a
|
|
125
|
-
* residential rooftop returns `{osm_key:"place", osm_value:"house", type:"house", housenumber, street}` with NO
|
|
126
|
-
* `name`). Absent → the result keeps its admin-ancestry schema. Without it a rooftop reads as `type: city` and a
|
|
127
|
-
* client zooms to city scale (or paints a city marker) on a doorstep match — the #1041 regression.
|
|
128
|
-
*/
|
|
129
|
-
house?: {
|
|
130
|
-
number?: string | null;
|
|
131
|
-
street?: string | null;
|
|
132
|
-
} | null;
|
|
133
|
-
/**
|
|
134
|
-
* A STREET-GRADE result (#1050): set when the street-centroid tier (#1042/#1046) fired — a street-level coordinate,
|
|
135
|
-
* below rooftop/interp, above admin. {@link photonForwardProperties} re-tags it `osm_key: highway` / `osm_value:
|
|
136
|
-
* residential` / `type: street` with the FULL assembled street name in `name` — matching upstream komoot's street
|
|
137
|
-
* results (verified live 2026-07-10: a street primary returns `{osm_key:"highway", osm_value:<class>, type:"street",
|
|
138
|
-
* name:"Rue de la République", city, …}`; the street name rides `name`, not `street`). Without it a street centroid
|
|
139
|
-
* reads `type: city` with the city's name — the #1050 regression. `house` wins when both are set (a numbered query
|
|
140
|
-
* never street-tiers).
|
|
141
|
-
*/
|
|
142
|
-
street?: {
|
|
143
|
-
name?: string | null;
|
|
144
|
-
} | null;
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* The Photon `osm_key`/`osm_value`/`type` for a resolved tag or WOF placetype (`locality`, `region`, `country`, …),
|
|
148
|
-
* falling back to a safe default so the fields are always present. Shared by the forward projection and `/reverse` so
|
|
149
|
-
* the two endpoints report a place the SAME way. #1014.
|
|
150
|
-
*/
|
|
151
|
-
export declare function photonOSMTags(tagOrPlacetype: string): {
|
|
152
|
-
osm_key: string;
|
|
153
|
-
osm_value: string;
|
|
154
|
-
type: string;
|
|
155
|
-
};
|
|
156
|
-
/**
|
|
157
|
-
* Project a resolved forward result into Photon properties — decorating from the RESOLVED gazetteer place (proper-cased
|
|
158
|
-
* names + ancestry + country), NOT the parsed input span, and ALWAYS emitting `osm_key`/`osm_value`/`type` so Photon
|
|
159
|
-
* client libraries (leaflet-control-geocoder, @openrunner/photon-geocoder) never dereference undefined. #1014.
|
|
160
|
-
*/
|
|
161
|
-
export declare function photonForwardProperties(input: PhotonForwardInput): PhotonProperties;
|
|
162
|
-
/** {@link photonForwardProperties}, wrapped as a Photon Point `Feature` at the resolved coordinate. #1014. */
|
|
163
|
-
export declare function photonForwardFeature(input: PhotonForwardInput): PhotonFeature;
|
|
164
|
-
/** The winning place plus its ranked alternatives — the input to {@link photonForwardCollection}. #1016. */
|
|
165
|
-
export interface PhotonForwardResult {
|
|
166
|
-
/** The winning place, with full admin ancestry (from the resolved hierarchy). */
|
|
167
|
-
primary: PhotonForwardInput;
|
|
168
|
-
/** Ranked alternative places (Springfield MA / IL / …), each a single-place input; excludes the primary. */
|
|
169
|
-
alternatives: PhotonForwardInput[];
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Assemble a Photon `FeatureCollection` honoring `limit` (#1016): the primary feature first, then ranked alternatives,
|
|
173
|
-
* capped at `limit`. `limit` floors to 1 (Photon always returns at least the best match).
|
|
174
|
-
*/
|
|
175
|
-
export declare function photonForwardCollection(result: PhotonForwardResult, limit: number): PhotonFeatureCollection;
|
|
15
|
+
*
|
|
16
|
+
* The Hono app (CORS + error envelope + the emitted OpenAPI document) lives in `app.ts`; route
|
|
17
|
+
* definitions + handlers in `routes.ts`; wire types + the engine contract in `engine.ts`; the
|
|
18
|
+
* resolved-place → Photon-schema projection in `projection.ts`; the zod wire schemas in
|
|
19
|
+
* `schema.ts`.
|
|
20
|
+
*/
|
|
21
|
+
export * from "./app.ts";
|
|
22
|
+
export * from "./engine.ts";
|
|
23
|
+
export * from "./projection.ts";
|
|
24
|
+
export * from "./schema.ts";
|
|
176
25
|
//# sourceMappingURL=index.d.ts.map
|
package/out/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,aAAa,CAAA"}
|