@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
@@ -1 +1 @@
1
- {"version":3,"file":"GpfWfsSearchTypesTool.js","sourceRoot":"","sources":["../../src/tools/GpfWfsSearchTypesTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,qCAAqC,EAAE,MAAM,+BAA+B,CAAC;AACtF,OAAO,EAAE,SAAS,EAAE,MAAM,eA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CAAC,CAAC;QAEH,MAAM,UAAU,GAAG,KAAK,CAAC,WAAW,IAAI,EAAE,CAAC;QAC3C,MAAM,YAAY,GAAG,MAAM,SAAS,CAAC,4BAA4B,CAAC,KAAK,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;QAC3F,OAAO;YACL,OAAO,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;gBACpD,EAAE,EAAE,UAAU,CAAC,EAAE;gBACjB,KAAK,EAAE,UAAU,CAAC,KAAK;gBACvB,WAAW,EAAE,UAAU,CAAC,WAAW;gBACnC,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAC1C,CAAC,CAAC;SACJ,CAAC;IACJ,CAAC;CACF;AAED,eAAe,qBAAqB,CAAC"}
@@ -1,17 +1,20 @@
1
- import { MCPTool } from "mcp-framework";
1
+ /**
2
+ * MCP tool exposing urban planning information around a given point.
3
+ */
4
+ import BaseTool from "./BaseTool.js";
2
5
  import { z } from "zod";
3
6
  declare const urbanismeInputSchema: z.ZodObject<{
4
7
  lon: z.ZodNumber;
5
8
  lat: z.ZodNumber;
6
9
  }, "strict", z.ZodTypeAny, {
7
- lon?: number;
8
- lat?: number;
10
+ lon: number;
11
+ lat: number;
9
12
  }, {
10
- lon?: number;
11
- lat?: number;
13
+ lon: number;
14
+ lat: number;
12
15
  }>;
13
16
  type UrbanismeInput = z.infer<typeof urbanismeInputSchema>;
14
- declare class UrbanismeTool extends MCPTool<UrbanismeInput> {
17
+ declare class UrbanismeTool extends BaseTool<UrbanismeInput> {
15
18
  name: string;
16
19
  title: string;
17
20
  annotations: {
@@ -30,11 +33,11 @@ declare class UrbanismeTool extends MCPTool<UrbanismeInput> {
30
33
  typename: z.ZodString;
31
34
  feature_id: z.ZodString;
32
35
  }, "strip", z.ZodTypeAny, {
33
- typename?: string;
34
- feature_id?: string;
36
+ typename: string;
37
+ feature_id: string;
35
38
  }, {
36
- typename?: string;
37
- feature_id?: string;
39
+ typename: string;
40
+ feature_id: string;
38
41
  }>>;
39
42
  distance: z.ZodNumber;
40
43
  }, "strip", z.ZodUnknown, z.objectOutputType<{
@@ -45,11 +48,11 @@ declare class UrbanismeTool extends MCPTool<UrbanismeInput> {
45
48
  typename: z.ZodString;
46
49
  feature_id: z.ZodString;
47
50
  }, "strip", z.ZodTypeAny, {
48
- typename?: string;
49
- feature_id?: string;
51
+ typename: string;
52
+ feature_id: string;
50
53
  }, {
51
- typename?: string;
52
- feature_id?: string;
54
+ typename: string;
55
+ feature_id: string;
53
56
  }>>;
54
57
  distance: z.ZodNumber;
55
58
  }, z.ZodUnknown, "strip">, z.objectInputType<{
@@ -60,16 +63,16 @@ declare class UrbanismeTool extends MCPTool<UrbanismeInput> {
60
63
  typename: z.ZodString;
61
64
  feature_id: z.ZodString;
62
65
  }, "strip", z.ZodTypeAny, {
63
- typename?: string;
64
- feature_id?: string;
66
+ typename: string;
67
+ feature_id: string;
65
68
  }, {
66
- typename?: string;
67
- feature_id?: string;
69
+ typename: string;
70
+ feature_id: string;
68
71
  }>>;
69
72
  distance: z.ZodNumber;
70
73
  }, z.ZodUnknown, "strip">>, "many">;
71
74
  }, "strip", z.ZodTypeAny, {
72
- results?: z.objectOutputType<{
75
+ results: z.objectOutputType<{
73
76
  type: z.ZodString;
74
77
  id: z.ZodString;
75
78
  bbox: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
@@ -77,16 +80,16 @@ declare class UrbanismeTool extends MCPTool<UrbanismeInput> {
77
80
  typename: z.ZodString;
78
81
  feature_id: z.ZodString;
79
82
  }, "strip", z.ZodTypeAny, {
80
- typename?: string;
81
- feature_id?: string;
83
+ typename: string;
84
+ feature_id: string;
82
85
  }, {
83
- typename?: string;
84
- feature_id?: string;
86
+ typename: string;
87
+ feature_id: string;
85
88
  }>>;
86
89
  distance: z.ZodNumber;
87
90
  }, z.ZodUnknown, "strip">[];
88
91
  }, {
89
- results?: z.objectInputType<{
92
+ results: z.objectInputType<{
90
93
  type: z.ZodString;
91
94
  id: z.ZodString;
92
95
  bbox: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
@@ -94,11 +97,11 @@ declare class UrbanismeTool extends MCPTool<UrbanismeInput> {
94
97
  typename: z.ZodString;
95
98
  feature_id: z.ZodString;
96
99
  }, "strip", z.ZodTypeAny, {
97
- typename?: string;
98
- feature_id?: string;
100
+ typename: string;
101
+ feature_id: string;
99
102
  }, {
100
- typename?: string;
101
- feature_id?: string;
103
+ typename: string;
104
+ feature_id: string;
102
105
  }>>;
103
106
  distance: z.ZodNumber;
104
107
  }, z.ZodUnknown, "strip">[];
@@ -107,14 +110,20 @@ declare class UrbanismeTool extends MCPTool<UrbanismeInput> {
107
110
  lon: z.ZodNumber;
108
111
  lat: z.ZodNumber;
109
112
  }, "strict", z.ZodTypeAny, {
110
- lon?: number;
111
- lat?: number;
113
+ lon: number;
114
+ lat: number;
112
115
  }, {
113
- lon?: number;
114
- lat?: number;
116
+ lon: number;
117
+ lat: number;
115
118
  }>;
119
+ /**
120
+ * Returns the urban planning objects relevant to the requested point.
121
+ *
122
+ * @param input Normalized tool input.
123
+ * @returns The relevant urban planning objects, including reusable `feature_ref` metadata when available.
124
+ */
116
125
  execute(input: UrbanismeInput): Promise<{
117
- results: {}[];
126
+ results: Record<string, unknown>[];
118
127
  }>;
119
128
  }
120
129
  export default UrbanismeTool;
@@ -1,8 +1,13 @@
1
- import { MCPTool } from "mcp-framework";
1
+ /**
2
+ * MCP tool exposing urban planning information around a given point.
3
+ */
4
+ import BaseTool from "./BaseTool.js";
2
5
  import { z } from "zod";
3
6
  import { getUrbanisme, URBANISME_SOURCE } from "../gpf/urbanisme.js";
4
7
  import { READ_ONLY_OPEN_WORLD_TOOL_ANNOTATIONS } from "../helpers/toolAnnotations.js";
5
8
  import { featureRefSchema, lonSchema, latSchema } from "../helpers/schemas.js";
9
+ import logger from "../logger.js";
10
+ // --- Schema ---
6
11
  const urbanismeInputSchema = z.object({
7
12
  lon: lonSchema,
8
13
  lat: latSchema,
@@ -24,19 +29,30 @@ const URBANISME_TOOL_DESCRIPTION = [
24
29
  "Les résultats peuvent notamment inclure le document d'urbanisme applicable ainsi que des éléments réglementaires associés à proximité du point.",
25
30
  "Quand un objet correspond à une couche WFS réutilisable, il expose aussi un `feature_ref` compatible avec `gpf_wfs_get_features` et `spatial_operator=\"intersects_feature\"`.",
26
31
  "Le zonage PLU (zone U, AU, A, N...) est inclus dans les zones retournées et constitue souvent l'information principale recherchée.",
32
+ "Pour récupérer exactement l'objet correspondant au `feature_ref`, utiliser `gpf_wfs_get_feature_by_id`.",
27
33
  "Modèles d'URL Géoportail de l'Urbanisme :",
28
34
  "- fiche document: https://www.geoportail-urbanisme.gouv.fr/document/by-id/{gpu_doc_id}",
29
35
  "- carte: https://www.geoportail-urbanisme.gouv.fr/map/?documentId={gpu_doc_id}",
30
36
  "- fichier: https://www.geoportail-urbanisme.gouv.fr/api/document/{gpu_doc_id}/files/{nomfic}",
31
37
  ].join("\n");
32
- class UrbanismeTool extends MCPTool {
38
+ // --- Tool ---
39
+ class UrbanismeTool extends BaseTool {
33
40
  name = "urbanisme";
34
41
  title = "Informations d’urbanisme";
35
42
  annotations = READ_ONLY_OPEN_WORLD_TOOL_ANNOTATIONS;
36
43
  description = URBANISME_TOOL_DESCRIPTION;
37
44
  outputSchemaShape = urbanismeOutputSchema;
38
45
  schema = urbanismeInputSchema;
46
+ /**
47
+ * Returns the urban planning objects relevant to the requested point.
48
+ *
49
+ * @param input Normalized tool input.
50
+ * @returns The relevant urban planning objects, including reusable `feature_ref` metadata when available.
51
+ */
39
52
  async execute(input) {
53
+ logger.info(`[tool] execute ${this.name} ...`, {
54
+ input: input
55
+ });
40
56
  return {
41
57
  results: await getUrbanisme(input.lon, input.lat),
42
58
  };
@@ -1 +1 @@
1
- {"version":3,"file":"UrbanismeTool.js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K;SACb,CAAC,CAAC;QAEH,OAAO;YACL,OAAO,EAAE,MAAM,YAAY,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC;SAClD,CAAC;IACJ,CAAC;CACF;AAED,eAAe,aAAa,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ignfab/geocontext",
3
- "version": "0.9.5",
3
+ "version": "0.9.7",
4
4
  "description": "An experimental MCP server providing access to the services and data of the french Geoplateform",
5
5
  "type": "module",
6
6
  "bin": {
@@ -28,42 +28,69 @@
28
28
  "homepage": "https://github.com/ignfab/geocontext#readme",
29
29
  "scripts": {
30
30
  "clean:dist": "node scripts/dist-clean.js",
31
- "build": "npm run clean:dist && tsc && npx mcp-build",
31
+ "clean:coverage": "rm -rf coverage",
32
+ "clean:deps": "rm -rf node_modules",
33
+ "clean": "npm run clean:dist && npm run clean:coverage",
34
+ "reset:local": "npm run clean && npm run clean:deps",
35
+ "build": "npm run clean:dist && mcp-build",
36
+ "docs:mcp": "npm run build && node --no-warnings scripts/generate-mcp-docs.mjs",
37
+ "typecheck": "tsc -p tsconfig.json --noEmit",
38
+ "typecheck:test": "tsc -p tsconfig.test.json --noEmit",
32
39
  "watch": "tsc --watch",
33
- "start": "node dist/index.js",
34
- "test": "node --no-warnings --experimental-vm-modules ./node_modules/jest/bin/jest.js",
35
- "coverage": "node --no-warnings --experimental-vm-modules ./node_modules/jest/bin/jest.js --coverage",
36
- "reset": "rm -rf node_modules package-lock.json dist build .next .turbo coverage",
37
- "fresh": "npm run reset && npm cache verify && npm install && npm run build && npm test"
40
+ "start": "node --use-env-proxy dist/index.js",
41
+ "test": "npm run test:unit",
42
+ "test:unit": "vitest run",
43
+ "test:integration": "vitest run --config vitest.integration.config.mts",
44
+ "test:e2e": "vitest run --config vitest.e2e.config.mts",
45
+ "test:coverage": "vitest run --coverage",
46
+ "verify:fast": "npm run typecheck && npm run typecheck:test && npm run build && npm run test:unit",
47
+ "verify": "npm run verify:fast && npm run test:integration",
48
+ "verify:full": "npm run verify && npm run test:e2e",
49
+ "fresh": "npm run reset:local && npm ci && npm run verify",
50
+ "deps:outdated": "npm outdated",
51
+ "deps:audit": "npm audit",
52
+ "inspect:mcp": "mcp-inspector -- node --use-env-proxy dist/index.js",
53
+ "inspect:mcp:cli": "mcp-inspector --cli node --use-env-proxy dist/index.js"
38
54
  },
39
55
  "dependencies": {
40
56
  "@ignfab/gpf-schema-store": "^0.1.5",
41
57
  "@rgrove/parse-xml": "^4.2.0",
42
- "@turf/distance": "^7.3.4",
43
- "@turf/helpers": "^7.3.4",
44
- "https-proxy-agent": "^7.0.6",
58
+ "@turf/distance": "^7.3.5",
59
+ "@turf/helpers": "^7.3.5",
45
60
  "jsts": "^2.12.1",
46
- "lodash": "^4.17.21",
47
61
  "mcp-framework": "^0.2.22",
48
62
  "node-fetch": "^3.3.2",
49
- "winston": "^3.18.3",
63
+ "winston": "^3.19.0",
50
64
  "zod": "^3.25.76"
51
65
  },
52
66
  "devDependencies": {
53
- "@types/cors": "^2.8.19",
67
+ "@langchain/anthropic": "^1.3.28",
68
+ "@langchain/core": "^1.1.44",
69
+ "@langchain/langgraph": "^1.3.0",
70
+ "@langchain/mcp-adapters": "^1.1.3",
71
+ "@langchain/ollama": "^1.2.7",
72
+ "@modelcontextprotocol/inspector": "^0.21.2",
73
+ "@modelcontextprotocol/sdk": "^1.29.0",
54
74
  "@types/geojson": "^7946.0.16",
55
- "@types/jest": "^30.0.0",
56
- "@types/lodash": "^4.17.21",
57
- "@types/node": "^24.10.1",
58
- "@types/supertest": "^6.0.3",
59
- "geojson": "^0.5.0",
60
- "jest": "^30.2.0",
61
- "supertest": "^7.1.4",
62
- "ts-jest": "^29.4.5",
63
- "ts-node": "^10.9.2",
64
- "typescript": "^5.9.3"
75
+ "@types/node": "^25.6.0",
76
+ "@vitest/coverage-v8": "^4.1.5",
77
+ "langchain": "^1.3.5",
78
+ "supertest": "^7.2.2",
79
+ "typescript": "^6.0.3",
80
+ "vitest": "^4.1.5"
65
81
  },
66
82
  "engines": {
67
- "node": ">=18.19.0"
83
+ "node": ">=22.21.0 <23 || >=24.5.0"
84
+ },
85
+ "devEngines": {
86
+ "runtime": {
87
+ "name": "node",
88
+ "version": ">=22.21.0 <23 || >=24.5.0",
89
+ "onFail": "error"
90
+ },
91
+ "packageManager": {
92
+ "name": "npm",
93
+ "onFail": "error"
94
+ }
68
95
  }
69
96
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"wfs.js","sourceRoot":"","sources":["../../src/gpf/wfs.ts"],"names":[],"mappings":"AAAA,kBAAkB;AAElB,OAAO,EAGH,oBAAoB,EACpB,gCAAgC,GAEnC,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,oBAAoB;AAEpB,MAAM,CAAC,MAAM,WAAW,GAAG,2BAA2B,CAAC;AAEvD,mFAAmF;AACnF,MAAM,8BAA8B,GAAG,4BAA4B,CAAC;AAEpE,sFAAsF;AACtF,MAAM,8BAA8B,GAAG;IACnC,WAAW;IACX,MAAM;IACN,OAAO;IACP,aAAa;IACb,YAAY;IACZ,OAAO;IACP,kBAAkB;CACZ,CAAC;AAEX,MAAM,8BAA8B,GAAG,CAAC,KAAK,EAAE,IAAI,CAAU,CAAC;AAM9D,iBAAiB;AAEjB,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IAC/C,YAAY,IAAY;QACpB,KAAK,CAAC,YAAY,IAAI,mBAAmB,CAAC,CAAC;QAC3C,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;IAC3C,CAAC;CACJ;AAED,kBAAkB;AAElB,SAAS,yBAAyB,CAAC,MAAc;IAC7C,OAAO,IAAI,KAAK,CAAC,WAAW,8BAA8B,KAAK,MAAM,EAAE,CAAC,CAAC;AAC7E,CAAC;AAED,gCAAgC;AAEhC,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC;IACrC,MAAM,EAAE,C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EAAE;YACxC,KAAK,EAAE,UAAU;SACpB,CAAC,CAAC;IACP,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,IAAY;QAC7B,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC/C,IAAI,WAAW,EAAE,CAAC;YACd,OAAO,WAAW,CAAC;QACvB,CAAC;QACD,MAAM,IAAI,wBAAwB,CAAC,IAAI,CAAC,CAAC;IAC7C,CAAC;CAEJ;AAED,4BAA4B;AAE5B,kGAAkG;AAClG,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,SAAS,CAAC,SAAS,EAAE;IAC9C,UAAU,EAAE,4BAA4B,EAAE;CAC7C,CAAC,CAAC"}
@@ -1,27 +0,0 @@
1
- /**
2
- * Fetch features from a GPF WFS endpoint.
3
- *
4
- * @param {string[]} typeNames - fully qualified WFS type names
5
- * @param {string} cqlFilter - CQL_FILTER value
6
- * @param {string} errorLabel - service label used in the error message
7
- * @param {(url: string) => Promise<any>} [fetcher]
8
- * @returns {Promise<any[]>} raw GeoJSON features array
9
- */
10
- export function fetchWfsFeatures(typeNames: string[], cqlFilter: string, errorLabel: string, fetcher?: (url: string) => Promise<any>): Promise<any[]>;
11
- /**
12
- * Builds a GeoJSON Point from longitude and latitude.
13
- *
14
- * @param {number} lon
15
- * @param {number} lat
16
- * @returns {object} GeoJSON Point
17
- */
18
- export function toGeoJsonPoint(lon: number, lat: number): object;
19
- /**
20
- * Maps a raw WFS feature into a flat result object, stripping geometry
21
- * and resolving a reusable feature_ref from the known type names.
22
- *
23
- * @param {object} feature - Raw GeoJSON feature from WFS
24
- * @param {string[]} knownTypeNames - Fully qualified WFS type names used for feature_ref resolution
25
- * @returns {object} Flat result with type, id, bbox, optional feature_ref, and spread properties
26
- */
27
- export function mapWfsFeature(feature: object, knownTypeNames: string[]): object;
@@ -1,55 +0,0 @@
1
- import { fetchJSON } from './http.js';
2
- const GPF_WFS_BASE_URL = process.env.GPF_WFS_BASE_URL || 'https://data.geopf.fr/wfs';
3
- /**
4
- * Fetch features from a GPF WFS endpoint.
5
- *
6
- * @param {string[]} typeNames - fully qualified WFS type names
7
- * @param {string} cqlFilter - CQL_FILTER value
8
- * @param {string} errorLabel - service label used in the error message
9
- * @param {(url: string) => Promise<any>} [fetcher]
10
- * @returns {Promise<any[]>} raw GeoJSON features array
11
- */
12
- export async function fetchWfsFeatures(typeNames, cqlFilter, errorLabel, fetcher = fetchJSON) {
13
- const url = GPF_WFS_BASE_URL + '?' + new URLSearchParams({
14
- service: 'WFS',
15
- request: 'GetFeature',
16
- typeName: typeNames.join(','),
17
- outputFormat: 'application/json',
18
- cql_filter: cqlFilter,
19
- }).toString();
20
- const featureCollection = await fetcher(url);
21
- if (!Array.isArray(featureCollection?.features)) {
22
- throw new Error(`Le service ${errorLabel} n'a pas retourné de collection d'objets exploitable`);
23
- }
24
- return featureCollection.features;
25
- }
26
- /**
27
- * Builds a GeoJSON Point from longitude and latitude.
28
- *
29
- * @param {number} lon
30
- * @param {number} lat
31
- * @returns {object} GeoJSON Point
32
- */
33
- export function toGeoJsonPoint(lon, lat) {
34
- return { type: "Point", coordinates: [lon, lat] };
35
- }
36
- /**
37
- * Maps a raw WFS feature into a flat result object, stripping geometry
38
- * and resolving a reusable feature_ref from the known type names.
39
- *
40
- * @param {object} feature - Raw GeoJSON feature from WFS
41
- * @param {string[]} knownTypeNames - Fully qualified WFS type names used for feature_ref resolution
42
- * @returns {object} Flat result with type, id, bbox, optional feature_ref, and spread properties
43
- */
44
- export function mapWfsFeature(feature, knownTypeNames) {
45
- const type = feature.id.split('.')[0];
46
- const typename = knownTypeNames.find((t) => t.endsWith(`:${type}`));
47
- return {
48
- ...feature.properties,
49
- type,
50
- id: feature.id,
51
- bbox: feature.bbox,
52
- ...(typename ? { feature_ref: { typename, feature_id: feature.id } } : {}),
53
- };
54
- }
55
- //# sourceMappingURL=wfs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"wfs.js","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CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC;IACpE,OAAO;QACH,GAAG,OAAO,CAAC,UAAU;QACrB,IAAI;QACJ,EAAE,EAAE,OAAO,CAAC,EAAE;QACd,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC7E,CAAC;AACN,CAAC"}
@@ -1,46 +0,0 @@
1
- import type { Collection, CollectionProperty } from "@ignfab/gpf-schema-store";
2
- import type { GpfWfsGetFeaturesInput, SpatialFilter } from "./schema.js";
3
- export type ResolvedFeatureGeometryRef = {
4
- typename: string;
5
- feature_id: string;
6
- geometry_ewkt: string;
7
- };
8
- export type CompiledQuery = {
9
- geometryProperty: CollectionProperty;
10
- cqlFilter?: string;
11
- propertyName?: string;
12
- sortBy?: string;
13
- };
14
- /**
15
- * Resolves the single geometry property expected by the query compiler.
16
- *
17
- * @param featureType Feature type definition loaded from the embedded catalog.
18
- * @returns The unique geometry property for the feature type.
19
- */
20
- export declare function getGeometryProperty(featureType: Collection): CollectionProperty;
21
- /**
22
- * Serializes a GeoJSON-like geometry object into EWKT for CQL spatial predicates.
23
- *
24
- * @param geometry Geometry object exposing a GeoJSON `type` and `coordinates`.
25
- * @returns The EWKT representation of the geometry.
26
- */
27
- export declare function geometryToEwkt(geometry: {
28
- type: string;
29
- coordinates: unknown;
30
- }): string;
31
- /**
32
- * Normalizes the raw spatial input into a discriminated spatial filter object.
33
- *
34
- * @param input Normalized tool input.
35
- * @returns A normalized spatial filter, or `undefined` when no spatial filter is requested.
36
- */
37
- export declare function getSpatialFilter(input: GpfWfsGetFeaturesInput): SpatialFilter | undefined;
38
- /**
39
- * Compiles normalized tool input into query fragments ready to be turned into a WFS request.
40
- *
41
- * @param input Normalized tool input.
42
- * @param featureType Feature type definition loaded from the embedded catalog.
43
- * @param resolvedGeometryRef Optional resolved reference geometry for `intersects_feature`.
44
- * @returns Compiled query parts used by request builders.
45
- */
46
- export declare function compileQueryParts(input: GpfWfsGetFeaturesInput, featureType: Collection, resolvedGeometryRef?: ResolvedFeatureGeometryRef): CompiledQuery;