@honua/react 0.1.0-beta.0 → 0.1.2-beta.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 (315) hide show
  1. package/contract/discovery.d.ts +231 -0
  2. package/contract/discovery.d.ts.map +1 -0
  3. package/contract/discovery.js +554 -0
  4. package/contract/edit-sketch.d.ts +8 -0
  5. package/contract/edit-sketch.d.ts.map +1 -1
  6. package/contract/edit-sketch.js +15 -0
  7. package/contract/edit-snapping.d.ts +160 -0
  8. package/contract/edit-snapping.d.ts.map +1 -0
  9. package/contract/edit-snapping.js +675 -0
  10. package/contract/generated/projjson-v0.7-crs-validator.d.ts +35 -0
  11. package/contract/generated/projjson-v0.7-crs-validator.d.ts.map +1 -0
  12. package/contract/generated/projjson-v0.7-crs-validator.js +3941 -0
  13. package/contract/index.d.ts +11 -2
  14. package/contract/index.d.ts.map +1 -1
  15. package/contract/index.js +4 -1
  16. package/contract/pmtiles.d.ts +31 -0
  17. package/contract/pmtiles.d.ts.map +1 -1
  18. package/contract/pmtiles.js +60 -20
  19. package/contract/protocol-module.d.ts +70 -0
  20. package/contract/protocol-module.d.ts.map +1 -0
  21. package/contract/protocol-module.js +1 -0
  22. package/contract/schema-envelope.d.ts +26 -0
  23. package/contract/schema-envelope.d.ts.map +1 -0
  24. package/contract/schema-envelope.js +25 -0
  25. package/contract/schema.d.ts +582 -0
  26. package/contract/schema.d.ts.map +1 -0
  27. package/contract/schema.js +2483 -0
  28. package/contract/source-capability-support.d.ts +6 -0
  29. package/contract/source-capability-support.d.ts.map +1 -0
  30. package/contract/source-capability-support.js +154 -0
  31. package/contract/source.d.ts +35 -17
  32. package/contract/source.d.ts.map +1 -1
  33. package/contract/source.js +267 -71
  34. package/contract/types.d.ts +140 -4
  35. package/contract/types.d.ts.map +1 -1
  36. package/contract/types.js +6 -14
  37. package/core/bounded-json.d.ts +4 -0
  38. package/core/bounded-json.d.ts.map +1 -0
  39. package/core/bounded-json.js +38 -0
  40. package/core/cache-state.d.ts +9 -0
  41. package/core/cache-state.d.ts.map +1 -1
  42. package/core/cache-state.js +10 -0
  43. package/core/capabilities-xml.d.ts +33 -0
  44. package/core/capabilities-xml.d.ts.map +1 -0
  45. package/core/capabilities-xml.js +331 -0
  46. package/core/client.d.ts +4 -1
  47. package/core/client.d.ts.map +1 -1
  48. package/core/client.js +115 -29
  49. package/core/error-classifications.d.ts +153 -0
  50. package/core/error-classifications.d.ts.map +1 -0
  51. package/core/error-classifications.js +140 -0
  52. package/core/error-code-registry.d.ts +158 -0
  53. package/core/error-code-registry.d.ts.map +1 -0
  54. package/core/error-code-registry.js +143 -0
  55. package/core/error-envelope.d.ts +68 -0
  56. package/core/error-envelope.d.ts.map +1 -0
  57. package/core/error-envelope.js +357 -0
  58. package/core/errors.d.ts +45 -29
  59. package/core/errors.d.ts.map +1 -1
  60. package/core/errors.js +97 -50
  61. package/core/geoparquet-sql.d.ts +30 -2
  62. package/core/geoparquet-sql.d.ts.map +1 -1
  63. package/core/geoparquet-sql.js +38 -3
  64. package/core/odata-key-path.d.ts +12 -0
  65. package/core/odata-key-path.d.ts.map +1 -0
  66. package/core/odata-key-path.js +28 -0
  67. package/core/odata-write-codec.d.ts +66 -0
  68. package/core/odata-write-codec.d.ts.map +1 -0
  69. package/core/odata-write-codec.js +1083 -0
  70. package/core/odata.d.ts +59 -7
  71. package/core/odata.d.ts.map +1 -1
  72. package/core/odata.js +431 -99
  73. package/core/ogc-features.d.ts.map +1 -1
  74. package/core/ogc-features.js +3 -0
  75. package/core/ogc-maps.d.ts +7 -0
  76. package/core/ogc-maps.d.ts.map +1 -1
  77. package/core/ogc-maps.js +46 -7
  78. package/core/ogc-processes.d.ts +2 -1
  79. package/core/ogc-processes.d.ts.map +1 -1
  80. package/core/ogc-processes.js +33 -5
  81. package/core/ogc-records.d.ts +9 -0
  82. package/core/ogc-records.d.ts.map +1 -1
  83. package/core/ogc-records.js +78 -29
  84. package/core/ogc-tiles.d.ts +10 -1
  85. package/core/ogc-tiles.d.ts.map +1 -1
  86. package/core/ogc-tiles.js +56 -17
  87. package/core/path-utils.d.ts +9 -0
  88. package/core/path-utils.d.ts.map +1 -1
  89. package/core/path-utils.js +19 -0
  90. package/core/protocol-transport.d.ts +1 -0
  91. package/core/protocol-transport.d.ts.map +1 -1
  92. package/core/request-pipeline.d.ts.map +1 -1
  93. package/core/request-pipeline.js +1 -1
  94. package/core/spatial-filter.d.ts +8 -4
  95. package/core/spatial-filter.d.ts.map +1 -1
  96. package/core/spatial-filter.js +206 -16
  97. package/core/stac-static.d.ts +6 -2
  98. package/core/stac-static.d.ts.map +1 -1
  99. package/core/stac-static.js +260 -69
  100. package/core/surfaces.d.ts.map +1 -1
  101. package/core/surfaces.js +69 -5
  102. package/core/types.d.ts +125 -7
  103. package/core/types.d.ts.map +1 -1
  104. package/core/wfs-capabilities.d.ts +2 -0
  105. package/core/wfs-capabilities.d.ts.map +1 -1
  106. package/core/wfs-capabilities.js +8 -1
  107. package/core/wfs.d.ts.map +1 -1
  108. package/core/wfs.js +10 -0
  109. package/core/wms-capabilities.d.ts +56 -84
  110. package/core/wms-capabilities.d.ts.map +1 -1
  111. package/core/wms-capabilities.js +212 -509
  112. package/core/wmts-capabilities.d.ts +62 -62
  113. package/core/wmts-capabilities.d.ts.map +1 -1
  114. package/core/wmts-capabilities.js +224 -371
  115. package/esri-compat/editor.d.ts +8 -0
  116. package/esri-compat/editor.d.ts.map +1 -1
  117. package/esri-compat/editor.js +13 -0
  118. package/esri-compat/feature-layer.d.ts +2 -0
  119. package/esri-compat/feature-layer.d.ts.map +1 -1
  120. package/esri-compat/feature-layer.js +1 -0
  121. package/esri-compat/layer-list.d.ts +11 -0
  122. package/esri-compat/layer-list.d.ts.map +1 -1
  123. package/esri-compat/layer-list.js +49 -0
  124. package/esri-compat/legend.d.ts +10 -0
  125. package/esri-compat/legend.d.ts.map +1 -1
  126. package/esri-compat/legend.js +27 -0
  127. package/esri-compat/portal.d.ts +197 -0
  128. package/esri-compat/portal.d.ts.map +1 -0
  129. package/esri-compat/portal.js +251 -0
  130. package/esri-compat/renderer-objects.d.ts +40 -0
  131. package/esri-compat/renderer-objects.d.ts.map +1 -0
  132. package/esri-compat/renderer-objects.js +62 -0
  133. package/esri-compat/sketch.d.ts +43 -0
  134. package/esri-compat/sketch.d.ts.map +1 -1
  135. package/esri-compat/sketch.js +46 -0
  136. package/esri-compat/snapping.d.ts +43 -0
  137. package/esri-compat/snapping.d.ts.map +1 -0
  138. package/esri-compat/snapping.js +45 -0
  139. package/esri-compat/url.d.ts.map +1 -1
  140. package/esri-compat/url.js +1 -1
  141. package/esri-compat/widget-host.d.ts +84 -0
  142. package/esri-compat/widget-host.d.ts.map +1 -0
  143. package/esri-compat/widget-host.js +159 -0
  144. package/filter-registry/index.d.ts +145 -0
  145. package/filter-registry/index.d.ts.map +1 -0
  146. package/filter-registry/index.js +531 -0
  147. package/generated-app/errors.d.ts +18 -2
  148. package/generated-app/errors.d.ts.map +1 -1
  149. package/generated-app/errors.js +44 -11
  150. package/map/automatic-mount-integration.d.ts +134 -0
  151. package/map/automatic-mount-integration.d.ts.map +1 -0
  152. package/map/automatic-mount-integration.js +305 -0
  153. package/map/automatic-source-strategy.d.ts +125 -0
  154. package/map/automatic-source-strategy.d.ts.map +1 -0
  155. package/map/automatic-source-strategy.js +494 -0
  156. package/map/data-to-map-bridge.d.ts +293 -0
  157. package/map/data-to-map-bridge.d.ts.map +1 -0
  158. package/map/data-to-map-bridge.js +817 -0
  159. package/map/geojson-projection.d.ts +33 -0
  160. package/map/geojson-projection.d.ts.map +1 -0
  161. package/map/geojson-projection.js +118 -0
  162. package/map/index.d.ts +14 -0
  163. package/map/index.d.ts.map +1 -1
  164. package/map/index.js +8 -0
  165. package/map/raster-source-spec.d.ts +30 -0
  166. package/map/raster-source-spec.d.ts.map +1 -0
  167. package/map/raster-source-spec.js +190 -0
  168. package/map/raster-source-strategy.d.ts +65 -0
  169. package/map/raster-source-strategy.d.ts.map +1 -0
  170. package/map/raster-source-strategy.js +232 -0
  171. package/map/source-to-maplibre.d.ts +91 -0
  172. package/map/source-to-maplibre.d.ts.map +1 -0
  173. package/map/source-to-maplibre.js +454 -0
  174. package/map/temporal-playback.d.ts +139 -0
  175. package/map/temporal-playback.d.ts.map +1 -0
  176. package/map/temporal-playback.js +247 -0
  177. package/package.json +14 -1
  178. package/query-planner/canonical.d.ts +7 -0
  179. package/query-planner/canonical.d.ts.map +1 -0
  180. package/query-planner/canonical.js +145 -0
  181. package/query-planner/cql2-json.d.ts +17 -0
  182. package/query-planner/cql2-json.d.ts.map +1 -0
  183. package/query-planner/cql2-json.js +646 -0
  184. package/query-planner/diagnostics.d.ts +35 -0
  185. package/query-planner/diagnostics.d.ts.map +1 -0
  186. package/query-planner/diagnostics.js +373 -0
  187. package/query-planner/duckdb.d.ts +79 -0
  188. package/query-planner/duckdb.d.ts.map +1 -0
  189. package/query-planner/duckdb.js +758 -0
  190. package/query-planner/execution-context.d.ts +5 -0
  191. package/query-planner/execution-context.d.ts.map +1 -0
  192. package/query-planner/execution-context.js +50 -0
  193. package/query-planner/executor.d.ts +5 -0
  194. package/query-planner/executor.d.ts.map +1 -0
  195. package/query-planner/executor.js +223 -0
  196. package/query-planner/geoservices.d.ts +91 -0
  197. package/query-planner/geoservices.d.ts.map +1 -0
  198. package/query-planner/geoservices.js +667 -0
  199. package/query-planner/grpc.d.ts +100 -0
  200. package/query-planner/grpc.d.ts.map +1 -0
  201. package/query-planner/grpc.js +736 -0
  202. package/query-planner/index.d.ts +44 -0
  203. package/query-planner/index.d.ts.map +1 -0
  204. package/query-planner/index.js +30 -0
  205. package/query-planner/ir.d.ts +20 -0
  206. package/query-planner/ir.d.ts.map +1 -0
  207. package/query-planner/ir.js +417 -0
  208. package/query-planner/local-aggregate.d.ts +5 -0
  209. package/query-planner/local-aggregate.d.ts.map +1 -0
  210. package/query-planner/local-aggregate.js +126 -0
  211. package/query-planner/odata.d.ts +48 -0
  212. package/query-planner/odata.d.ts.map +1 -0
  213. package/query-planner/odata.js +662 -0
  214. package/query-planner/ogc-compiler.d.ts +55 -0
  215. package/query-planner/ogc-compiler.d.ts.map +1 -0
  216. package/query-planner/ogc-compiler.js +480 -0
  217. package/query-planner/ogc-features.d.ts +53 -0
  218. package/query-planner/ogc-features.d.ts.map +1 -0
  219. package/query-planner/ogc-features.js +617 -0
  220. package/query-planner/planner.d.ts +17 -0
  221. package/query-planner/planner.d.ts.map +1 -0
  222. package/query-planner/planner.js +818 -0
  223. package/query-planner/resource.d.ts +94 -0
  224. package/query-planner/resource.d.ts.map +1 -0
  225. package/query-planner/resource.js +526 -0
  226. package/query-planner/semantic-canonical.d.ts +15 -0
  227. package/query-planner/semantic-canonical.d.ts.map +1 -0
  228. package/query-planner/semantic-canonical.js +62 -0
  229. package/query-planner/semantic-compat.d.ts +10 -0
  230. package/query-planner/semantic-compat.d.ts.map +1 -0
  231. package/query-planner/semantic-compat.js +35 -0
  232. package/query-planner/semantic-compiler.d.ts +64 -0
  233. package/query-planner/semantic-compiler.d.ts.map +1 -0
  234. package/query-planner/semantic-compiler.js +81 -0
  235. package/query-planner/semantic-literals.d.ts +30 -0
  236. package/query-planner/semantic-literals.d.ts.map +1 -0
  237. package/query-planner/semantic-literals.js +133 -0
  238. package/query-planner/semantic-types.d.ts +265 -0
  239. package/query-planner/semantic-types.d.ts.map +1 -0
  240. package/query-planner/semantic-types.js +1 -0
  241. package/query-planner/semantic.d.ts +54 -0
  242. package/query-planner/semantic.d.ts.map +1 -0
  243. package/query-planner/semantic.js +1421 -0
  244. package/query-planner/types.d.ts +560 -0
  245. package/query-planner/types.d.ts.map +1 -0
  246. package/query-planner/types.js +49 -0
  247. package/query-planner/wfs-semantic.d.ts +58 -0
  248. package/query-planner/wfs-semantic.d.ts.map +1 -0
  249. package/query-planner/wfs-semantic.js +547 -0
  250. package/query-planner/wfs.d.ts +6 -0
  251. package/query-planner/wfs.d.ts.map +1 -0
  252. package/query-planner/wfs.js +71 -0
  253. package/react/external-map.d.ts +67 -0
  254. package/react/external-map.d.ts.map +1 -0
  255. package/react/external-map.js +63 -0
  256. package/react/honua-map.d.ts.map +1 -1
  257. package/react/honua-map.js +3 -2
  258. package/react/honua-source-layer.d.ts +110 -0
  259. package/react/honua-source-layer.d.ts.map +1 -0
  260. package/react/honua-source-layer.js +101 -0
  261. package/react/hooks.d.ts +28 -0
  262. package/react/hooks.d.ts.map +1 -1
  263. package/react/hooks.js +26 -4
  264. package/react/index.d.ts +8 -0
  265. package/react/index.d.ts.map +1 -1
  266. package/react/index.js +5 -0
  267. package/react/query-cache.d.ts +26 -4
  268. package/react/query-cache.d.ts.map +1 -1
  269. package/react/query-cache.js +51 -8
  270. package/react/selection.d.ts +177 -0
  271. package/react/selection.d.ts.map +1 -0
  272. package/react/selection.js +0 -0
  273. package/react/use-mounted-source.d.ts +69 -0
  274. package/react/use-mounted-source.d.ts.map +1 -0
  275. package/react/use-mounted-source.js +346 -0
  276. package/runtime/edit-snapping.d.ts +107 -0
  277. package/runtime/edit-snapping.d.ts.map +1 -0
  278. package/runtime/edit-snapping.js +190 -0
  279. package/runtime/errors.d.ts +3 -2
  280. package/runtime/errors.d.ts.map +1 -1
  281. package/runtime/errors.js +19 -2
  282. package/runtime/index.d.ts +6 -0
  283. package/runtime/index.d.ts.map +1 -1
  284. package/runtime/index.js +3 -0
  285. package/runtime/maplibre-renderer.d.ts +41 -0
  286. package/runtime/maplibre-renderer.d.ts.map +1 -0
  287. package/runtime/maplibre-renderer.js +322 -0
  288. package/runtime/query-tiles.d.ts +2 -1
  289. package/runtime/query-tiles.d.ts.map +1 -1
  290. package/runtime/query-tiles.js +6 -2
  291. package/runtime/source-bridge.d.ts +4 -4
  292. package/runtime/source-bridge.d.ts.map +1 -1
  293. package/runtime/source-bridge.js +9 -56
  294. package/runtime/style-interactions.d.ts +3 -2
  295. package/runtime/style-interactions.d.ts.map +1 -1
  296. package/runtime/style-interactions.js +11 -3
  297. package/runtime/terra-draw-sketch.d.ts +275 -0
  298. package/runtime/terra-draw-sketch.d.ts.map +1 -0
  299. package/runtime/terra-draw-sketch.js +404 -0
  300. package/source-capability-registry.d.ts +1 -0
  301. package/source-capability-registry.js +1 -0
  302. package/source-capability-types.d.ts +186 -0
  303. package/source-capability-types.js +7 -0
  304. package/style/index.d.ts +2 -0
  305. package/style/index.d.ts.map +1 -1
  306. package/style/index.js +2 -0
  307. package/style/renderers.d.ts +326 -0
  308. package/style/renderers.d.ts.map +1 -0
  309. package/style/renderers.js +517 -0
  310. package/webmap/convert-renderer.d.ts +24 -3
  311. package/webmap/convert-renderer.d.ts.map +1 -1
  312. package/webmap/convert-renderer.js +93 -112
  313. package/webmap/index.d.ts +1 -1
  314. package/webmap/index.d.ts.map +1 -1
  315. package/webmap/index.js +1 -1
@@ -0,0 +1,62 @@
1
+ import { parseSourceSchemaV2 } from "../contract/schema.js";
2
+ import { canonicalStringify, sha256, toJsonValue } from "./canonical.js";
3
+ import { parseSemanticQuery } from "./semantic.js";
4
+ import { HonuaQueryPlanningError } from "./types.js";
5
+ export const SEMANTIC_QUERY_CANONICAL_KIND = "honua.semantic-query-canonical";
6
+ export const SEMANTIC_QUERY_CANONICAL_VERSION = 1;
7
+ export const SEMANTIC_QUERY_HASH_DOMAIN = "honua.semantic-query.hash.v1";
8
+ const MAX_IDENTITY_VERSION_BYTES = 4096;
9
+ const TEXT_ENCODER = new TextEncoder();
10
+ /**
11
+ * Serialize a validated semantic query plus its schema/CRS/policy identity.
12
+ * Object keys are UTF-8 deterministically ordered; array order stays
13
+ * significant. Volatile execution state is not accepted by the semantic AST.
14
+ */
15
+ export function serializeCanonicalSemanticQuery(value, options = {}) {
16
+ const schema = verifiedSchema(options.schema);
17
+ const query = parseSemanticQuery(value, {
18
+ ...(schema ? { schema } : {}),
19
+ ...(options.protocol !== undefined ? { protocol: options.protocol } : {}),
20
+ });
21
+ const identity = {
22
+ schemaFingerprint: schema?.fingerprint ?? null,
23
+ crsVersion: identityVersion(options.crsVersion, "crsVersion"),
24
+ policyVersion: identityVersion(options.policyVersion, "policyVersion"),
25
+ protocol: options.protocol ?? null,
26
+ };
27
+ return canonicalStringify(toJsonValue({
28
+ kind: SEMANTIC_QUERY_CANONICAL_KIND,
29
+ version: SEMANTIC_QUERY_CANONICAL_VERSION,
30
+ identity,
31
+ query,
32
+ }));
33
+ }
34
+ /** Return a fresh UTF-8 byte copy of the canonical semantic-query envelope. */
35
+ export function canonicalSemanticQueryBytes(value, options = {}) {
36
+ return TEXT_ENCODER.encode(serializeCanonicalSemanticQuery(value, options));
37
+ }
38
+ /** Domain-separated SHA-256 identity for a canonical semantic query. */
39
+ export function hashSemanticQuery(value, options = {}) {
40
+ return sha256(`${SEMANTIC_QUERY_HASH_DOMAIN}\n${serializeCanonicalSemanticQuery(value, options)}`);
41
+ }
42
+ function verifiedSchema(value) {
43
+ if (value === undefined)
44
+ return undefined;
45
+ try {
46
+ return parseSourceSchemaV2(value);
47
+ }
48
+ catch {
49
+ throw new HonuaQueryPlanningError("invalid-query", "Canonical semantic-query identity requires a valid schema");
50
+ }
51
+ }
52
+ function identityVersion(value, name) {
53
+ if (value === undefined)
54
+ return null;
55
+ if (typeof value !== "string" || value.length === 0) {
56
+ throw new HonuaQueryPlanningError("invalid-query", `${name} must be a non-empty string when supplied`);
57
+ }
58
+ if (TEXT_ENCODER.encode(value).byteLength > MAX_IDENTITY_VERSION_BYTES) {
59
+ throw new HonuaQueryPlanningError("invalid-query", `${name} exceeds the ${MAX_IDENTITY_VERSION_BYTES}-byte bound`);
60
+ }
61
+ return value;
62
+ }
@@ -0,0 +1,10 @@
1
+ import type { LegacyWhereDialectFor, LegacyWhereProtocol, NativeFilter } from "./semantic-types.js";
2
+ /**
3
+ * Convert deprecated v1 `Query.where` text into an explicitly tagged native
4
+ * filter. This is a migration bridge, not a protocol-neutral parser.
5
+ *
6
+ * @deprecated Build a typed semantic filter instead. Keep this only while a
7
+ * v1 caller still owns protocol-native `where` text.
8
+ */
9
+ export declare function legacyWhereToNativeFilter<TProtocol extends LegacyWhereProtocol>(protocol: TProtocol, where: string): NativeFilter<LegacyWhereDialectFor<TProtocol>>;
10
+ //# sourceMappingURL=semantic-compat.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"semantic-compat.d.ts","sourceRoot":"","sources":["../../../src/query-planner/semantic-compat.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAepG;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,SAAS,SAAS,mBAAmB,EAC7E,QAAQ,EAAE,SAAS,EACnB,KAAK,EAAE,MAAM,GACZ,YAAY,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC,CAsBhD"}
@@ -0,0 +1,35 @@
1
+ import { parseSemanticQuery } from "./semantic.js";
2
+ import { HonuaQueryPlanningError } from "./types.js";
3
+ const LEGACY_WHERE_DIALECT = {
4
+ "geoservices-feature-service": "geoservices-sql92",
5
+ "geoservices-map-service": "geoservices-sql92",
6
+ "geoservices-image-service": "geoservices-sql92",
7
+ "ogc-features": "cql2-text",
8
+ "ogc-records": "cql2-text",
9
+ stac: "cql2-text",
10
+ odata: "odata-4.0",
11
+ geoparquet: "duckdb-sql",
12
+ };
13
+ /**
14
+ * Convert deprecated v1 `Query.where` text into an explicitly tagged native
15
+ * filter. This is a migration bridge, not a protocol-neutral parser.
16
+ *
17
+ * @deprecated Build a typed semantic filter instead. Keep this only while a
18
+ * v1 caller still owns protocol-native `where` text.
19
+ */
20
+ export function legacyWhereToNativeFilter(protocol, where) {
21
+ const dialect = typeof protocol === "string" && Object.prototype.hasOwnProperty.call(LEGACY_WHERE_DIALECT, protocol)
22
+ ? LEGACY_WHERE_DIALECT[protocol]
23
+ : undefined;
24
+ if (!dialect) {
25
+ throw new HonuaQueryPlanningError("unsupported-query", "The supplied protocol has no lossless raw-where compatibility dialect");
26
+ }
27
+ if (typeof where !== "string" || where.trim().length === 0) {
28
+ throw new HonuaQueryPlanningError("invalid-query", "Legacy raw where must be a non-empty string");
29
+ }
30
+ const query = parseSemanticQuery({
31
+ kind: "features",
32
+ filter: { kind: "native", dialect, payload: { format: "text", text: where } },
33
+ }, { protocol });
34
+ return query.filter;
35
+ }
@@ -0,0 +1,64 @@
1
+ import { type CrsDefinition, type ExecutableCrsBinding, type JsonPrimitive, type LogicalField, type SourceProtocol, type SourceSchemaV2 } from "../contract/schema.js";
2
+ import type { SemanticQuery, SourceSpatiality } from "./semantic-types.js";
3
+ /** Fidelity attached to a successful semantic compiler result. */
4
+ export type SemanticCompilerFidelity = "exact" | "approximate";
5
+ /** Stable reasons a valid semantic query cannot be represented by a compiler. */
6
+ export type SemanticCompilerUnsupportedCode = "unsupported-crs" | "crs-transform-required" | "unsupported-distance" | "unsupported-field-type" | "unsupported-geometry" | "unsupported-native-filter" | "unsupported-node" | "unsupported-projection" | "unsupported-sort" | "unsupported-source";
7
+ /** Path-addressed, deterministic unsupported outcome. */
8
+ export interface SemanticCompilerDiagnostic {
9
+ readonly code: SemanticCompilerUnsupportedCode;
10
+ readonly path: string;
11
+ readonly message: string;
12
+ }
13
+ /** Stable fidelity loss carried beside an approximate compiled artifact. */
14
+ export interface SemanticCompilerLoss {
15
+ readonly code: "spatial-envelope-reduction";
16
+ readonly path: string;
17
+ readonly message: string;
18
+ }
19
+ /**
20
+ * A compiler never silently drops a node. Valid but non-representable queries
21
+ * produce an explicit unsupported result; malformed queries still throw the
22
+ * common planning error before an artifact can be constructed.
23
+ */
24
+ export type SemanticCompilationResult<TArtifact> = {
25
+ readonly outcome: "compiled";
26
+ readonly fidelity: SemanticCompilerFidelity;
27
+ readonly losses: readonly SemanticCompilerLoss[];
28
+ readonly artifact: TArtifact;
29
+ } | {
30
+ readonly outcome: "unsupported";
31
+ readonly fidelity: "unsupported";
32
+ readonly diagnostics: readonly [SemanticCompilerDiagnostic, ...SemanticCompilerDiagnostic[]];
33
+ };
34
+ /** Ordered bind value for parameterized semantic SQL. */
35
+ export interface SemanticSqlParameter {
36
+ /** One-based position matching the corresponding `?` in SQL text. */
37
+ readonly position: number;
38
+ readonly role: "literal" | "geometry" | "bbox" | "distance";
39
+ readonly value: JsonPrimitive;
40
+ readonly field?: string;
41
+ readonly logicalType?: string;
42
+ }
43
+ export type RuntimeSemanticQuery<TProtocol extends SourceProtocol> = SemanticQuery<Record<string, unknown>, TProtocol, SourceSpatiality>;
44
+ interface SemanticCompilerBuild<TArtifact> {
45
+ readonly artifact: TArtifact;
46
+ readonly losses?: readonly SemanticCompilerLoss[];
47
+ }
48
+ /** @internal Verify untrusted schema/query values once at the compiler boundary. */
49
+ export declare function prepareSemanticCompilerQuery<TProtocol extends SourceProtocol>(value: unknown, schemaValue: SourceSchemaV2, protocol: TProtocol): {
50
+ readonly query: RuntimeSemanticQuery<TProtocol>;
51
+ readonly schema: SourceSchemaV2;
52
+ };
53
+ /** @internal Convert compiler-local unsupported failures into the public union. */
54
+ export declare function runSemanticCompiler<TArtifact>(compile: () => SemanticCompilerBuild<TArtifact>): SemanticCompilationResult<TArtifact>;
55
+ /** @internal Stop compilation at an exact query path without constructing a request. */
56
+ export declare function semanticUnsupported(code: SemanticCompilerUnsupportedCode, path: string, message: string): never;
57
+ /** @internal Resolve one validated logical field. */
58
+ export declare function semanticSchemaField(schema: SourceSchemaV2, name: string, path: string): LogicalField;
59
+ /** @internal Compare executable CRS semantics without volatile provenance. */
60
+ export declare function sameExecutableCrs(left: ExecutableCrsBinding, right: ExecutableCrsBinding): boolean;
61
+ /** @internal Compare a requested output definition with a field binding. */
62
+ export declare function sameCrsDefinition(left: CrsDefinition, right: CrsDefinition): boolean;
63
+ export {};
64
+ //# sourceMappingURL=semantic-compiler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"semantic-compiler.d.ts","sourceRoot":"","sources":["../../../src/query-planner/semantic-compiler.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,81 @@
1
+ import { parseSourceSchemaV2, } from "../contract/schema.js";
2
+ import { canonicalStringify, toJsonValue } from "./canonical.js";
3
+ import { parseSemanticQuery } from "./semantic.js";
4
+ import { HonuaQueryPlanningError } from "./types.js";
5
+ class SemanticCompilerUnsupported extends Error {
6
+ diagnostic;
7
+ constructor(diagnostic) {
8
+ super(diagnostic.message);
9
+ this.diagnostic = diagnostic;
10
+ this.name = "SemanticCompilerUnsupported";
11
+ }
12
+ }
13
+ /** @internal Verify untrusted schema/query values once at the compiler boundary. */
14
+ export function prepareSemanticCompilerQuery(value, schemaValue, protocol) {
15
+ let schema;
16
+ try {
17
+ schema = parseSourceSchemaV2(schemaValue);
18
+ }
19
+ catch {
20
+ throw new HonuaQueryPlanningError("invalid-query", "Semantic compilation requires a valid SourceSchemaV2");
21
+ }
22
+ const query = parseSemanticQuery(value, { schema, protocol });
23
+ return { query, schema };
24
+ }
25
+ /** @internal Convert compiler-local unsupported failures into the public union. */
26
+ export function runSemanticCompiler(compile) {
27
+ try {
28
+ const built = compile();
29
+ const losses = [...(built.losses ?? [])];
30
+ return deepFreeze({
31
+ outcome: "compiled",
32
+ fidelity: losses.length === 0 ? "exact" : "approximate",
33
+ losses,
34
+ artifact: built.artifact,
35
+ });
36
+ }
37
+ catch (error) {
38
+ if (!(error instanceof SemanticCompilerUnsupported))
39
+ throw error;
40
+ return deepFreeze({
41
+ outcome: "unsupported",
42
+ fidelity: "unsupported",
43
+ diagnostics: [error.diagnostic],
44
+ });
45
+ }
46
+ }
47
+ /** @internal Stop compilation at an exact query path without constructing a request. */
48
+ export function semanticUnsupported(code, path, message) {
49
+ throw new SemanticCompilerUnsupported({ code, path, message });
50
+ }
51
+ /** @internal Resolve one validated logical field. */
52
+ export function semanticSchemaField(schema, name, path) {
53
+ const field = schema.fields.find((candidate) => candidate.name === name);
54
+ if (!field) {
55
+ throw new HonuaQueryPlanningError("invalid-query", `${path} references unknown schema field ${JSON.stringify(name)}`);
56
+ }
57
+ return field;
58
+ }
59
+ /** @internal Compare executable CRS semantics without volatile provenance. */
60
+ export function sameExecutableCrs(left, right) {
61
+ return crsBindingIdentity(left) === crsBindingIdentity(right);
62
+ }
63
+ /** @internal Compare a requested output definition with a field binding. */
64
+ export function sameCrsDefinition(left, right) {
65
+ return canonicalStringify(toJsonValue(left)) === canonicalStringify(toJsonValue(right));
66
+ }
67
+ function crsBindingIdentity(binding) {
68
+ return canonicalStringify(toJsonValue({
69
+ definition: binding.definition,
70
+ coordinateOrder: binding.coordinateOrder,
71
+ coordinateEpoch: binding.coordinateEpoch ?? null,
72
+ }));
73
+ }
74
+ function deepFreeze(value) {
75
+ if (value !== null && typeof value === "object" && !Object.isFrozen(value)) {
76
+ Object.freeze(value);
77
+ for (const child of Object.values(value))
78
+ deepFreeze(child);
79
+ }
80
+ return value;
81
+ }
@@ -0,0 +1,30 @@
1
+ import type { LogicalField } from "../contract/schema.js";
2
+ /** Trace from one public semantic field to its exact protocol request name. */
3
+ export interface SemanticCompilerFieldMapping {
4
+ readonly logicalField: string;
5
+ readonly physicalPath: readonly string[];
6
+ readonly requestField: string;
7
+ }
8
+ /** @internal Record each field mapping once, in first-use order. */
9
+ export declare function recordSemanticFieldMapping(mappings: SemanticCompilerFieldMapping[], field: LogicalField, requestField: string): void;
10
+ /** @internal Sort mapping evidence by Unicode scalar value, independent of locale/ICU data. */
11
+ export declare function sortSemanticFieldMappings(mappings: readonly SemanticCompilerFieldMapping[]): readonly SemanticCompilerFieldMapping[];
12
+ /** @internal Quote one SQL-92 identifier without changing its Unicode spelling. */
13
+ export declare function sql92Identifier(value: string, path: string): string;
14
+ /** @internal Compile an OData structural-property path with no alias rewriting. */
15
+ export declare function odataPropertyPath(segments: readonly string[], path: string): string;
16
+ /** @internal SQL/OData single-quoted string literal with quote doubling. */
17
+ export declare function quotedSemanticString(value: string, path: string): string;
18
+ /** @internal Convert a finite JavaScript number to a deterministic non-exponent decimal. */
19
+ export declare function finiteDecimalNumber(value: number, path: string): string;
20
+ /** @internal Validate an exact JSON string-encoded integer or decimal. */
21
+ export declare function exactDecimalText(value: string, path: string): string;
22
+ /** @internal Validate one bounded, credential-free source version token. */
23
+ export declare function verifiedSemanticSourceVersion(value: unknown, path: string): string | undefined;
24
+ /** @internal Validate a bounded source locator string. */
25
+ export declare function verifiedSemanticSourceText(value: unknown, path: string): string;
26
+ /** @internal Admit already-bounded protocol-native text without URL control bytes or an empty expression. */
27
+ export declare function verifiedSemanticNativeText(value: string, path: string, dialect: string): string;
28
+ /** @internal Domain-separated identity of the exact request pre-image. */
29
+ export declare function semanticRequestFingerprint(domain: string, value: unknown): `sha256:${string}`;
30
+ //# sourceMappingURL=semantic-literals.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"semantic-literals.d.ts","sourceRoot":"","sources":["../../../src/query-planner/semantic-literals.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAa1D,+EAA+E;AAC/E,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;IACzC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B;AAED,oEAAoE;AACpE,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,4BAA4B,EAAE,EACxC,KAAK,EAAE,YAAY,EACnB,YAAY,EAAE,MAAM,GACnB,IAAI,CAGN;AAED,+FAA+F;AAC/F,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,SAAS,4BAA4B,EAAE,GAChD,SAAS,4BAA4B,EAAE,CAEzC;AAED,mFAAmF;AACnF,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAGnE;AAED,mFAAmF;AACnF,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAenF;AAED,4EAA4E;AAC5E,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAKxE;AAED,4FAA4F;AAC5F,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAKvE;AAED,0EAA0E;AAC1E,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CASpE;AAED,4EAA4E;AAC5E,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAW9F;AAED,0DAA0D;AAC1D,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAU/E;AAED,6GAA6G;AAC7G,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAQ/F;AAED,0EAA0E;AAC1E,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,UAAU,MAAM,EAAE,CAE7F"}
@@ -0,0 +1,133 @@
1
+ import { canonicalStringify, sha256, toJsonValue } from "./canonical.js";
2
+ import { semanticUnsupported } from "./semantic-compiler.js";
3
+ import { HonuaQueryPlanningError } from "./types.js";
4
+ const MAX_SOURCE_IDENTITY_TEXT = 512;
5
+ const MAX_PHYSICAL_SEGMENT_TEXT = 512;
6
+ const MAX_ODATA_IDENTIFIER_CODE_POINTS = 128;
7
+ // biome-ignore lint/suspicious/noControlCharactersInRegex: request identities and identifiers reject control bytes
8
+ const CONTROL_CHARACTER = /[\u0000-\u001f\u007f]/;
9
+ const ODATA_IDENTIFIER = /^[_\p{ID_Start}][_\p{ID_Continue}]*$/u;
10
+ const DECIMAL_TEXT = /^-?(?:0|[1-9]\d*)(?:\.\d+)?$/;
11
+ /** @internal Record each field mapping once, in first-use order. */
12
+ export function recordSemanticFieldMapping(mappings, field, requestField) {
13
+ if (mappings.some((candidate) => candidate.logicalField === field.name))
14
+ return;
15
+ mappings.push({ logicalField: field.name, physicalPath: [...field.path], requestField });
16
+ }
17
+ /** @internal Sort mapping evidence by Unicode scalar value, independent of locale/ICU data. */
18
+ export function sortSemanticFieldMappings(mappings) {
19
+ return [...mappings].sort((left, right) => compareUnicodeScalars(left.logicalField, right.logicalField));
20
+ }
21
+ /** @internal Quote one SQL-92 identifier without changing its Unicode spelling. */
22
+ export function sql92Identifier(value, path) {
23
+ verifiedPhysicalSegment(value, path);
24
+ return `"${value.replace(/"/g, '""')}"`;
25
+ }
26
+ /** @internal Compile an OData structural-property path with no alias rewriting. */
27
+ export function odataPropertyPath(segments, path) {
28
+ if (segments.length === 0) {
29
+ semanticUnsupported("unsupported-source", path, "OData fields require a non-empty physical property path");
30
+ }
31
+ for (const segment of segments) {
32
+ verifiedPhysicalSegment(segment, path);
33
+ if (!ODATA_IDENTIFIER.test(segment) || [...segment].length > MAX_ODATA_IDENTIFIER_CODE_POINTS) {
34
+ semanticUnsupported("unsupported-source", path, "OData cannot represent a physical property path segment in its bounded simple-identifier grammar");
35
+ }
36
+ }
37
+ return segments.join("/");
38
+ }
39
+ /** @internal SQL/OData single-quoted string literal with quote doubling. */
40
+ export function quotedSemanticString(value, path) {
41
+ if (CONTROL_CHARACTER.test(value)) {
42
+ semanticUnsupported("unsupported-node", path, "Text literals containing control characters are not portable");
43
+ }
44
+ return `'${value.replace(/'/g, "''")}'`;
45
+ }
46
+ /** @internal Convert a finite JavaScript number to a deterministic non-exponent decimal. */
47
+ export function finiteDecimalNumber(value, path) {
48
+ if (!Number.isFinite(value)) {
49
+ semanticUnsupported("unsupported-field-type", path, "The request dialect requires a finite numeric literal");
50
+ }
51
+ return expandExponent(Object.is(value, -0) ? "0" : String(value));
52
+ }
53
+ /** @internal Validate an exact JSON string-encoded integer or decimal. */
54
+ export function exactDecimalText(value, path) {
55
+ if (!DECIMAL_TEXT.test(value)) {
56
+ semanticUnsupported("unsupported-field-type", path, "String-encoded numeric literals require a canonical non-exponent decimal");
57
+ }
58
+ return value;
59
+ }
60
+ /** @internal Validate one bounded, credential-free source version token. */
61
+ export function verifiedSemanticSourceVersion(value, path) {
62
+ if (value === undefined)
63
+ return undefined;
64
+ if (typeof value !== "string" ||
65
+ value.trim().length === 0 ||
66
+ value.length > MAX_SOURCE_IDENTITY_TEXT ||
67
+ CONTROL_CHARACTER.test(value)) {
68
+ throw new HonuaQueryPlanningError("invalid-query", `${path} is invalid`);
69
+ }
70
+ return value;
71
+ }
72
+ /** @internal Validate a bounded source locator string. */
73
+ export function verifiedSemanticSourceText(value, path) {
74
+ if (typeof value !== "string" ||
75
+ value.trim().length === 0 ||
76
+ value.length > MAX_SOURCE_IDENTITY_TEXT ||
77
+ CONTROL_CHARACTER.test(value)) {
78
+ throw new HonuaQueryPlanningError("invalid-query", `${path} is invalid`);
79
+ }
80
+ return value;
81
+ }
82
+ /** @internal Admit already-bounded protocol-native text without URL control bytes or an empty expression. */
83
+ export function verifiedSemanticNativeText(value, path, dialect) {
84
+ if (value.trim().length === 0) {
85
+ semanticUnsupported("unsupported-native-filter", path, `${dialect} native expression is empty`);
86
+ }
87
+ if (CONTROL_CHARACTER.test(value)) {
88
+ semanticUnsupported("unsupported-native-filter", path, `${dialect} native expression contains a control character`);
89
+ }
90
+ return value;
91
+ }
92
+ /** @internal Domain-separated identity of the exact request pre-image. */
93
+ export function semanticRequestFingerprint(domain, value) {
94
+ return sha256(`${domain}\n${canonicalStringify(toJsonValue(value))}`);
95
+ }
96
+ function verifiedPhysicalSegment(value, path) {
97
+ if (typeof value !== "string" ||
98
+ value.length === 0 ||
99
+ value.length > MAX_PHYSICAL_SEGMENT_TEXT ||
100
+ CONTROL_CHARACTER.test(value)) {
101
+ semanticUnsupported("unsupported-source", path, "The physical field path contains an unsafe segment");
102
+ }
103
+ }
104
+ function expandExponent(value) {
105
+ const match = /^(-?)(\d+)(?:\.(\d+))?[eE]([+-]?\d+)$/.exec(value);
106
+ if (!match)
107
+ return value;
108
+ const sign = match[1] ?? "";
109
+ const integer = match[2] ?? "0";
110
+ const fraction = match[3] ?? "";
111
+ const exponent = Number(match[4]);
112
+ const digits = `${integer}${fraction}`;
113
+ const decimalPosition = integer.length + exponent;
114
+ if (decimalPosition <= 0)
115
+ return `${sign}0.${"0".repeat(-decimalPosition)}${digits}`;
116
+ if (decimalPosition >= digits.length)
117
+ return `${sign}${digits}${"0".repeat(decimalPosition - digits.length)}`;
118
+ return `${sign}${digits.slice(0, decimalPosition)}.${digits.slice(decimalPosition)}`;
119
+ }
120
+ function compareUnicodeScalars(left, right) {
121
+ const leftScalars = [...left];
122
+ const rightScalars = [...right];
123
+ const length = Math.min(leftScalars.length, rightScalars.length);
124
+ for (let index = 0; index < length; index += 1) {
125
+ const leftPoint = leftScalars[index]?.codePointAt(0) ?? 0;
126
+ const rightPoint = rightScalars[index]?.codePointAt(0) ?? 0;
127
+ if (leftPoint !== rightPoint)
128
+ return leftPoint < rightPoint ? -1 : 1;
129
+ }
130
+ if (leftScalars.length === rightScalars.length)
131
+ return 0;
132
+ return leftScalars.length < rightScalars.length ? -1 : 1;
133
+ }