@ignfab/geocontext 0.9.3 → 0.9.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -28
- package/dist/gpf/adminexpress.js +7 -27
- package/dist/gpf/adminexpress.js.map +1 -1
- package/dist/gpf/parcellaire-express.js +13 -33
- package/dist/gpf/parcellaire-express.js.map +1 -1
- package/dist/gpf/urbanisme.d.ts +4 -2
- package/dist/gpf/urbanisme.js +20 -61
- package/dist/gpf/urbanisme.js.map +1 -1
- package/dist/gpf/wfs.d.ts +2 -2
- package/dist/gpf/wfs.js +17 -71
- package/dist/gpf/wfs.js.map +1 -1
- package/dist/helpers/distance.d.ts +4 -2
- package/dist/helpers/distance.js +20 -5
- package/dist/helpers/distance.js.map +1 -1
- package/dist/helpers/http.d.ts +4 -0
- package/dist/helpers/http.js +103 -1
- package/dist/helpers/http.js.map +1 -1
- package/dist/helpers/jsonSchema.d.ts +3 -0
- package/dist/helpers/jsonSchema.js +8 -0
- package/dist/helpers/jsonSchema.js.map +1 -0
- package/dist/helpers/schemas.d.ts +13 -0
- package/dist/helpers/schemas.js +18 -0
- package/dist/helpers/schemas.js.map +1 -0
- package/dist/helpers/wfs.d.ts +27 -0
- package/dist/helpers/wfs.js +55 -0
- package/dist/helpers/wfs.js.map +1 -0
- package/dist/helpers/wfs_internal/compile.d.ts +46 -0
- package/dist/helpers/wfs_internal/compile.js +595 -0
- package/dist/helpers/wfs_internal/compile.js.map +1 -0
- package/dist/helpers/wfs_internal/request.d.ts +38 -0
- package/dist/helpers/wfs_internal/request.js +92 -0
- package/dist/helpers/wfs_internal/request.js.map +1 -0
- package/dist/helpers/wfs_internal/response.d.ts +21 -0
- package/dist/helpers/wfs_internal/response.js +29 -0
- package/dist/helpers/wfs_internal/response.js.map +1 -0
- package/dist/helpers/wfs_internal/schema.d.ts +167 -0
- package/dist/helpers/wfs_internal/schema.js +81 -0
- package/dist/helpers/wfs_internal/schema.js.map +1 -0
- package/dist/index.js +47 -25
- package/dist/index.js.map +1 -1
- package/dist/tools/AdminexpressTool.d.ts +52 -2
- package/dist/tools/AdminexpressTool.js +11 -14
- package/dist/tools/AdminexpressTool.js.map +1 -1
- package/dist/tools/AltitudeTool.d.ts +2 -2
- package/dist/tools/AltitudeTool.js +4 -13
- package/dist/tools/AltitudeTool.js.map +1 -1
- package/dist/tools/AssietteSupTool.d.ts +55 -3
- package/dist/tools/AssietteSupTool.js +12 -15
- package/dist/tools/AssietteSupTool.js.map +1 -1
- package/dist/tools/CadastreTool.d.ts +52 -2
- package/dist/tools/CadastreTool.js +13 -15
- package/dist/tools/CadastreTool.js.map +1 -1
- package/dist/tools/GeocodeTool.d.ts +2 -2
- package/dist/tools/GeocodeTool.js +6 -4
- package/dist/tools/GeocodeTool.js.map +1 -1
- package/dist/tools/GpfWfsDescribeTypeTool.d.ts +16 -16
- package/dist/tools/GpfWfsDescribeTypeTool.js +4 -3
- package/dist/tools/GpfWfsDescribeTypeTool.js.map +1 -1
- package/dist/tools/GpfWfsGetFeaturesTool.d.ts +170 -44
- package/dist/tools/GpfWfsGetFeaturesTool.js +161 -114
- package/dist/tools/GpfWfsGetFeaturesTool.js.map +1 -1
- package/dist/tools/GpfWfsSearchTypesTool.d.ts +8 -2
- package/dist/tools/GpfWfsSearchTypesTool.js +12 -9
- package/dist/tools/GpfWfsSearchTypesTool.js.map +1 -1
- package/dist/tools/UrbanismeTool.d.ts +53 -3
- package/dist/tools/UrbanismeTool.js +9 -15
- package/dist/tools/UrbanismeTool.js.map +1 -1
- package/package.json +8 -7
- package/dist/resources/WfsCqlFilterResource.d.ts +0 -10
- package/dist/resources/WfsCqlFilterResource.js +0 -23
- package/dist/resources/WfsCqlFilterResource.js.map +0 -1
- package/dist/resources/content/wfs-cql-filter.md +0 -215
- package/dist/tools/GpfWfsListTypesTool.d.ts +0 -22
- package/dist/tools/GpfWfsListTypesTool.js +0 -26
- package/dist/tools/GpfWfsListTypesTool.js.map +0 -1
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { GPF_WFS_URL } from "../../gpf/wfs.js";
|
|
2
|
+
import { REQUEST_GET_URL_MAX_LENGTH } from "./schema.js";
|
|
3
|
+
/**
|
|
4
|
+
* Encodes the optional CQL filter as an `application/x-www-form-urlencoded` POST body.
|
|
5
|
+
*
|
|
6
|
+
* @param cqlFilter Compiled CQL filter, when the request needs one.
|
|
7
|
+
* @returns The encoded POST body, or an empty string when no filter is present.
|
|
8
|
+
*/
|
|
9
|
+
function buildBody(cqlFilter) {
|
|
10
|
+
if (!cqlFilter) {
|
|
11
|
+
return "";
|
|
12
|
+
}
|
|
13
|
+
return new URLSearchParams({ cql_filter: cqlFilter }).toString();
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Builds a portable GET URL variant of the request when it stays below the configured limit.
|
|
17
|
+
*
|
|
18
|
+
* @param url Base WFS endpoint URL.
|
|
19
|
+
* @param query Query-string parameters sent with the request.
|
|
20
|
+
* @param cqlFilter Optional CQL filter to append to the GET variant.
|
|
21
|
+
* @returns A derived GET URL, or `null` when it would be too long to expose safely.
|
|
22
|
+
*/
|
|
23
|
+
export function buildGetUrl(url, query, cqlFilter) {
|
|
24
|
+
const params = new URLSearchParams(query);
|
|
25
|
+
if (cqlFilter) {
|
|
26
|
+
params.set("cql_filter", cqlFilter);
|
|
27
|
+
}
|
|
28
|
+
const getUrl = `${url}?${params.toString()}`;
|
|
29
|
+
if (getUrl.length > REQUEST_GET_URL_MAX_LENGTH) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
return getUrl;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Builds the main WFS GetFeature request from normalized tool input and compiled query parts.
|
|
36
|
+
*
|
|
37
|
+
* @param input Normalized tool input.
|
|
38
|
+
* @param compiled Compiled query fragments produced from the input and feature type.
|
|
39
|
+
* @returns A POST request split into base URL, query-string parameters, encoded body, and optional GET variant.
|
|
40
|
+
*/
|
|
41
|
+
export function buildMainRequest(input, compiled) {
|
|
42
|
+
const query = {
|
|
43
|
+
service: "WFS",
|
|
44
|
+
version: "2.0.0",
|
|
45
|
+
request: "GetFeature",
|
|
46
|
+
typeNames: input.typename,
|
|
47
|
+
outputFormat: "application/json",
|
|
48
|
+
count: input.result_type === "hits" ? "1" : String(input.limit),
|
|
49
|
+
};
|
|
50
|
+
if (compiled.propertyName && input.result_type !== "hits") {
|
|
51
|
+
query.propertyName = compiled.propertyName;
|
|
52
|
+
}
|
|
53
|
+
if (compiled.sortBy) {
|
|
54
|
+
query.sortBy = compiled.sortBy;
|
|
55
|
+
}
|
|
56
|
+
const body = buildBody(compiled.cqlFilter);
|
|
57
|
+
return {
|
|
58
|
+
method: "POST",
|
|
59
|
+
url: GPF_WFS_URL,
|
|
60
|
+
query,
|
|
61
|
+
body,
|
|
62
|
+
get_url: buildGetUrl(GPF_WFS_URL, query, compiled.cqlFilter),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Builds the auxiliary request used to fetch the geometry of a reference feature.
|
|
67
|
+
*
|
|
68
|
+
* @param typename Typename of the reference layer.
|
|
69
|
+
* @param featureId Identifier of the reference feature.
|
|
70
|
+
* @param geometryPropertyName Geometry property to request from the reference layer.
|
|
71
|
+
* @returns A POST request targeting the reference feature lookup.
|
|
72
|
+
*/
|
|
73
|
+
export function buildReferenceGeometryRequest(typename, featureId, geometryPropertyName) {
|
|
74
|
+
const query = {
|
|
75
|
+
service: "WFS",
|
|
76
|
+
version: "2.0.0",
|
|
77
|
+
request: "GetFeature",
|
|
78
|
+
typeNames: typename,
|
|
79
|
+
outputFormat: "application/json",
|
|
80
|
+
featureID: featureId,
|
|
81
|
+
propertyName: geometryPropertyName,
|
|
82
|
+
count: "1",
|
|
83
|
+
};
|
|
84
|
+
return {
|
|
85
|
+
method: "POST",
|
|
86
|
+
url: GPF_WFS_URL,
|
|
87
|
+
query,
|
|
88
|
+
body: "",
|
|
89
|
+
get_url: buildGetUrl(GPF_WFS_URL, query),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../../src/helpers/wfs_internal/request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAUzD;;;;;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;;;;;;;GAOG;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,EAAE,CAAC;QAC/C,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAC9B,KAA6B,EAC7B,QAAwE;IAExE,MAAM,KAAK,GAA2B;QACpC,OAAO,EAAE,KAAK;QACd,OAAO,EAAE,OAAO;QAChB,OAAO,EAAE,YAAY;QACrB,SAAS,EAAE,KAAK,CAAC,QAAQ;QACzB,YAAY,EAAE,kBAAkB;QAChC,KAAK,EAAE,KAAK,CAAC,WAA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|
+
[key: string]: unknown;
|
|
6
|
+
};
|
|
7
|
+
type GenericFeatureCollection = {
|
|
8
|
+
features?: GenericFeature[];
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Removes raw geometry payloads from a FeatureCollection, keeps GeoJSON validity by forcing
|
|
13
|
+
* `geometry: null`, and exposes lightweight `feature_ref` objects reusable by follow-up requests.
|
|
14
|
+
*
|
|
15
|
+
* @param featureCollection Raw FeatureCollection returned by the WFS endpoint.
|
|
16
|
+
* @returns A transformed FeatureCollection with raw geometry fields removed, `geometry: null`, and optional `feature_ref` metadata.
|
|
17
|
+
*/
|
|
18
|
+
export declare function transformFeatureCollectionResponse(featureCollection: GenericFeatureCollection): GenericFeatureCollection | {
|
|
19
|
+
features: Record<string, unknown>[];
|
|
20
|
+
};
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Removes raw geometry payloads from a FeatureCollection, keeps GeoJSON validity by forcing
|
|
3
|
+
* `geometry: null`, and exposes lightweight `feature_ref` objects reusable by follow-up requests.
|
|
4
|
+
*
|
|
5
|
+
* @param featureCollection Raw FeatureCollection returned by the WFS endpoint.
|
|
6
|
+
* @returns A transformed FeatureCollection with raw geometry fields removed, `geometry: null`, and optional `feature_ref` metadata.
|
|
7
|
+
*/
|
|
8
|
+
export function transformFeatureCollectionResponse(featureCollection) {
|
|
9
|
+
if (!Array.isArray(featureCollection.features)) {
|
|
10
|
+
return featureCollection;
|
|
11
|
+
}
|
|
12
|
+
const transformedFeatures = featureCollection.features.map((feature) => {
|
|
13
|
+
const { geometry: _geometry, geometry_name: _geometryName, ...rest } = feature;
|
|
14
|
+
const nextFeature = {
|
|
15
|
+
...rest,
|
|
16
|
+
geometry: null,
|
|
17
|
+
};
|
|
18
|
+
if (typeof feature.id === "string") {
|
|
19
|
+
nextFeature.feature_ref = {
|
|
20
|
+
typename: null,
|
|
21
|
+
feature_id: feature.id,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
return nextFeature;
|
|
25
|
+
});
|
|
26
|
+
const { crs: _crs, ...restCollection } = featureCollection;
|
|
27
|
+
return { ...restCollection, features: transformedFeatures };
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=response.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response.js","sourceRoot":"","sources":["../../../src/helpers/wfs_internal/response.ts"],"names":[],"mappings":"AAYA;;;;;;GAMG;AACH,MAAM,UAAU,kCAAkC,CAAC,iBAA2C;IAC5F,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,iBAAiB,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC/C,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAED,MAAM,mBAAmB,GAAG,iBAAiB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;QACrE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,aAAa,EAAE,aAAa,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;QAE/E,MAAM,WAAW,GAA4B;YAC3C,GAAG,IAAI;YACP,QAAQ,EAAE,IAAI;SACf,CAAC;QAEF,IAAI,OAAO,OAAO,CAAC,EAAE,KAAK,QAAQ,EAAE,CAAC;YACnC,WAAW,CAAC,WAAW,GAAG;gBACxB,QAAQ,EAAE,IAAI;gBACd,UAAU,EAAE,OAAO,CAAC,EAAE;aACvB,CAAC;QACJ,CAAC;QAED,OAAO,WAAW,CAAC;IACrB,CAAC,CAAC,CAAC;IAEH,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,cAAc,EAAE,GAAG,iBAAiB,CAAC;IAC3D,OAAO,EAAE,GAAG,cAAc,EAAE,QAAQ,EAAE,mBAAmB,EAAE,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const DEFAULT_LIMIT = 100;
|
|
3
|
+
export declare const MAX_LIMIT = 5000;
|
|
4
|
+
export declare const REQUEST_GET_URL_MAX_LENGTH = 6000;
|
|
5
|
+
export declare const WHERE_OPERATORS: readonly ["eq", "ne", "lt", "lte", "gt", "gte", "in", "is_null"];
|
|
6
|
+
export declare const SPATIAL_OPERATORS: readonly ["bbox", "intersects_point", "dwithin_point", "intersects_feature"];
|
|
7
|
+
export declare const ORDER_DIRECTIONS: readonly ["asc", "desc"];
|
|
8
|
+
export declare const gpfWfsGetFeaturesInputSchema: z.ZodObject<{
|
|
9
|
+
typename: z.ZodString;
|
|
10
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
11
|
+
result_type: z.ZodDefault<z.ZodEnum<["results", "hits", "request"]>>;
|
|
12
|
+
select: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
13
|
+
order_by: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
14
|
+
property: z.ZodString;
|
|
15
|
+
direction: z.ZodDefault<z.ZodEnum<["asc", "desc"]>>;
|
|
16
|
+
}, "strict", z.ZodTypeAny, {
|
|
17
|
+
property?: string;
|
|
18
|
+
direction?: "asc" | "desc";
|
|
19
|
+
}, {
|
|
20
|
+
property?: string;
|
|
21
|
+
direction?: "asc" | "desc";
|
|
22
|
+
}>, "many">>;
|
|
23
|
+
where: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
24
|
+
property: z.ZodString;
|
|
25
|
+
operator: z.ZodEnum<["eq", "ne", "lt", "lte", "gt", "gte", "in", "is_null"]>;
|
|
26
|
+
value: z.ZodOptional<z.ZodString>;
|
|
27
|
+
values: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
28
|
+
}, "strict", z.ZodTypeAny, {
|
|
29
|
+
values?: string[];
|
|
30
|
+
value?: string;
|
|
31
|
+
property?: string;
|
|
32
|
+
operator?: "gte" | "gt" | "lte" | "lt" | "eq" | "ne" | "in" | "is_null";
|
|
33
|
+
}, {
|
|
34
|
+
values?: string[];
|
|
35
|
+
value?: string;
|
|
36
|
+
property?: string;
|
|
37
|
+
operator?: "gte" | "gt" | "lte" | "lt" | "eq" | "ne" | "in" | "is_null";
|
|
38
|
+
}>, "many">>;
|
|
39
|
+
spatial_operator: z.ZodOptional<z.ZodEnum<["bbox", "intersects_point", "dwithin_point", "intersects_feature"]>>;
|
|
40
|
+
bbox_west: z.ZodOptional<z.ZodNumber>;
|
|
41
|
+
bbox_south: z.ZodOptional<z.ZodNumber>;
|
|
42
|
+
bbox_east: z.ZodOptional<z.ZodNumber>;
|
|
43
|
+
bbox_north: z.ZodOptional<z.ZodNumber>;
|
|
44
|
+
intersects_lon: z.ZodOptional<z.ZodNumber>;
|
|
45
|
+
intersects_lat: z.ZodOptional<z.ZodNumber>;
|
|
46
|
+
dwithin_lon: z.ZodOptional<z.ZodNumber>;
|
|
47
|
+
dwithin_lat: z.ZodOptional<z.ZodNumber>;
|
|
48
|
+
dwithin_distance_m: z.ZodOptional<z.ZodNumber>;
|
|
49
|
+
intersects_feature_typename: z.ZodOptional<z.ZodString>;
|
|
50
|
+
intersects_feature_id: z.ZodOptional<z.ZodString>;
|
|
51
|
+
}, "strict", z.ZodTypeAny, {
|
|
52
|
+
typename?: string;
|
|
53
|
+
limit?: number;
|
|
54
|
+
result_type?: "request" | "results" | "hits";
|
|
55
|
+
select?: string[];
|
|
56
|
+
order_by?: {
|
|
57
|
+
property?: string;
|
|
58
|
+
direction?: "asc" | "desc";
|
|
59
|
+
}[];
|
|
60
|
+
where?: {
|
|
61
|
+
values?: string[];
|
|
62
|
+
value?: string;
|
|
63
|
+
property?: string;
|
|
64
|
+
operator?: "gte" | "gt" | "lte" | "lt" | "eq" | "ne" | "in" | "is_null";
|
|
65
|
+
}[];
|
|
66
|
+
spatial_operator?: "bbox" | "intersects_point" | "dwithin_point" | "intersects_feature";
|
|
67
|
+
bbox_west?: number;
|
|
68
|
+
bbox_south?: number;
|
|
69
|
+
bbox_east?: number;
|
|
70
|
+
bbox_north?: number;
|
|
71
|
+
intersects_lon?: number;
|
|
72
|
+
intersects_lat?: number;
|
|
73
|
+
dwithin_lon?: number;
|
|
74
|
+
dwithin_lat?: number;
|
|
75
|
+
dwithin_distance_m?: number;
|
|
76
|
+
intersects_feature_typename?: string;
|
|
77
|
+
intersects_feature_id?: string;
|
|
78
|
+
}, {
|
|
79
|
+
typename?: string;
|
|
80
|
+
limit?: number;
|
|
81
|
+
result_type?: "request" | "results" | "hits";
|
|
82
|
+
select?: string[];
|
|
83
|
+
order_by?: {
|
|
84
|
+
property?: string;
|
|
85
|
+
direction?: "asc" | "desc";
|
|
86
|
+
}[];
|
|
87
|
+
where?: {
|
|
88
|
+
values?: string[];
|
|
89
|
+
value?: string;
|
|
90
|
+
property?: string;
|
|
91
|
+
operator?: "gte" | "gt" | "lte" | "lt" | "eq" | "ne" | "in" | "is_null";
|
|
92
|
+
}[];
|
|
93
|
+
spatial_operator?: "bbox" | "intersects_point" | "dwithin_point" | "intersects_feature";
|
|
94
|
+
bbox_west?: number;
|
|
95
|
+
bbox_south?: number;
|
|
96
|
+
bbox_east?: number;
|
|
97
|
+
bbox_north?: number;
|
|
98
|
+
intersects_lon?: number;
|
|
99
|
+
intersects_lat?: number;
|
|
100
|
+
dwithin_lon?: number;
|
|
101
|
+
dwithin_lat?: number;
|
|
102
|
+
dwithin_distance_m?: number;
|
|
103
|
+
intersects_feature_typename?: string;
|
|
104
|
+
intersects_feature_id?: string;
|
|
105
|
+
}>;
|
|
106
|
+
export type GpfWfsGetFeaturesInput = z.infer<typeof gpfWfsGetFeaturesInputSchema>;
|
|
107
|
+
export type WhereClause = NonNullable<GpfWfsGetFeaturesInput["where"]>[number];
|
|
108
|
+
export type OrderByClause = NonNullable<GpfWfsGetFeaturesInput["order_by"]>[number];
|
|
109
|
+
export type SpatialFilter = {
|
|
110
|
+
operator: "bbox";
|
|
111
|
+
west: number;
|
|
112
|
+
south: number;
|
|
113
|
+
east: number;
|
|
114
|
+
north: number;
|
|
115
|
+
} | {
|
|
116
|
+
operator: "intersects_point";
|
|
117
|
+
lon: number;
|
|
118
|
+
lat: number;
|
|
119
|
+
} | {
|
|
120
|
+
operator: "dwithin_point";
|
|
121
|
+
lon: number;
|
|
122
|
+
lat: number;
|
|
123
|
+
distance_m: number;
|
|
124
|
+
} | {
|
|
125
|
+
operator: "intersects_feature";
|
|
126
|
+
typename: string;
|
|
127
|
+
feature_id: string;
|
|
128
|
+
};
|
|
129
|
+
export declare const gpfWfsGetFeaturesHitsOutputSchema: z.ZodObject<{
|
|
130
|
+
result_type: z.ZodLiteral<"hits">;
|
|
131
|
+
totalFeatures: z.ZodNumber;
|
|
132
|
+
}, "strip", z.ZodTypeAny, {
|
|
133
|
+
result_type?: "hits";
|
|
134
|
+
totalFeatures?: number;
|
|
135
|
+
}, {
|
|
136
|
+
result_type?: "hits";
|
|
137
|
+
totalFeatures?: number;
|
|
138
|
+
}>;
|
|
139
|
+
export declare const gpfWfsGetFeaturesRequestOutputSchema: z.ZodObject<{
|
|
140
|
+
result_type: z.ZodLiteral<"request">;
|
|
141
|
+
method: z.ZodLiteral<"POST">;
|
|
142
|
+
url: z.ZodString;
|
|
143
|
+
query: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
144
|
+
body: z.ZodString;
|
|
145
|
+
get_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
146
|
+
}, "strip", z.ZodTypeAny, {
|
|
147
|
+
body?: string;
|
|
148
|
+
result_type?: "request";
|
|
149
|
+
method?: "POST";
|
|
150
|
+
url?: string;
|
|
151
|
+
query?: Record<string, string>;
|
|
152
|
+
get_url?: string;
|
|
153
|
+
}, {
|
|
154
|
+
body?: string;
|
|
155
|
+
result_type?: "request";
|
|
156
|
+
method?: "POST";
|
|
157
|
+
url?: string;
|
|
158
|
+
query?: Record<string, string>;
|
|
159
|
+
get_url?: string;
|
|
160
|
+
}>;
|
|
161
|
+
type PublishedInputSchema = {
|
|
162
|
+
type: "object";
|
|
163
|
+
properties?: Record<string, object>;
|
|
164
|
+
required?: string[];
|
|
165
|
+
};
|
|
166
|
+
export declare const gpfWfsGetFeaturesPublishedInputSchema: PublishedInputSchema;
|
|
167
|
+
export {};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { generatePublishedInputSchema } from "../../helpers/jsonSchema.js";
|
|
3
|
+
import { lonSchema, latSchema } from "../../helpers/schemas.js";
|
|
4
|
+
export const DEFAULT_LIMIT = 100;
|
|
5
|
+
export const MAX_LIMIT = 5000;
|
|
6
|
+
export const REQUEST_GET_URL_MAX_LENGTH = 6000;
|
|
7
|
+
export const WHERE_OPERATORS = ["eq", "ne", "lt", "lte", "gt", "gte", "in", "is_null"];
|
|
8
|
+
export const SPATIAL_OPERATORS = ["bbox", "intersects_point", "dwithin_point", "intersects_feature"];
|
|
9
|
+
export const ORDER_DIRECTIONS = ["asc", "desc"];
|
|
10
|
+
const whereClauseSchema = z.object({
|
|
11
|
+
property: z.string().trim().min(1).describe("Nom exact d'une propriété non géométrique du type WFS. Utiliser `gpf_wfs_describe_type` pour connaître les noms exacts disponibles."),
|
|
12
|
+
operator: z.enum(WHERE_OPERATORS).describe("Opérateur de filtre : `eq`, `ne`, `lt`, `lte`, `gt`, `gte`, `in`, `is_null`."),
|
|
13
|
+
value: z.string().optional().describe("Valeur scalaire sérialisée en texte, utilisée avec tous les opérateurs sauf `in` et `is_null`."),
|
|
14
|
+
values: z.array(z.string()).min(1).optional().describe("Liste de valeurs sérialisées en texte, utilisée uniquement avec `operator = \"in\"`."),
|
|
15
|
+
}).strict().describe("Clause de filtre structurée. Exemple : `{ property: \"code_insee\", operator: \"eq\", value: \"75056\" }`.");
|
|
16
|
+
const orderBySchema = z.object({
|
|
17
|
+
property: z.string().trim().min(1).describe("Nom exact d'une propriété non géométrique à utiliser pour le tri. Utiliser `gpf_wfs_describe_type` pour connaître les noms exacts disponibles."),
|
|
18
|
+
direction: z.enum(ORDER_DIRECTIONS).default("asc").describe("Direction de tri : `asc` ou `desc`."),
|
|
19
|
+
}).strict().describe("Critère de tri structuré. Exemple : `{ property: \"population\", direction: \"desc\" }`.");
|
|
20
|
+
export const gpfWfsGetFeaturesInputSchema = z.object({
|
|
21
|
+
typename: z
|
|
22
|
+
.string()
|
|
23
|
+
.trim()
|
|
24
|
+
.min(1, "le nom du type ne doit pas être vide")
|
|
25
|
+
.describe("Nom exact du type WFS à interroger, par exemple `BDTOPO_V3:batiment`. Utiliser `gpf_wfs_search_types` pour trouver un `typename` valide."),
|
|
26
|
+
limit: z
|
|
27
|
+
.number()
|
|
28
|
+
.int()
|
|
29
|
+
.min(1)
|
|
30
|
+
.max(MAX_LIMIT)
|
|
31
|
+
.default(DEFAULT_LIMIT)
|
|
32
|
+
.describe(`Nombre maximum d'objets à renvoyer. Valeur par défaut : ${DEFAULT_LIMIT}. Maximum : ${MAX_LIMIT}.`),
|
|
33
|
+
result_type: z
|
|
34
|
+
.enum(["results", "hits", "request"])
|
|
35
|
+
.default("results")
|
|
36
|
+
.describe("`results` renvoie une FeatureCollection avec les propriétés attributaires uniquement — **les géométries ne sont pas incluses**, ce mode ne peut donc pas être utilisé directement pour cartographier. `hits` renvoie uniquement le nombre total d'objets correspondant à la requête. `request` renvoie l'URL WFS compilée (`get_url`) à destination de `create_map` via `geojson_url`, ou pour déboguer la requête générée. **La géométrie est automatiquement ajoutée aux propriétés du `select`** pour garantir l'affichage cartographique."),
|
|
37
|
+
select: z
|
|
38
|
+
.array(z.string().trim().min(1))
|
|
39
|
+
.min(1)
|
|
40
|
+
.optional()
|
|
41
|
+
.describe("Liste des propriétés non géométriques à renvoyer pour chaque objet. Utiliser `gpf_wfs_describe_type` pour connaître les noms exacts disponibles. Exemple : `[\"code_insee\", \"nom_officiel\"]`."),
|
|
42
|
+
order_by: z
|
|
43
|
+
.array(orderBySchema)
|
|
44
|
+
.min(1)
|
|
45
|
+
.optional()
|
|
46
|
+
.describe("Liste ordonnée des critères de tri."),
|
|
47
|
+
where: z
|
|
48
|
+
.array(whereClauseSchema)
|
|
49
|
+
.min(1)
|
|
50
|
+
.optional()
|
|
51
|
+
.describe("Clauses de filtre attributaire, combinées avec `AND`."),
|
|
52
|
+
spatial_operator: z
|
|
53
|
+
.enum(SPATIAL_OPERATORS)
|
|
54
|
+
.optional()
|
|
55
|
+
.describe("Type optionnel de filtre spatial."),
|
|
56
|
+
bbox_west: lonSchema.describe("Longitude ouest en WGS84 `lon/lat`, utilisée avec `spatial_operator = \"bbox\"`.").optional(),
|
|
57
|
+
bbox_south: latSchema.describe("Latitude sud en WGS84 `lon/lat`, utilisée avec `spatial_operator = \"bbox\"`.").optional(),
|
|
58
|
+
bbox_east: lonSchema.describe("Longitude est en WGS84 `lon/lat`, utilisée avec `spatial_operator = \"bbox\"`.").optional(),
|
|
59
|
+
bbox_north: latSchema.describe("Latitude nord en WGS84 `lon/lat`, utilisée avec `spatial_operator = \"bbox\"`.").optional(),
|
|
60
|
+
intersects_lon: lonSchema.describe("Longitude du point en WGS84 `lon/lat`, utilisée avec `spatial_operator = \"intersects_point\"`.").optional(),
|
|
61
|
+
intersects_lat: latSchema.describe("Latitude du point en WGS84 `lon/lat`, utilisée avec `spatial_operator = \"intersects_point\"`.").optional(),
|
|
62
|
+
dwithin_lon: lonSchema.describe("Longitude du point en WGS84 `lon/lat`, utilisée avec `spatial_operator = \"dwithin_point\"`.").optional(),
|
|
63
|
+
dwithin_lat: latSchema.describe("Latitude du point en WGS84 `lon/lat`, utilisée avec `spatial_operator = \"dwithin_point\"`.").optional(),
|
|
64
|
+
dwithin_distance_m: z.number().finite().positive().describe("Distance en mètres, utilisée avec `spatial_operator = \"dwithin_point\"`.").optional(),
|
|
65
|
+
intersects_feature_typename: z.string().trim().min(1).optional().describe("Type WFS du feature de référence, utilisé avec `spatial_operator = \"intersects_feature\"`."),
|
|
66
|
+
intersects_feature_id: z.string().trim().min(1).optional().describe("Identifiant du feature de référence, utilisé avec `spatial_operator = \"intersects_feature\"`."),
|
|
67
|
+
}).strict();
|
|
68
|
+
export const gpfWfsGetFeaturesHitsOutputSchema = z.object({
|
|
69
|
+
result_type: z.literal("hits").describe("Indique que la réponse contient uniquement un comptage."),
|
|
70
|
+
totalFeatures: z.number().describe("Le nombre total d'objets correspondant à la requête."),
|
|
71
|
+
});
|
|
72
|
+
export const gpfWfsGetFeaturesRequestOutputSchema = z.object({
|
|
73
|
+
result_type: z.literal("request").describe("Indique que la réponse contient la requête WFS compilée (équivalent enrichi géométrie pour `create_map` et le débogage)."),
|
|
74
|
+
method: z.literal("POST").describe("Méthode HTTP réellement utilisée pour exécuter la requête."),
|
|
75
|
+
url: z.string().describe("URL de base appelée pour la requête POST."),
|
|
76
|
+
query: z.record(z.string()).describe("Paramètres WFS envoyés dans la query string."),
|
|
77
|
+
body: z.string().describe("Corps de la requête POST, encodé en `application/x-www-form-urlencoded`."),
|
|
78
|
+
get_url: z.string().nullable().optional().describe("URL GET dérivée quand la requête reste raisonnablement portable en GET."),
|
|
79
|
+
});
|
|
80
|
+
export const gpfWfsGetFeaturesPublishedInputSchema = generatePublishedInputSchema(gpfWfsGetFeaturesInputSchema);
|
|
81
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/helpers/wfs_internal/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,4BAA4B,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAEhE,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,CAAC;AACjC,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,CAAC;AAC9B,MAAM,CAAC,MAAM,0BAA0B,GAAG,IAAI,CAAC;AAC/C,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KA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,MAAM,oCAAoC,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3D,WAAW,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,0HAA0H,CAAC;IACtK,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,4DAA4D,CAAC;IAChG,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,2CAA2C,CAAC;IACrE,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,8CAA8C,CAAC;IACpF,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,0EAA0E,CAAC;IACrG,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,yEAAyE,CAAC;CAC9H,CAAC,CAAC;AAQH,MAAM,CAAC,MAAM,qCAAqC,GAAG,4BAA4B,CAAC,4BAA4B,CAAyB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,46 +3,68 @@ import { MCPServer } from "mcp-framework";
|
|
|
3
3
|
import { dirname, join } from "path";
|
|
4
4
|
import { fileURLToPath } from "url";
|
|
5
5
|
import { readFileSync } from "fs";
|
|
6
|
-
// Get the directory of the current module (dist directory)
|
|
7
6
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
8
|
-
// Get version from package.json
|
|
9
|
-
const pkgMetadata = JSON.parse(readFileSync(join(__dirname, '../package.json'), 'utf-8'));
|
|
10
|
-
const VERSION = pkgMetadata.version;
|
|
11
|
-
/**
|
|
12
|
-
* Available transports
|
|
13
|
-
*/
|
|
14
7
|
const TRANSPORTS = {
|
|
15
|
-
|
|
16
|
-
type: "stdio"
|
|
8
|
+
stdio: {
|
|
9
|
+
type: "stdio",
|
|
17
10
|
},
|
|
18
|
-
|
|
11
|
+
http: {
|
|
19
12
|
type: "http-stream",
|
|
20
13
|
options: {
|
|
21
|
-
host: process.env.HTTP_HOST,
|
|
22
14
|
port: 3000,
|
|
23
15
|
cors: {
|
|
24
|
-
allowOrigin: "*"
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
16
|
+
allowOrigin: "*",
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
28
20
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
21
|
+
function isTransportType(value) {
|
|
22
|
+
return Object.prototype.hasOwnProperty.call(TRANSPORTS, value);
|
|
23
|
+
}
|
|
24
|
+
function getTransportType() {
|
|
25
|
+
const transportType = process.env.TRANSPORT_TYPE ?? "stdio";
|
|
26
|
+
if (!isTransportType(transportType)) {
|
|
27
|
+
throw new Error(`Invalid transport type: ${transportType}`);
|
|
28
|
+
}
|
|
29
|
+
return transportType;
|
|
30
|
+
}
|
|
31
|
+
function buildTransport(transportType) {
|
|
32
|
+
if (transportType !== "http") {
|
|
33
|
+
return TRANSPORTS[transportType];
|
|
34
34
|
}
|
|
35
|
-
|
|
35
|
+
const host = process.env.HTTP_HOST?.trim();
|
|
36
|
+
if (!host) {
|
|
37
|
+
return TRANSPORTS.http;
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
...TRANSPORTS.http,
|
|
41
|
+
options: {
|
|
42
|
+
...TRANSPORTS.http.options,
|
|
43
|
+
host,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function getVersion() {
|
|
48
|
+
const pkgMetadata = JSON.parse(readFileSync(join(__dirname, "../package.json"), "utf-8"));
|
|
49
|
+
if (!pkgMetadata?.version || typeof pkgMetadata.version !== "string") {
|
|
50
|
+
throw new Error("Missing or invalid version in package.json");
|
|
51
|
+
}
|
|
52
|
+
return pkgMetadata.version;
|
|
53
|
+
}
|
|
54
|
+
async function main() {
|
|
55
|
+
const transportType = getTransportType();
|
|
56
|
+
const transport = buildTransport(transportType);
|
|
57
|
+
const version = getVersion();
|
|
36
58
|
const mcpServer = new MCPServer({
|
|
37
|
-
name:
|
|
38
|
-
version
|
|
59
|
+
name: "geocontext",
|
|
60
|
+
version,
|
|
39
61
|
basePath: __dirname,
|
|
40
|
-
transport
|
|
62
|
+
transport,
|
|
41
63
|
});
|
|
42
64
|
await mcpServer.start();
|
|
43
65
|
}
|
|
44
66
|
main().catch((error) => {
|
|
45
|
-
console.error("Fatal error in main():", error);
|
|
67
|
+
console.error("Fatal error in main():", error instanceof Error ? error.stack : String(error));
|
|
46
68
|
process.exit(1);
|
|
47
69
|
});
|
|
48
70
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAElC,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAE1D,MAAM,UAAU,GAAG;IACjB,KAAK,EAAE;QACL,IAAI,EAAE,OAAO;KACd;IACD,IAAI,EAAE;QACJ,IAAI,EAAE,aAAa;QACnB,OAAO,EAAE;YACP,IAAI,EAAE,IAAI;YACV,IAAI,EAAE;gBACJ,WAAW,EAAE,GAAG;aACjB;SACF;KACF;CACO,CAAC;AAIX,SAAS,eAAe,CAAC,KAAa;IACpC,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AC,aAAa,CAAC,CAAC;IAChD,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAE7B,MAAM,SAAS,GAAG,IAAI,SAAS,CAAC;QAC9B,IAAI,EAAE,YAAY;QAClB,OAAO;QACP,QAAQ,EAAE,SAAS;QACnB,SAAS;KACV,CAAC,CAAC;IAEH,MAAM,SAAS,CAAC,KAAK,EAAE,CAAC;AAC1B,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CACX,wBAAwB,EACxB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CACrD,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -3,7 +3,7 @@ import { z } from "zod";
|
|
|
3
3
|
declare const adminexpressInputSchema: z.ZodObject<{
|
|
4
4
|
lon: z.ZodNumber;
|
|
5
5
|
lat: z.ZodNumber;
|
|
6
|
-
}, "
|
|
6
|
+
}, "strict", z.ZodTypeAny, {
|
|
7
7
|
lon?: number;
|
|
8
8
|
lat?: number;
|
|
9
9
|
}, {
|
|
@@ -26,32 +26,82 @@ declare class AdminexpressTool extends MCPTool<AdminexpressInput> {
|
|
|
26
26
|
type: z.ZodString;
|
|
27
27
|
id: z.ZodString;
|
|
28
28
|
bbox: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
|
|
29
|
+
feature_ref: z.ZodObject<{
|
|
30
|
+
typename: z.ZodString;
|
|
31
|
+
feature_id: z.ZodString;
|
|
32
|
+
}, "strip", z.ZodTypeAny, {
|
|
33
|
+
typename?: string;
|
|
34
|
+
feature_id?: string;
|
|
35
|
+
}, {
|
|
36
|
+
typename?: string;
|
|
37
|
+
feature_id?: string;
|
|
38
|
+
}>;
|
|
29
39
|
}, "strip", z.ZodUnknown, z.objectOutputType<{
|
|
30
40
|
type: z.ZodString;
|
|
31
41
|
id: z.ZodString;
|
|
32
42
|
bbox: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
|
|
43
|
+
feature_ref: z.ZodObject<{
|
|
44
|
+
typename: z.ZodString;
|
|
45
|
+
feature_id: z.ZodString;
|
|
46
|
+
}, "strip", z.ZodTypeAny, {
|
|
47
|
+
typename?: string;
|
|
48
|
+
feature_id?: string;
|
|
49
|
+
}, {
|
|
50
|
+
typename?: string;
|
|
51
|
+
feature_id?: string;
|
|
52
|
+
}>;
|
|
33
53
|
}, z.ZodUnknown, "strip">, z.objectInputType<{
|
|
34
54
|
type: z.ZodString;
|
|
35
55
|
id: z.ZodString;
|
|
36
56
|
bbox: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
|
|
57
|
+
feature_ref: z.ZodObject<{
|
|
58
|
+
typename: z.ZodString;
|
|
59
|
+
feature_id: z.ZodString;
|
|
60
|
+
}, "strip", z.ZodTypeAny, {
|
|
61
|
+
typename?: string;
|
|
62
|
+
feature_id?: string;
|
|
63
|
+
}, {
|
|
64
|
+
typename?: string;
|
|
65
|
+
feature_id?: string;
|
|
66
|
+
}>;
|
|
37
67
|
}, z.ZodUnknown, "strip">>, "many">;
|
|
38
68
|
}, "strip", z.ZodTypeAny, {
|
|
39
69
|
results?: z.objectOutputType<{
|
|
40
70
|
type: z.ZodString;
|
|
41
71
|
id: z.ZodString;
|
|
42
72
|
bbox: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
|
|
73
|
+
feature_ref: z.ZodObject<{
|
|
74
|
+
typename: z.ZodString;
|
|
75
|
+
feature_id: z.ZodString;
|
|
76
|
+
}, "strip", z.ZodTypeAny, {
|
|
77
|
+
typename?: string;
|
|
78
|
+
feature_id?: string;
|
|
79
|
+
}, {
|
|
80
|
+
typename?: string;
|
|
81
|
+
feature_id?: string;
|
|
82
|
+
}>;
|
|
43
83
|
}, z.ZodUnknown, "strip">[];
|
|
44
84
|
}, {
|
|
45
85
|
results?: z.objectInputType<{
|
|
46
86
|
type: z.ZodString;
|
|
47
87
|
id: z.ZodString;
|
|
48
88
|
bbox: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
|
|
89
|
+
feature_ref: z.ZodObject<{
|
|
90
|
+
typename: z.ZodString;
|
|
91
|
+
feature_id: z.ZodString;
|
|
92
|
+
}, "strip", z.ZodTypeAny, {
|
|
93
|
+
typename?: string;
|
|
94
|
+
feature_id?: string;
|
|
95
|
+
}, {
|
|
96
|
+
typename?: string;
|
|
97
|
+
feature_id?: string;
|
|
98
|
+
}>;
|
|
49
99
|
}, z.ZodUnknown, "strip">[];
|
|
50
100
|
}>;
|
|
51
101
|
schema: z.ZodObject<{
|
|
52
102
|
lon: z.ZodNumber;
|
|
53
103
|
lat: z.ZodNumber;
|
|
54
|
-
}, "
|
|
104
|
+
}, "strict", z.ZodTypeAny, {
|
|
55
105
|
lon?: number;
|
|
56
106
|
lat?: number;
|
|
57
107
|
}, {
|