@ignfab/geocontext 0.9.5 → 0.9.7

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 (128) hide show
  1. package/README.md +349 -259
  2. package/dist/gpf/adminexpress.d.ts +17 -8
  3. package/dist/gpf/adminexpress.js +40 -17
  4. package/dist/gpf/adminexpress.js.map +1 -1
  5. package/dist/gpf/altitude.d.ts +21 -9
  6. package/dist/gpf/altitude.js +5 -5
  7. package/dist/gpf/altitude.js.map +1 -1
  8. package/dist/gpf/geocode.d.ts +25 -4
  9. package/dist/gpf/geocode.js +5 -5
  10. package/dist/gpf/geocode.js.map +1 -1
  11. package/dist/gpf/parcellaire-express.d.ts +19 -9
  12. package/dist/gpf/parcellaire-express.js +59 -26
  13. package/dist/gpf/parcellaire-express.js.map +1 -1
  14. package/dist/gpf/urbanisme.d.ts +24 -16
  15. package/dist/gpf/urbanisme.js +81 -33
  16. package/dist/gpf/urbanisme.js.map +1 -1
  17. package/dist/gpf/{wfs.js → wfs-schema-catalog.js} +1 -1
  18. package/dist/gpf/wfs-schema-catalog.js.map +1 -0
  19. package/dist/helpers/RateLimiter.d.ts +44 -0
  20. package/dist/helpers/RateLimiter.js +52 -0
  21. package/dist/helpers/RateLimiter.js.map +1 -0
  22. package/dist/helpers/distance.d.ts +2 -1
  23. package/dist/helpers/distance.js +2 -1
  24. package/dist/helpers/distance.js.map +1 -1
  25. package/dist/helpers/errors/toolError.d.ts +30 -0
  26. package/dist/helpers/errors/toolError.js +193 -0
  27. package/dist/helpers/errors/toolError.js.map +1 -0
  28. package/dist/helpers/errors/zodErrorMapFr.d.ts +20 -0
  29. package/dist/helpers/errors/zodErrorMapFr.js +191 -0
  30. package/dist/helpers/errors/zodErrorMapFr.js.map +1 -0
  31. package/dist/helpers/http.d.ts +67 -7
  32. package/dist/helpers/http.js +458 -84
  33. package/dist/helpers/http.js.map +1 -1
  34. package/dist/helpers/jsonSchema.d.ts +20 -2
  35. package/dist/helpers/jsonSchema.js +12 -0
  36. package/dist/helpers/jsonSchema.js.map +1 -1
  37. package/dist/helpers/schemas.d.ts +4 -4
  38. package/dist/helpers/wfs_engine/attributeFilter.d.ts +51 -0
  39. package/dist/helpers/wfs_engine/attributeFilter.js +258 -0
  40. package/dist/helpers/wfs_engine/attributeFilter.js.map +1 -0
  41. package/dist/helpers/wfs_engine/byId.d.ts +76 -0
  42. package/dist/helpers/wfs_engine/byId.js +106 -0
  43. package/dist/helpers/wfs_engine/byId.js.map +1 -0
  44. package/dist/helpers/wfs_engine/execution.d.ts +72 -0
  45. package/dist/helpers/wfs_engine/execution.js +95 -0
  46. package/dist/helpers/wfs_engine/execution.js.map +1 -0
  47. package/dist/helpers/wfs_engine/features.d.ts +64 -0
  48. package/dist/helpers/wfs_engine/features.js +138 -0
  49. package/dist/helpers/wfs_engine/features.js.map +1 -0
  50. package/dist/helpers/wfs_engine/geometry.d.ts +16 -0
  51. package/dist/helpers/wfs_engine/geometry.js +44 -0
  52. package/dist/helpers/wfs_engine/geometry.js.map +1 -0
  53. package/dist/helpers/wfs_engine/properties.d.ts +51 -0
  54. package/dist/helpers/wfs_engine/properties.js +128 -0
  55. package/dist/helpers/wfs_engine/properties.js.map +1 -0
  56. package/dist/helpers/wfs_engine/queryPreparation.d.ts +32 -0
  57. package/dist/helpers/wfs_engine/queryPreparation.js +149 -0
  58. package/dist/helpers/wfs_engine/queryPreparation.js.map +1 -0
  59. package/dist/helpers/wfs_engine/request.d.ts +94 -0
  60. package/dist/helpers/wfs_engine/request.js +197 -0
  61. package/dist/helpers/wfs_engine/request.js.map +1 -0
  62. package/dist/helpers/wfs_engine/response.d.ts +80 -0
  63. package/dist/helpers/wfs_engine/response.js +135 -0
  64. package/dist/helpers/wfs_engine/response.js.map +1 -0
  65. package/dist/helpers/wfs_engine/schema.d.ts +209 -0
  66. package/dist/helpers/{wfs_internal → wfs_engine}/schema.js +50 -10
  67. package/dist/helpers/wfs_engine/schema.js.map +1 -0
  68. package/dist/helpers/wfs_engine/spatialCql.d.ts +46 -0
  69. package/dist/helpers/wfs_engine/spatialCql.js +54 -0
  70. package/dist/helpers/wfs_engine/spatialCql.js.map +1 -0
  71. package/dist/helpers/wfs_engine/spatialFilter.d.ts +14 -0
  72. package/dist/helpers/wfs_engine/spatialFilter.js +131 -0
  73. package/dist/helpers/wfs_engine/spatialFilter.js.map +1 -0
  74. package/dist/index.js +65 -23
  75. package/dist/index.js.map +1 -1
  76. package/dist/logger.d.ts +1 -1
  77. package/dist/logger.js +4 -1
  78. package/dist/logger.js.map +1 -1
  79. package/dist/tools/AdminexpressTool.d.ts +42 -33
  80. package/dist/tools/AdminexpressTool.js +19 -3
  81. package/dist/tools/AdminexpressTool.js.map +1 -1
  82. package/dist/tools/AltitudeTool.d.ts +35 -44
  83. package/dist/tools/AltitudeTool.js +19 -8
  84. package/dist/tools/AltitudeTool.js.map +1 -1
  85. package/dist/tools/AssietteSupTool.d.ts +51 -34
  86. package/dist/tools/AssietteSupTool.js +18 -2
  87. package/dist/tools/AssietteSupTool.js.map +1 -1
  88. package/dist/tools/BaseTool.d.ts +17 -0
  89. package/dist/tools/BaseTool.js +41 -0
  90. package/dist/tools/BaseTool.js.map +1 -0
  91. package/dist/tools/CadastreTool.d.ts +53 -33
  92. package/dist/tools/CadastreTool.js +18 -2
  93. package/dist/tools/CadastreTool.js.map +1 -1
  94. package/dist/tools/GeocodeTool.d.ts +53 -37
  95. package/dist/tools/GeocodeTool.js +17 -2
  96. package/dist/tools/GeocodeTool.js.map +1 -1
  97. package/dist/tools/GpfWfsDescribeTypeTool.d.ts +66 -94
  98. package/dist/tools/GpfWfsDescribeTypeTool.js +26 -15
  99. package/dist/tools/GpfWfsDescribeTypeTool.js.map +1 -1
  100. package/dist/tools/GpfWfsGetFeatureByIdTool.d.ts +89 -0
  101. package/dist/tools/GpfWfsGetFeatureByIdTool.js +99 -0
  102. package/dist/tools/GpfWfsGetFeatureByIdTool.js.map +1 -0
  103. package/dist/tools/GpfWfsGetFeaturesTool.d.ts +89 -123
  104. package/dist/tools/GpfWfsGetFeaturesTool.js +31 -144
  105. package/dist/tools/GpfWfsGetFeaturesTool.js.map +1 -1
  106. package/dist/tools/GpfWfsSearchTypesTool.d.ts +41 -32
  107. package/dist/tools/GpfWfsSearchTypesTool.js +18 -3
  108. package/dist/tools/GpfWfsSearchTypesTool.js.map +1 -1
  109. package/dist/tools/UrbanismeTool.d.ts +42 -33
  110. package/dist/tools/UrbanismeTool.js +18 -2
  111. package/dist/tools/UrbanismeTool.js.map +1 -1
  112. package/package.json +51 -24
  113. package/dist/gpf/wfs.js.map +0 -1
  114. package/dist/helpers/wfs.d.ts +0 -27
  115. package/dist/helpers/wfs.js +0 -55
  116. package/dist/helpers/wfs.js.map +0 -1
  117. package/dist/helpers/wfs_internal/compile.d.ts +0 -46
  118. package/dist/helpers/wfs_internal/compile.js +0 -595
  119. package/dist/helpers/wfs_internal/compile.js.map +0 -1
  120. package/dist/helpers/wfs_internal/request.d.ts +0 -38
  121. package/dist/helpers/wfs_internal/request.js +0 -92
  122. package/dist/helpers/wfs_internal/request.js.map +0 -1
  123. package/dist/helpers/wfs_internal/response.d.ts +0 -21
  124. package/dist/helpers/wfs_internal/response.js +0 -29
  125. package/dist/helpers/wfs_internal/response.js.map +0 -1
  126. package/dist/helpers/wfs_internal/schema.d.ts +0 -167
  127. package/dist/helpers/wfs_internal/schema.js.map +0 -1
  128. /package/dist/gpf/{wfs.d.ts → wfs-schema-catalog.d.ts} +0 -0
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Query preparation helpers for the structured WFS engine.
3
+ *
4
+ * This module centralizes:
5
+ * - compilation of attribute clauses into CQL fragments
6
+ * - compilation of spatial filters into CQL fragments
7
+ * - assembly of query parts used by WFS request builders
8
+ * - a small façade over lower-level helpers reused elsewhere in the engine
9
+ */
10
+ import type { Collection, CollectionProperty } from "@ignfab/gpf-schema-store";
11
+ import type { GpfWfsGetFeaturesInput } from "./schema.js";
12
+ export { geometryToEwkt } from "./geometry.js";
13
+ export { validateSelectProperty, getGeometryProperty } from "./properties.js";
14
+ export { getSpatialFilter } from "./spatialFilter.js";
15
+ export type ResolvedFeatureGeometryRef = {
16
+ geometry_ewkt: string;
17
+ };
18
+ export type CompiledQuery = {
19
+ geometryProperty: CollectionProperty;
20
+ cqlFilter?: string;
21
+ propertyName?: string;
22
+ sortBy?: string;
23
+ };
24
+ /**
25
+ * Compiles normalized tool input into query fragments ready to be turned into a WFS request.
26
+ *
27
+ * @param input Normalized tool input.
28
+ * @param featureType Feature type definition loaded from the embedded catalog.
29
+ * @param resolvedGeometryRef Optional resolved reference geometry for `intersects_feature`.
30
+ * @returns Compiled query parts used by request builders.
31
+ */
32
+ export declare function compileQueryParts(input: GpfWfsGetFeaturesInput, featureType: Collection, resolvedGeometryRef?: ResolvedFeatureGeometryRef): CompiledQuery;
@@ -0,0 +1,149 @@
1
+ /**
2
+ * Query preparation helpers for the structured WFS engine.
3
+ *
4
+ * This module centralizes:
5
+ * - compilation of attribute clauses into CQL fragments
6
+ * - compilation of spatial filters into CQL fragments
7
+ * - assembly of query parts used by WFS request builders
8
+ * - a small façade over lower-level helpers reused elsewhere in the engine
9
+ */
10
+ import { buildSelectList, resolveNonGeometryProperty, getGeometryProperty, } from "./properties.js";
11
+ import { getSpatialFilter } from "./spatialFilter.js";
12
+ import { formatScalarValue, normalizeWhereClause, SCALAR_COMPARISON_OPERATORS, NUMERIC_COMPARISON_OPERATORS, } from "./attributeFilter.js";
13
+ import { compileBboxSpatialFilter, compileDwithinSpatialFilter, compileIntersectsFeatureSpatialFilter, compileIntersectsPointSpatialFilter, } from "./spatialCql.js";
14
+ // --- Re-exports ---
15
+ export { geometryToEwkt } from "./geometry.js";
16
+ export { validateSelectProperty, getGeometryProperty } from "./properties.js";
17
+ export { getSpatialFilter } from "./spatialFilter.js";
18
+ // --- Internal Constants ---
19
+ const ORDER_DIRECTION_TO_WFS = {
20
+ asc: "A",
21
+ desc: "D",
22
+ };
23
+ // --- Attribute Compilation ---
24
+ /**
25
+ * Compiles a normalized scalar comparison (`eq` / `ne`) into a CQL fragment.
26
+ *
27
+ * @param property Non-geometric property targeted by the clause.
28
+ * @param clause Normalized scalar comparison clause.
29
+ * @returns A CQL predicate fragment.
30
+ */
31
+ function compileScalarComparisonClause(property, clause) {
32
+ return `${property.name} ${SCALAR_COMPARISON_OPERATORS[clause.operator]} ${formatScalarValue(clause.value)}`;
33
+ }
34
+ /**
35
+ * Compiles a normalized ordered comparison (`lt` / `lte` / `gt` / `gte`) into a CQL fragment.
36
+ *
37
+ * @param property Non-geometric property targeted by the clause.
38
+ * @param clause Normalized ordered comparison clause.
39
+ * @returns A CQL predicate fragment.
40
+ */
41
+ function compileOrderedComparisonClause(property, clause) {
42
+ return `${property.name} ${NUMERIC_COMPARISON_OPERATORS[clause.operator]} ${formatScalarValue(clause.value)}`;
43
+ }
44
+ /**
45
+ * Compiles a normalized `in` clause into a CQL fragment.
46
+ *
47
+ * @param property Non-geometric property targeted by the clause.
48
+ * @param clause Normalized `in` clause.
49
+ * @returns A CQL predicate fragment.
50
+ */
51
+ function compileInClause(property, clause) {
52
+ return `${property.name} IN (${clause.values.map(formatScalarValue).join(", ")})`;
53
+ }
54
+ /**
55
+ * Compiles a normalized `is_null` clause into a CQL fragment.
56
+ *
57
+ * @param property Non-geometric property targeted by the clause.
58
+ * @returns A CQL predicate fragment.
59
+ */
60
+ function compileIsNullClause(property) {
61
+ return `${property.name} IS NULL`;
62
+ }
63
+ /**
64
+ * Compiles a structured where clause into a CQL fragment.
65
+ *
66
+ * @param featureType Feature type definition loaded from the embedded catalog.
67
+ * @param geometryProperty Geometry property already resolved for the feature type.
68
+ * @param clause Raw where clause received from the tool input.
69
+ * @returns A CQL predicate fragment.
70
+ */
71
+ function compileWhereClause(featureType, geometryProperty, clause) {
72
+ const property = resolveNonGeometryProperty(featureType, geometryProperty, clause.property, "La propriété '{property}' est géométrique. Utiliser `spatial_operator` et ses paramètres dédiés.");
73
+ const normalized = normalizeWhereClause(property, clause);
74
+ switch (normalized.operator) {
75
+ case "eq":
76
+ case "ne":
77
+ return compileScalarComparisonClause(property, normalized);
78
+ case "lt":
79
+ case "lte":
80
+ case "gt":
81
+ case "gte":
82
+ return compileOrderedComparisonClause(property, normalized);
83
+ case "in":
84
+ return compileInClause(property, normalized);
85
+ case "is_null":
86
+ return compileIsNullClause(property);
87
+ }
88
+ }
89
+ /**
90
+ * Compiles a structured sort clause into a WFS `sortBy` fragment.
91
+ *
92
+ * @param featureType Feature type definition loaded from the embedded catalog.
93
+ * @param geometryProperty Geometry property already resolved for the feature type.
94
+ * @param clause Raw order-by clause received from the tool input.
95
+ * @returns A WFS `sortBy` fragment.
96
+ */
97
+ function compileOrderByClause(featureType, geometryProperty, clause) {
98
+ const property = resolveNonGeometryProperty(featureType, geometryProperty, clause.property, "La propriété '{property}' est géométrique. Utiliser une propriété non géométrique pour `order_by`.");
99
+ return `${property.name} ${ORDER_DIRECTION_TO_WFS[clause.direction]}`;
100
+ }
101
+ // --- Query Compilation ---
102
+ /**
103
+ * Compiles normalized tool input into query fragments ready to be turned into a WFS request.
104
+ *
105
+ * @param input Normalized tool input.
106
+ * @param featureType Feature type definition loaded from the embedded catalog.
107
+ * @param resolvedGeometryRef Optional resolved reference geometry for `intersects_feature`.
108
+ * @returns Compiled query parts used by request builders.
109
+ */
110
+ export function compileQueryParts(input, featureType, resolvedGeometryRef) {
111
+ const geometryProperty = getGeometryProperty(featureType);
112
+ const spatialFilter = getSpatialFilter(input);
113
+ const fragments = [];
114
+ // Keep the spatial predicate first: the GeoPlateforme GeoServer is sensitive
115
+ // to filter ordering and may reject equivalent filters when attributes come first.
116
+ if (spatialFilter) {
117
+ switch (spatialFilter.operator) {
118
+ case "bbox":
119
+ fragments.push(compileBboxSpatialFilter(geometryProperty, spatialFilter));
120
+ break;
121
+ case "intersects_point":
122
+ fragments.push(compileIntersectsPointSpatialFilter(geometryProperty, spatialFilter));
123
+ break;
124
+ case "dwithin_point":
125
+ fragments.push(compileDwithinSpatialFilter(geometryProperty, spatialFilter));
126
+ break;
127
+ case "intersects_feature":
128
+ if (!resolvedGeometryRef) {
129
+ throw new Error("Le filtre spatial `intersects_feature` exige la résolution préalable de la géométrie de référence.");
130
+ }
131
+ fragments.push(compileIntersectsFeatureSpatialFilter(geometryProperty, resolvedGeometryRef.geometry_ewkt));
132
+ break;
133
+ }
134
+ }
135
+ for (const clause of input.where ?? []) {
136
+ fragments.push(compileWhereClause(featureType, geometryProperty, clause));
137
+ }
138
+ const sortBy = input.order_by && input.order_by.length > 0
139
+ ? input.order_by.map((clause) => compileOrderByClause(featureType, geometryProperty, clause)).join(",")
140
+ : undefined;
141
+ const propertyNames = buildSelectList(featureType, geometryProperty, input);
142
+ return {
143
+ geometryProperty,
144
+ cqlFilter: fragments.length > 0 ? fragments.join(" AND ") : undefined,
145
+ propertyName: propertyNames.length > 0 ? propertyNames.join(",") : undefined,
146
+ sortBy,
147
+ };
148
+ }
149
+ //# sourceMappingURL=queryPreparation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queryPreparation.js","sourceRoot":"","sources":["../../../src/helpers/wfs_engine/queryPreparation.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EAEL,eAAe,EACf,0BAA0B,EAC1B,mBAAmB,GACpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAQtD,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,2BAA2B,EAC3B,4BAA4B,GAC7B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,wBAAwB,EACxB,2BAA2B,EAC3B,qCAAqC,EACrC,mCAAmC,GACpC,MAAM,iBAAiB,CAAC;AAEzB,qBAAqB;AAErB,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAC9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,CAAC,CAAC,CAAC,CAAC,SAAS;QAC5E,MAAM;KACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,94 @@
1
+ /**
2
+ * WFS request builders used by the structured WFS engine.
3
+ *
4
+ * This module centralizes:
5
+ * - the transport shape shared by compiled requests
6
+ * - GET/POST request assembly helpers
7
+ * - the compact request payload exposed by MCP `result_type="request"`
8
+ */
9
+ import type { GpfWfsGetFeaturesInput } from "./schema.js";
10
+ type WfsRequestTransport = {
11
+ method: "POST";
12
+ url: string;
13
+ query: Record<string, string>;
14
+ body: string;
15
+ };
16
+ export type CompiledRequest = WfsRequestTransport & {
17
+ get_url?: string | null;
18
+ };
19
+ export type WfsRequestPayload = WfsRequestTransport & {
20
+ result_type: "request";
21
+ get_url: string | null;
22
+ };
23
+ /**
24
+ * Maps a compiled WFS request to the compact MCP request payload.
25
+ *
26
+ * @param request Compiled request ready to be executed against the WFS service.
27
+ * @returns A normalized request payload exposed by MCP tools.
28
+ */
29
+ export declare function toWfsRequestPayload(request: CompiledRequest): WfsRequestPayload;
30
+ /**
31
+ * Builds a portable GET URL variant of the request when it stays below the configured limit.
32
+ *
33
+ * This helper is mainly used to populate `get_url` in request payloads
34
+ * returned by `result_type="request"`.
35
+ *
36
+ * @param url Base WFS endpoint URL.
37
+ * @param query Query-string parameters sent with the request.
38
+ * @param cqlFilter Optional CQL filter to append to the GET variant.
39
+ * @returns A derived GET URL, or `null` when it would be too long to expose safely.
40
+ */
41
+ export declare function buildGetUrl(url: string, query: Record<string, string>, cqlFilter?: string): string | null;
42
+ /**
43
+ * Builds the main WFS GetFeature request from normalized tool input and compiled query parts.
44
+ *
45
+ * @param input Normalized tool input.
46
+ * @param compiled Compiled query fragments produced from the input and feature type.
47
+ * @returns A POST request split into base URL, query-string parameters, encoded body, and optional GET variant.
48
+ */
49
+ export declare function buildMainRequest(input: GpfWfsGetFeaturesInput, compiled: {
50
+ cqlFilter?: string;
51
+ propertyName?: string;
52
+ sortBy?: string;
53
+ }): CompiledRequest;
54
+ /**
55
+ * Builds the auxiliary request used to fetch the geometry of a reference feature.
56
+ *
57
+ * @param typename Typename of the reference layer.
58
+ * @param featureId Identifier of the reference feature.
59
+ * @param geometryPropertyName Geometry property to request from the reference layer.
60
+ * @returns A POST request targeting the reference feature lookup.
61
+ */
62
+ export declare function buildReferenceGeometryRequest(typename: string, featureId: string, geometryPropertyName: string): CompiledRequest;
63
+ /**
64
+ * Builds a GetFeature request targeting exactly one feature by its WFS `featureID`.
65
+ *
66
+ * @param typename Typename of the target layer.
67
+ * @param featureId Identifier of the target feature.
68
+ * @param propertyName Optional comma-separated property list.
69
+ * @returns A POST request split into base URL, query-string parameters, empty body, and optional GET variant.
70
+ */
71
+ export declare function buildGetFeatureByIdRequest(typename: string, featureId: string, propertyName?: string): CompiledRequest;
72
+ /**
73
+ * Input parameters for building a multi-typename WFS request.
74
+ */
75
+ export type MultiTypenameRequestInput = {
76
+ /** Fully qualified WFS type names to query. */
77
+ typenames: string[];
78
+ /** Pre-compiled CQL filter string, when one shared filter is intentionally reused for all typenames. */
79
+ cqlFilter?: string;
80
+ /** Pre-compiled CQL filters aligned with `typenames` (same length, same order). */
81
+ cqlFilters?: string[];
82
+ };
83
+ /**
84
+ * Builds a WFS GetFeature request targeting multiple typenames.
85
+ *
86
+ * Unlike `buildMainRequest()`, this builder accepts a raw CQL filter
87
+ * and a list of typenames, making it suitable for domain-oriented modules
88
+ * that query several layers at once.
89
+ *
90
+ * @param input Multi-typename request parameters.
91
+ * @returns A POST request split into base URL, query-string parameters, encoded body, and optional GET variant.
92
+ */
93
+ export declare function buildMultiTypenameRequest(input: MultiTypenameRequestInput): CompiledRequest;
94
+ export {};
@@ -0,0 +1,197 @@
1
+ /**
2
+ * WFS request builders used by the structured WFS engine.
3
+ *
4
+ * This module centralizes:
5
+ * - the transport shape shared by compiled requests
6
+ * - GET/POST request assembly helpers
7
+ * - the compact request payload exposed by MCP `result_type="request"`
8
+ */
9
+ import { GPF_WFS_URL } from "../../gpf/wfs-schema-catalog.js";
10
+ import { REQUEST_GET_URL_MAX_LENGTH } from "./schema.js";
11
+ // --- Request Payload Mapping ---
12
+ /**
13
+ * Maps a compiled WFS request to the compact MCP request payload.
14
+ *
15
+ * @param request Compiled request ready to be executed against the WFS service.
16
+ * @returns A normalized request payload exposed by MCP tools.
17
+ */
18
+ export function toWfsRequestPayload(request) {
19
+ return {
20
+ result_type: "request",
21
+ method: request.method,
22
+ url: request.url,
23
+ query: request.query,
24
+ body: request.body,
25
+ get_url: request.get_url ?? null,
26
+ };
27
+ }
28
+ // --- Request Assembly Helpers ---
29
+ /**
30
+ * Encodes the optional CQL filter as an `application/x-www-form-urlencoded` POST body.
31
+ *
32
+ * @param cqlFilter Compiled CQL filter, when the request needs one.
33
+ * @returns The encoded POST body, or an empty string when no filter is present.
34
+ */
35
+ function buildBody(cqlFilter) {
36
+ if (!cqlFilter) {
37
+ return "";
38
+ }
39
+ return new URLSearchParams({ cql_filter: cqlFilter }).toString();
40
+ }
41
+ /**
42
+ * Builds a portable GET URL variant of the request when it stays below the configured limit.
43
+ *
44
+ * This helper is mainly used to populate `get_url` in request payloads
45
+ * returned by `result_type="request"`.
46
+ *
47
+ * @param url Base WFS endpoint URL.
48
+ * @param query Query-string parameters sent with the request.
49
+ * @param cqlFilter Optional CQL filter to append to the GET variant.
50
+ * @returns A derived GET URL, or `null` when it would be too long to expose safely.
51
+ */
52
+ export function buildGetUrl(url, query, cqlFilter) {
53
+ const params = new URLSearchParams(query);
54
+ if (cqlFilter) {
55
+ params.set("cql_filter", cqlFilter);
56
+ }
57
+ const getUrl = `${url}?${params.toString()}`;
58
+ if (getUrl.length > REQUEST_GET_URL_MAX_LENGTH) {
59
+ return null;
60
+ }
61
+ return getUrl;
62
+ }
63
+ // --- Public Builders ---
64
+ /**
65
+ * Builds the main WFS GetFeature request from normalized tool input and compiled query parts.
66
+ *
67
+ * @param input Normalized tool input.
68
+ * @param compiled Compiled query fragments produced from the input and feature type.
69
+ * @returns A POST request split into base URL, query-string parameters, encoded body, and optional GET variant.
70
+ */
71
+ export function buildMainRequest(input, compiled) {
72
+ const query = {
73
+ service: "WFS",
74
+ version: "2.0.0",
75
+ request: "GetFeature",
76
+ typeNames: input.typename,
77
+ outputFormat: "application/json",
78
+ exceptions: "application/json",
79
+ count: input.result_type === "hits" ? "1" : String(input.limit),
80
+ };
81
+ if (compiled.propertyName && input.result_type !== "hits") {
82
+ query.propertyName = compiled.propertyName;
83
+ }
84
+ if (compiled.sortBy) {
85
+ query.sortBy = compiled.sortBy;
86
+ }
87
+ const body = buildBody(compiled.cqlFilter);
88
+ return {
89
+ method: "POST",
90
+ url: GPF_WFS_URL,
91
+ query,
92
+ body,
93
+ get_url: buildGetUrl(GPF_WFS_URL, query, compiled.cqlFilter),
94
+ };
95
+ }
96
+ /**
97
+ * Builds the auxiliary request used to fetch the geometry of a reference feature.
98
+ *
99
+ * @param typename Typename of the reference layer.
100
+ * @param featureId Identifier of the reference feature.
101
+ * @param geometryPropertyName Geometry property to request from the reference layer.
102
+ * @returns A POST request targeting the reference feature lookup.
103
+ */
104
+ export function buildReferenceGeometryRequest(typename, featureId, geometryPropertyName) {
105
+ const query = {
106
+ service: "WFS",
107
+ version: "2.0.0",
108
+ request: "GetFeature",
109
+ typeNames: typename,
110
+ outputFormat: "application/json",
111
+ exceptions: "application/json",
112
+ featureID: featureId,
113
+ propertyName: geometryPropertyName,
114
+ count: "1",
115
+ };
116
+ return {
117
+ method: "POST",
118
+ url: GPF_WFS_URL,
119
+ query,
120
+ body: "",
121
+ get_url: buildGetUrl(GPF_WFS_URL, query),
122
+ };
123
+ }
124
+ /**
125
+ * Builds a GetFeature request targeting exactly one feature by its WFS `featureID`.
126
+ *
127
+ * @param typename Typename of the target layer.
128
+ * @param featureId Identifier of the target feature.
129
+ * @param propertyName Optional comma-separated property list.
130
+ * @returns A POST request split into base URL, query-string parameters, empty body, and optional GET variant.
131
+ */
132
+ export function buildGetFeatureByIdRequest(typename, featureId, propertyName) {
133
+ const query = {
134
+ service: "WFS",
135
+ version: "2.0.0",
136
+ request: "GetFeature",
137
+ typeNames: typename,
138
+ outputFormat: "application/json",
139
+ exceptions: "application/json",
140
+ featureID: featureId,
141
+ count: "2",
142
+ };
143
+ if (propertyName) {
144
+ query.propertyName = propertyName;
145
+ }
146
+ return {
147
+ method: "POST",
148
+ url: GPF_WFS_URL,
149
+ query,
150
+ body: "",
151
+ get_url: buildGetUrl(GPF_WFS_URL, query),
152
+ };
153
+ }
154
+ /**
155
+ * Builds a WFS GetFeature request targeting multiple typenames.
156
+ *
157
+ * Unlike `buildMainRequest()`, this builder accepts a raw CQL filter
158
+ * and a list of typenames, making it suitable for domain-oriented modules
159
+ * that query several layers at once.
160
+ *
161
+ * @param input Multi-typename request parameters.
162
+ * @returns A POST request split into base URL, query-string parameters, encoded body, and optional GET variant.
163
+ */
164
+ export function buildMultiTypenameRequest(input) {
165
+ if (input.cqlFilter && input.cqlFilters) {
166
+ throw new Error("`cqlFilter` et `cqlFilters` ne peuvent pas être utilisés ensemble.");
167
+ }
168
+ if (input.cqlFilters && input.cqlFilters.length !== input.typenames.length) {
169
+ throw new Error(`Le nombre de filtres CQL (${input.cqlFilters.length}) doit correspondre au nombre de typenames (${input.typenames.length}).`);
170
+ }
171
+ const encodedTypeNames = input.typenames.map((typename) => `(${typename})`).join("");
172
+ const expandedCqlFilter = input.cqlFilters
173
+ ? input.cqlFilters.join(";")
174
+ : input.cqlFilter
175
+ ? input.typenames.map(() => input.cqlFilter).join(";")
176
+ : undefined;
177
+ const query = {
178
+ service: "WFS",
179
+ version: "2.0.0",
180
+ request: "GetFeature",
181
+ typeNames: encodedTypeNames,
182
+ outputFormat: "application/json",
183
+ exceptions: "application/json",
184
+ srsName: "EPSG:4326",
185
+ };
186
+ const body = expandedCqlFilter
187
+ ? new URLSearchParams({ cql_filter: expandedCqlFilter }).toString()
188
+ : "";
189
+ return {
190
+ method: "POST",
191
+ url: GPF_WFS_URL,
192
+ query,
193
+ body,
194
+ get_url: buildGetUrl(GPF_WFS_URL, query, expandedCqlFilter),
195
+ };
196
+ }
197
+ //# sourceMappingURL=request.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.js","sourceRoot":"","sources":["../../../src/helpers/wfs_engine/request.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAoBzD,kCAAkC;AAElC;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAwB;IAC1D,OAAO;QACL,WAAW,EAAE,SAAS;QACtB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,IAAI;KACjC,CAAC;AACJ,CAAC;AAED,mCAAmC;AAEnC;;;;;GAKG;AACH,SAAS,SAAS,CAAC,SAAkB;IACnC,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,IAAI,eAAe,CAAC,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;AACnE,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,WAAW,CAAC,GAAW,EAAE,KAA6B,EAAE,SAAkB;IACxF,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,CAAC;IAC1C,IAAI,SAAS,EAAE,CAAC;QACd,MAAM,CAAC,GAAG,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;IACtC,CAAC;IACD,MAAM,MAAM,GAAG,GAAG,GAAG,IAAI,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC;IAC7C,IAAI,MAAM,CAAC,MAAM,GAAG,0BAA0B,E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+CAA+C,KAAK,CAAC,SAAS,CAAC,MAAM,IAAI,CAC9H,CAAC;IACJ,CAAC;IAED,MAAM,gBAAgB,GAAG,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,QAAQ,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAErF,MAAM,iBAAiB,GAAG,KAAK,CAAC,UAAU;QACxC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC;QAC5B,CAAC,CAAC,KAAK,CAAC,SAAS;YACf,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;YACtD,CAAC,CAAC,SAAS,CAAC;IAEhB,MAAM,KAAK,GAA2B;QACpC,OAAO,EAAE,KAAK;QACd,OAAO,EAAE,OAAO;QAChB,OAAO,EAAE,YAAY;QACrB,SAAS,EAAE,gBAAgB;QAC3B,YAAY,EAAE,kBAAkB;QAChC,UAAU,EAAE,kBAAkB;QAC9B,OAAO,EAAE,WAAW;KACrB,CAAC;IAEF,MAAM,IAAI,GAAG,iBAAiB;QAC5B,CAAC,CAAC,IAAI,eAAe,CAAC,EAAE,UAAU,EAAE,iBAAiB,EAAE,CAAC,CAAC,QAAQ,EAAE;QACnE,CAAC,CAAC,EAAE,CAAC;IAEP,OAAO;QACL,MAAM,EAAE,MAAM;QACd,GAAG,EAAE,WAAW;QAChB,KAAK;QACL,IAAI;QACJ,OAAO,EAAE,WAAW,CAAC,WAAW,EAAE,KAAK,EAAE,iBAAiB,CAAC;KAC5D,CAAC;AACJ,CAAC"}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Structured WFS response layer used by the MCP WFS tools and domain-oriented modules.
3
+ *
4
+ * This module provides:
5
+ * - FeatureCollection-preserving transformations for the MCP WFS tools
6
+ * - Flat item mapping for domain-oriented modules (`src/gpf/*`)
7
+ */
8
+ type GenericFeature = {
9
+ id?: unknown;
10
+ geometry?: unknown;
11
+ geometry_name?: string;
12
+ bbox?: unknown;
13
+ properties?: unknown;
14
+ [key: string]: unknown;
15
+ };
16
+ type GenericFeatureCollection = {
17
+ features?: GenericFeature[];
18
+ [key: string]: unknown;
19
+ };
20
+ type FeatureRef = {
21
+ typename: string | null;
22
+ feature_id: string;
23
+ };
24
+ type TransformedFeature = Record<string, unknown> & {
25
+ feature_ref?: FeatureRef;
26
+ };
27
+ type TransformedFeatureCollection = Record<string, unknown> & {
28
+ features?: TransformedFeature[];
29
+ };
30
+ /**
31
+ * A flattened WFS feature with properties spread at the top level.
32
+ *
33
+ * This is the output format used by domain-oriented modules (`src/gpf/*`)
34
+ * as opposed to the FeatureCollection-preserving format used by the MCP WFS tools.
35
+ */
36
+ export type FlatItem = Record<string, unknown> & {
37
+ type: string;
38
+ id: string;
39
+ bbox?: number[];
40
+ feature_ref?: {
41
+ typename: string;
42
+ feature_id: string;
43
+ };
44
+ };
45
+ /**
46
+ * Removes raw geometry payloads from a FeatureCollection, keeps GeoJSON validity by forcing
47
+ * `geometry: null`, and exposes lightweight `feature_ref` objects reusable by follow-up requests.
48
+ *
49
+ * @param featureCollection Raw FeatureCollection returned by the WFS endpoint.
50
+ * @returns A transformed FeatureCollection with raw geometry fields removed, `geometry: null`, and optional `feature_ref` metadata.
51
+ */
52
+ export declare function transformFeatureCollectionResponse(featureCollection: GenericFeatureCollection): TransformedFeatureCollection;
53
+ /**
54
+ * Transforms a FeatureCollection and injects the exact queried typename into each `feature_ref`.
55
+ *
56
+ * @param featureCollection Raw FeatureCollection returned by the WFS endpoint.
57
+ * @param typename Typename of the queried layer.
58
+ * @returns A transformed FeatureCollection whose `feature_ref` objects carry the exact typename.
59
+ */
60
+ export declare function attachFeatureRefs(featureCollection: GenericFeatureCollection, typename: string): TransformedFeatureCollection;
61
+ /**
62
+ * Maps a FeatureCollection to an array of flat items without preserving geometry.
63
+ *
64
+ * @param featureCollection Raw FeatureCollection returned by the WFS endpoint.
65
+ * @param knownTypeNames Fully qualified typenames used for `feature_ref` resolution.
66
+ * @returns An array of flat items with spread properties and `feature_ref`.
67
+ */
68
+ export declare function mapToFlatItems(featureCollection: GenericFeatureCollection, knownTypeNames: string[]): FlatItem[];
69
+ /**
70
+ * Maps a FeatureCollection to an array of flat items preserving raw geometry
71
+ * in a temporary `_rawGeometry` field for downstream distance calculations.
72
+ *
73
+ * Callers should strip `_rawGeometry` from the final output.
74
+ *
75
+ * @param featureCollection Raw FeatureCollection returned by the WFS endpoint.
76
+ * @param knownTypeNames Fully qualified typenames used for `feature_ref` resolution.
77
+ * @returns An array of flat items with `_rawGeometry` preserved.
78
+ */
79
+ export declare function mapToFlatItemsWithGeometry(featureCollection: GenericFeatureCollection, knownTypeNames: string[]): FlatItem[];
80
+ export {};