zenit-sdk 0.0.1
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 +279 -0
- package/dist/chunk-RGS6AZWV.mjs +3057 -0
- package/dist/chunk-RGS6AZWV.mjs.map +1 -0
- package/dist/index-C_2fk0Fk.d.mts +690 -0
- package/dist/index-C_2fk0Fk.d.ts +690 -0
- package/dist/index.d.mts +105 -0
- package/dist/index.d.ts +105 -0
- package/dist/index.js +4165 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1095 -0
- package/dist/index.mjs.map +1 -0
- package/dist/react/index.d.mts +4 -0
- package/dist/react/index.d.ts +4 -0
- package/dist/react/index.js +3088 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/index.mjs +53 -0
- package/dist/react/index.mjs.map +1 -0
- package/package.json +65 -0
|
@@ -0,0 +1,690 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import L, { PathOptions } from 'leaflet';
|
|
3
|
+
import 'lucide-react';
|
|
4
|
+
|
|
5
|
+
interface ZenitSdkError {
|
|
6
|
+
success: false;
|
|
7
|
+
statusCode: number;
|
|
8
|
+
timestamp?: string;
|
|
9
|
+
path?: string;
|
|
10
|
+
method?: string;
|
|
11
|
+
error?: string;
|
|
12
|
+
message: string;
|
|
13
|
+
}
|
|
14
|
+
type TokenResolver = () => {
|
|
15
|
+
accessToken?: string;
|
|
16
|
+
sdkToken?: string;
|
|
17
|
+
};
|
|
18
|
+
type AuthorizationHeaderResolver = () => Record<string, string>;
|
|
19
|
+
interface HttpClientOptions {
|
|
20
|
+
baseUrl: string;
|
|
21
|
+
resolveTokens?: TokenResolver;
|
|
22
|
+
resolveAuthorizationHeader?: AuthorizationHeaderResolver;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Minimal fetch-based HTTP client for the Zenit SDK.
|
|
26
|
+
* Responsible for setting base URL, auth headers and error normalization.
|
|
27
|
+
*
|
|
28
|
+
* - El header `Authorization` se usa para JWT de usuario o JWT obtenido vía `/sdk-auth/exchange`.
|
|
29
|
+
* - El header `X-SDK-Token` se usa para enviar el token SDK crudo a endpoints como
|
|
30
|
+
* `/sdk-auth/validate` y `/sdk-auth/exchange`.
|
|
31
|
+
*/
|
|
32
|
+
declare class HttpClient {
|
|
33
|
+
private readonly baseUrl;
|
|
34
|
+
private readonly resolveTokens?;
|
|
35
|
+
private readonly resolveAuthorizationHeader;
|
|
36
|
+
constructor(options: HttpClientOptions);
|
|
37
|
+
get<T>(path: string, options?: RequestInit): Promise<T>;
|
|
38
|
+
post<T>(path: string, body?: unknown, options?: RequestInit): Promise<T>;
|
|
39
|
+
put<T>(path: string, body?: unknown, options?: RequestInit): Promise<T>;
|
|
40
|
+
patch<T>(path: string, body?: unknown, options?: RequestInit): Promise<T>;
|
|
41
|
+
delete<T>(path: string, options?: RequestInit): Promise<T>;
|
|
42
|
+
private request;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
type LoginRequest = {
|
|
46
|
+
email: string;
|
|
47
|
+
password: string;
|
|
48
|
+
};
|
|
49
|
+
type UserSummary = {
|
|
50
|
+
id: number | string;
|
|
51
|
+
email: string;
|
|
52
|
+
roles: string[];
|
|
53
|
+
employeeCode?: string;
|
|
54
|
+
};
|
|
55
|
+
type LoginResponse = {
|
|
56
|
+
accessToken: string;
|
|
57
|
+
refreshToken: string;
|
|
58
|
+
user: UserSummary;
|
|
59
|
+
};
|
|
60
|
+
type RefreshResponse = {
|
|
61
|
+
accessToken: string;
|
|
62
|
+
refreshToken: string;
|
|
63
|
+
};
|
|
64
|
+
type MeResponse = UserSummary;
|
|
65
|
+
type ValidateResponse = {
|
|
66
|
+
valid: boolean;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Client to manage user authentication endpoints.
|
|
71
|
+
*/
|
|
72
|
+
declare class ZenitAuthClient {
|
|
73
|
+
private readonly http;
|
|
74
|
+
private readonly updateTokens;
|
|
75
|
+
private readonly config;
|
|
76
|
+
constructor(http: HttpClient, updateTokens: (tokens: {
|
|
77
|
+
accessToken?: string;
|
|
78
|
+
refreshToken?: string;
|
|
79
|
+
}) => void, config: ZenitSdkConfig);
|
|
80
|
+
login(credentials: LoginRequest): Promise<LoginResponse>;
|
|
81
|
+
refresh(refreshToken?: string): Promise<RefreshResponse>;
|
|
82
|
+
me(): Promise<MeResponse>;
|
|
83
|
+
validate(): Promise<ValidateResponse>;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
type SdkTokenValidateResponse = {
|
|
87
|
+
valid: boolean;
|
|
88
|
+
clientId?: string | number;
|
|
89
|
+
clientName?: string;
|
|
90
|
+
scopes?: string[];
|
|
91
|
+
reason?: string;
|
|
92
|
+
};
|
|
93
|
+
type SdkTokenExchangeResponse = {
|
|
94
|
+
accessToken: string;
|
|
95
|
+
expiresIn: number;
|
|
96
|
+
tokenType: 'Bearer';
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Client to manage SDK token validation and exchange endpoints.
|
|
101
|
+
*/
|
|
102
|
+
declare class ZenitSdkAuthClient {
|
|
103
|
+
private readonly http;
|
|
104
|
+
private readonly updateAccessToken;
|
|
105
|
+
private readonly config;
|
|
106
|
+
constructor(http: HttpClient, updateAccessToken: (token?: string) => void, config: ZenitSdkConfig);
|
|
107
|
+
/**
|
|
108
|
+
* Validate an SDK token. If no token argument is provided, it falls back to config.sdkToken.
|
|
109
|
+
*/
|
|
110
|
+
validateSdkToken(token?: string): Promise<SdkTokenValidateResponse>;
|
|
111
|
+
/**
|
|
112
|
+
* Exchange an SDK token for an access token. Token can come from method args or config.sdkToken.
|
|
113
|
+
*/
|
|
114
|
+
exchangeSdkToken(token?: string): Promise<SdkTokenExchangeResponse>;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
interface LayerDto {
|
|
118
|
+
id: number | string;
|
|
119
|
+
name?: string;
|
|
120
|
+
description?: string;
|
|
121
|
+
totalFeatures?: number;
|
|
122
|
+
layerType?: string;
|
|
123
|
+
[key: string]: unknown;
|
|
124
|
+
}
|
|
125
|
+
type LayerSummary = Pick<LayerDto, 'id' | 'name'>;
|
|
126
|
+
interface GeoJsonPoint {
|
|
127
|
+
type: 'Point';
|
|
128
|
+
coordinates: [number, number];
|
|
129
|
+
[key: string]: unknown;
|
|
130
|
+
}
|
|
131
|
+
interface GeoJsonPolygon {
|
|
132
|
+
type: 'Polygon';
|
|
133
|
+
coordinates: number[][][];
|
|
134
|
+
[key: string]: unknown;
|
|
135
|
+
}
|
|
136
|
+
interface GeoJsonFeature<TProperties = Record<string, unknown>, TGeometry = unknown> {
|
|
137
|
+
type: 'Feature';
|
|
138
|
+
geometry: TGeometry;
|
|
139
|
+
properties?: TProperties;
|
|
140
|
+
[key: string]: unknown;
|
|
141
|
+
}
|
|
142
|
+
interface GeoJsonFeatureCollection<TProperties = Record<string, unknown>, TGeometry = GeoJsonPoint | GeoJsonPolygon | unknown> {
|
|
143
|
+
type: 'FeatureCollection';
|
|
144
|
+
features: Array<GeoJsonFeature<TProperties, TGeometry>>;
|
|
145
|
+
[key: string]: unknown;
|
|
146
|
+
}
|
|
147
|
+
interface GeoJsonGeometryCollection<TGeometry = unknown> {
|
|
148
|
+
type: 'GeometryCollection';
|
|
149
|
+
geometries: TGeometry[];
|
|
150
|
+
[key: string]: unknown;
|
|
151
|
+
}
|
|
152
|
+
interface Bbox {
|
|
153
|
+
minLon: number;
|
|
154
|
+
minLat: number;
|
|
155
|
+
maxLon: number;
|
|
156
|
+
maxLat: number;
|
|
157
|
+
}
|
|
158
|
+
type LayerDataStrategy = 'geojson' | 'bbox' | 'intersect';
|
|
159
|
+
interface ApiEnvelope<TData, TMetadata = Record<string, unknown>> {
|
|
160
|
+
success: boolean;
|
|
161
|
+
timestamp?: string;
|
|
162
|
+
path?: string;
|
|
163
|
+
method?: string;
|
|
164
|
+
data: TData;
|
|
165
|
+
message?: string;
|
|
166
|
+
metadata?: TMetadata;
|
|
167
|
+
limitedMessage?: string;
|
|
168
|
+
totalFeatures?: number;
|
|
169
|
+
}
|
|
170
|
+
type ApiResponseData<TData, TMetadata = Record<string, unknown>> = ApiEnvelope<TData, TMetadata>;
|
|
171
|
+
interface LayerMetadata {
|
|
172
|
+
totalFeatures?: number;
|
|
173
|
+
limit?: number;
|
|
174
|
+
limited?: boolean;
|
|
175
|
+
limitedMessage?: string;
|
|
176
|
+
[key: string]: unknown;
|
|
177
|
+
}
|
|
178
|
+
interface GeoJsonRequestOptions {
|
|
179
|
+
maxFeatures?: number;
|
|
180
|
+
simplify?: boolean;
|
|
181
|
+
}
|
|
182
|
+
interface GeoJsonBBoxRequest extends GeoJsonRequestOptions {
|
|
183
|
+
id: number | string;
|
|
184
|
+
bbox: Bbox;
|
|
185
|
+
}
|
|
186
|
+
interface GeoJsonIntersectRequest extends GeoJsonRequestOptions {
|
|
187
|
+
id: number | string;
|
|
188
|
+
geometry: unknown;
|
|
189
|
+
}
|
|
190
|
+
interface LayerAoi {
|
|
191
|
+
bbox?: Bbox;
|
|
192
|
+
geometry?: GeoJsonGeometryCollection;
|
|
193
|
+
}
|
|
194
|
+
interface ResolveLayerStrategyParams {
|
|
195
|
+
layerDetail: LayerDto;
|
|
196
|
+
bbox?: Bbox;
|
|
197
|
+
filterBBox?: Bbox;
|
|
198
|
+
filteredGeoJSON?: GeoJsonFeatureCollection | null;
|
|
199
|
+
isVisible?: boolean;
|
|
200
|
+
maxFeaturesFullGeojson?: number;
|
|
201
|
+
allowLargeGeojson?: boolean;
|
|
202
|
+
}
|
|
203
|
+
interface ResolveLayerStrategyResult {
|
|
204
|
+
strategy: LayerDataStrategy;
|
|
205
|
+
intersectionGeometry?: GeoJsonGeometryCollection | null;
|
|
206
|
+
effectiveBBox?: Bbox;
|
|
207
|
+
}
|
|
208
|
+
interface LoadLayerDataParams extends GeoJsonRequestOptions {
|
|
209
|
+
id: number | string;
|
|
210
|
+
layerDetail: LayerDto;
|
|
211
|
+
bbox?: Bbox;
|
|
212
|
+
filterBBox?: Bbox;
|
|
213
|
+
filteredGeoJSON?: GeoJsonFeatureCollection | null;
|
|
214
|
+
isVisible?: boolean;
|
|
215
|
+
maxFeaturesFullGeojson?: number;
|
|
216
|
+
allowLargeGeojson?: boolean;
|
|
217
|
+
}
|
|
218
|
+
interface LoadLayerDataResult<TMetadata = LayerMetadata> {
|
|
219
|
+
geojson: GeoJsonFeatureCollection;
|
|
220
|
+
strategy: LayerDataStrategy;
|
|
221
|
+
limitedMessage?: string;
|
|
222
|
+
totalFeatures?: number;
|
|
223
|
+
metadata?: TMetadata;
|
|
224
|
+
}
|
|
225
|
+
interface LayerFeatureCatalogItem {
|
|
226
|
+
id: string;
|
|
227
|
+
featureIndex: number;
|
|
228
|
+
properties: Record<string, string | number | boolean | null>;
|
|
229
|
+
bboxGeometry: GeoJsonPolygon;
|
|
230
|
+
centroid: GeoJsonPoint;
|
|
231
|
+
areaKm2: string;
|
|
232
|
+
geometryType: string;
|
|
233
|
+
}
|
|
234
|
+
interface LayerFeaturesCatalogDto {
|
|
235
|
+
layerId: number;
|
|
236
|
+
layerName: string;
|
|
237
|
+
layerType: string;
|
|
238
|
+
totalFeatures: number;
|
|
239
|
+
features: LayerFeatureCatalogItem[];
|
|
240
|
+
}
|
|
241
|
+
type FilterValue = string | number | boolean | Array<string | number | boolean>;
|
|
242
|
+
type LayerFilters = Record<string, FilterValue | null | undefined>;
|
|
243
|
+
interface FilterMultipleMetadata {
|
|
244
|
+
totalLayers?: number;
|
|
245
|
+
totalFeatures?: number;
|
|
246
|
+
appliedFilters?: Record<string, string | string[]>;
|
|
247
|
+
bbox?: unknown;
|
|
248
|
+
warnings?: string[];
|
|
249
|
+
layers?: Array<{
|
|
250
|
+
layerId: number;
|
|
251
|
+
layerName?: string;
|
|
252
|
+
featuresCount?: number;
|
|
253
|
+
}>;
|
|
254
|
+
[key: string]: unknown;
|
|
255
|
+
}
|
|
256
|
+
interface FilterMultipleLayerMeta {
|
|
257
|
+
layerId: number | string;
|
|
258
|
+
layerType?: string;
|
|
259
|
+
totalFeatures?: number;
|
|
260
|
+
label?: string;
|
|
261
|
+
prefilters?: LayerFilters;
|
|
262
|
+
}
|
|
263
|
+
interface FilterMultipleWithFallbackResult {
|
|
264
|
+
perLayer: Record<string, GeoJsonFeatureCollection>;
|
|
265
|
+
metadata?: FilterMultipleMetadata;
|
|
266
|
+
aoi?: LayerAoi | null;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
interface MapSettings {
|
|
270
|
+
center?: {
|
|
271
|
+
lat: number;
|
|
272
|
+
lon: number;
|
|
273
|
+
} | [number, number];
|
|
274
|
+
zoom?: number;
|
|
275
|
+
basemap?: string;
|
|
276
|
+
}
|
|
277
|
+
interface MapLayerConfig {
|
|
278
|
+
layerId?: number | string;
|
|
279
|
+
isVisible?: boolean;
|
|
280
|
+
order?: number | string;
|
|
281
|
+
displayOrder?: number | string;
|
|
282
|
+
opacity?: number | string;
|
|
283
|
+
layer?: LayerDto;
|
|
284
|
+
name?: string;
|
|
285
|
+
layerType?: string;
|
|
286
|
+
geometryType?: string;
|
|
287
|
+
/** Estilo de la capa, cuando viene embebido en el MapDto */
|
|
288
|
+
style?: {
|
|
289
|
+
color?: string;
|
|
290
|
+
weight?: number;
|
|
291
|
+
fillColor?: string;
|
|
292
|
+
fillOpacity?: number;
|
|
293
|
+
} | null;
|
|
294
|
+
layerConfig?: {
|
|
295
|
+
prefilters?: Record<string, unknown>;
|
|
296
|
+
[key: string]: unknown;
|
|
297
|
+
};
|
|
298
|
+
/** Filtros aplicados actualmente a esta capa (se setea después de operaciones de filtrado) */
|
|
299
|
+
appliedFilters?: Record<string, string | string[]>;
|
|
300
|
+
[key: string]: unknown;
|
|
301
|
+
}
|
|
302
|
+
interface NormalizedMapLayer {
|
|
303
|
+
layerId: number | string;
|
|
304
|
+
isVisible: boolean;
|
|
305
|
+
opacity: number;
|
|
306
|
+
displayOrder: number;
|
|
307
|
+
layer?: LayerDto;
|
|
308
|
+
layerType?: string;
|
|
309
|
+
geometryType?: string;
|
|
310
|
+
layerName?: string;
|
|
311
|
+
mapLayer: MapLayerConfig;
|
|
312
|
+
}
|
|
313
|
+
interface MapDto {
|
|
314
|
+
id: number | string;
|
|
315
|
+
mapType?: {
|
|
316
|
+
code?: string;
|
|
317
|
+
};
|
|
318
|
+
settings?: MapSettings;
|
|
319
|
+
mapLayers?: MapLayerConfig[];
|
|
320
|
+
layers?: LayerSummary[];
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
declare class ZenitMapsClient {
|
|
324
|
+
private readonly httpClient;
|
|
325
|
+
constructor(httpClient: HttpClient);
|
|
326
|
+
getMap(mapId: number | string, includeLayers?: boolean): Promise<MapDto>;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
declare function buildLayerFilters(filters?: LayerFilters): URLSearchParams;
|
|
330
|
+
declare function buildFilterMultipleParams(params: {
|
|
331
|
+
layerIds: Array<number | string>;
|
|
332
|
+
filters?: LayerFilters;
|
|
333
|
+
}): URLSearchParams;
|
|
334
|
+
declare const DEFAULT_MAX_FEATURES_FULL_GEOJSON = 50000;
|
|
335
|
+
declare function shouldUseFilterMultiple(layerType?: string): boolean;
|
|
336
|
+
declare function shouldSkipGeojsonDownload(layerType?: string, totalFeatures?: number, thresholds?: {
|
|
337
|
+
maxFeatures: number;
|
|
338
|
+
allowLargeGeojson?: boolean;
|
|
339
|
+
}): boolean;
|
|
340
|
+
declare function buildAoiFromFeatureCollection(featureCollection: GeoJsonFeatureCollection, metadata?: FilterMultipleMetadata): LayerAoi | null;
|
|
341
|
+
declare function resolveLayerStrategy(params: ResolveLayerStrategyParams): ResolveLayerStrategyResult;
|
|
342
|
+
declare function buildLimitedMessage(metadata?: LayerMetadata): string | undefined;
|
|
343
|
+
declare class ZenitLayersClient {
|
|
344
|
+
private readonly httpClient;
|
|
345
|
+
constructor(httpClient: HttpClient);
|
|
346
|
+
getLayer(layerId: number | string): Promise<ApiResponseData<LayerDto>>;
|
|
347
|
+
getLayerGeoJson(layerId: number | string, options?: GeoJsonRequestOptions): Promise<ApiResponseData<GeoJsonFeatureCollection>>;
|
|
348
|
+
getLayerFeaturesCatalog(layerId: number | string, options?: {
|
|
349
|
+
layerType?: string;
|
|
350
|
+
geometryType?: string;
|
|
351
|
+
strict?: boolean;
|
|
352
|
+
}): Promise<ApiResponseData<LayerFeaturesCatalogDto>>;
|
|
353
|
+
getLayerFeatures(layerId: number | string, featureIds: Array<number | string>): Promise<ApiResponseData<GeoJsonFeatureCollection>>;
|
|
354
|
+
filterLayerFeatures(layerId: number | string, filters: LayerFilters): Promise<ApiResponseData<GeoJsonFeatureCollection>>;
|
|
355
|
+
filterMultipleLayersFeatures(params: {
|
|
356
|
+
layerIds: Array<number | string>;
|
|
357
|
+
filters?: LayerFilters;
|
|
358
|
+
}): Promise<ApiResponseData<GeoJsonFeatureCollection, FilterMultipleMetadata>>;
|
|
359
|
+
filterMultiple(params: {
|
|
360
|
+
layerIds: Array<number | string>;
|
|
361
|
+
filters?: LayerFilters;
|
|
362
|
+
}): Promise<ApiResponseData<GeoJsonFeatureCollection, FilterMultipleMetadata>>;
|
|
363
|
+
/**
|
|
364
|
+
* Resilient filter-multiple helper:
|
|
365
|
+
* - Usa filter-multiple SOLO en capas multipolygon.
|
|
366
|
+
* - Para otras capas aplica filterLayerFeatures o getLayerGeoJson según haya filtros.
|
|
367
|
+
* - Nunca falla toda la operación por una capa inválida.
|
|
368
|
+
*
|
|
369
|
+
* Para mejor detección de layerType, pasa layerMetas con el layerType de cada capa.
|
|
370
|
+
*/
|
|
371
|
+
filterMultipleWithFallback(params: {
|
|
372
|
+
layerIds: Array<number | string>;
|
|
373
|
+
filters?: LayerFilters;
|
|
374
|
+
layerMetas?: FilterMultipleLayerMeta[];
|
|
375
|
+
maxFeaturesFullGeojson?: number;
|
|
376
|
+
allowLargeGeojson?: boolean;
|
|
377
|
+
}): Promise<FilterMultipleWithFallbackResult>;
|
|
378
|
+
getLayerGeoJsonBBox(request: GeoJsonBBoxRequest): Promise<ApiResponseData<GeoJsonFeatureCollection>>;
|
|
379
|
+
getLayerGeoJsonIntersect(request: GeoJsonIntersectRequest): Promise<ApiResponseData<GeoJsonFeatureCollection>>;
|
|
380
|
+
getLayerTileTemplate(layerId: number | string): Promise<string>;
|
|
381
|
+
loadLayerData(params: LoadLayerDataParams): Promise<LoadLayerDataResult>;
|
|
382
|
+
loadFilteredFeatures(params: {
|
|
383
|
+
layerIds: Array<number | string>;
|
|
384
|
+
filters: LayerFilters;
|
|
385
|
+
}): Promise<{
|
|
386
|
+
geojson: GeoJsonFeatureCollection;
|
|
387
|
+
metadata?: FilterMultipleMetadata;
|
|
388
|
+
totalFeatures?: number;
|
|
389
|
+
}>;
|
|
390
|
+
private fetchByStrategy;
|
|
391
|
+
private unwrapResponse;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
interface ZenitSdkConfig {
|
|
395
|
+
baseUrl: string;
|
|
396
|
+
sdkToken?: string;
|
|
397
|
+
accessToken?: string;
|
|
398
|
+
refreshToken?: string;
|
|
399
|
+
onAuthError?(error: ZenitSdkError): void;
|
|
400
|
+
onTokenRefreshed?(tokens: {
|
|
401
|
+
accessToken: string;
|
|
402
|
+
refreshToken?: string;
|
|
403
|
+
}): void;
|
|
404
|
+
}
|
|
405
|
+
declare class ZenitClient {
|
|
406
|
+
private readonly config;
|
|
407
|
+
private accessToken?;
|
|
408
|
+
private refreshToken?;
|
|
409
|
+
private sdkToken?;
|
|
410
|
+
private readonly httpClient;
|
|
411
|
+
readonly auth: ZenitAuthClient;
|
|
412
|
+
readonly sdkAuth: ZenitSdkAuthClient;
|
|
413
|
+
readonly maps: ZenitMapsClient;
|
|
414
|
+
readonly layers: ZenitLayersClient;
|
|
415
|
+
constructor(config: ZenitSdkConfig);
|
|
416
|
+
/**
|
|
417
|
+
* Update tokens in memory and propagate to config callbacks.
|
|
418
|
+
*/
|
|
419
|
+
private updateTokens;
|
|
420
|
+
private updateAccessTokenFromSdkExchange;
|
|
421
|
+
setAccessToken(token: string): void;
|
|
422
|
+
setRefreshToken(token: string): void;
|
|
423
|
+
getAuthorizationHeader(): Record<string, string>;
|
|
424
|
+
getHttpClient(): HttpClient;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
type LayerLike = Pick<MapLayerConfig | NormalizedMapLayer, 'layerId' | 'isVisible' | 'opacity'>;
|
|
428
|
+
interface LayerBaseState {
|
|
429
|
+
layerId: number | string;
|
|
430
|
+
baseVisible: boolean;
|
|
431
|
+
baseOpacity: number;
|
|
432
|
+
}
|
|
433
|
+
interface LayerOverrideState {
|
|
434
|
+
layerId: number | string;
|
|
435
|
+
overrideVisible?: boolean | null;
|
|
436
|
+
overrideOpacity?: number | string | null;
|
|
437
|
+
}
|
|
438
|
+
interface EffectiveLayerState extends LayerBaseState, LayerOverrideState {
|
|
439
|
+
visible: boolean;
|
|
440
|
+
opacity: number;
|
|
441
|
+
}
|
|
442
|
+
declare function initLayerStates(mapLayers: LayerLike[]): EffectiveLayerState[];
|
|
443
|
+
declare function applyLayerOverrides(states: EffectiveLayerState[], overrides: LayerOverrideState[]): EffectiveLayerState[];
|
|
444
|
+
declare function resetOverrides(states: EffectiveLayerState[]): EffectiveLayerState[];
|
|
445
|
+
|
|
446
|
+
interface ChatRequestDto {
|
|
447
|
+
message: string;
|
|
448
|
+
conversationId?: number;
|
|
449
|
+
filteredLayerIds?: number[];
|
|
450
|
+
filters?: Record<string, unknown>;
|
|
451
|
+
userId?: number | null;
|
|
452
|
+
}
|
|
453
|
+
interface SuggestedAction {
|
|
454
|
+
id?: string | number;
|
|
455
|
+
type?: 'highlight' | 'zoom' | 'filter' | 'navigate';
|
|
456
|
+
label?: string;
|
|
457
|
+
action?: string;
|
|
458
|
+
layerId?: number;
|
|
459
|
+
featureId?: number | string;
|
|
460
|
+
filter?: {
|
|
461
|
+
property: string;
|
|
462
|
+
operator: 'equals' | 'contains' | 'gt' | 'lt' | 'in';
|
|
463
|
+
value: string | number | boolean | Array<string | number>;
|
|
464
|
+
};
|
|
465
|
+
bbox?: [number, number, number, number] | {
|
|
466
|
+
minLon: number;
|
|
467
|
+
minLat: number;
|
|
468
|
+
maxLon: number;
|
|
469
|
+
maxLat: number;
|
|
470
|
+
};
|
|
471
|
+
coordinates?: {
|
|
472
|
+
lat: number;
|
|
473
|
+
lon: number;
|
|
474
|
+
};
|
|
475
|
+
payload?: Record<string, unknown>;
|
|
476
|
+
}
|
|
477
|
+
interface ChatResponseDto {
|
|
478
|
+
conversationId: number;
|
|
479
|
+
answer: string;
|
|
480
|
+
metadata?: Record<string, unknown>;
|
|
481
|
+
suggestedActions?: SuggestedAction[];
|
|
482
|
+
relevantFeatures?: Array<Record<string, unknown>>;
|
|
483
|
+
needsMoreInfo?: boolean;
|
|
484
|
+
followUpQuestions?: string[];
|
|
485
|
+
confidence?: number;
|
|
486
|
+
systemMetadata?: Record<string, unknown>;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
interface ChatServiceConfig {
|
|
490
|
+
baseUrl: string;
|
|
491
|
+
accessToken?: string;
|
|
492
|
+
getAccessToken?: () => string | Promise<string>;
|
|
493
|
+
}
|
|
494
|
+
interface ChatRequestOptions {
|
|
495
|
+
baseUrl?: string;
|
|
496
|
+
accessToken?: string;
|
|
497
|
+
getAccessToken?: () => string | Promise<string>;
|
|
498
|
+
signal?: AbortSignal;
|
|
499
|
+
}
|
|
500
|
+
interface ChatStreamCallbacks {
|
|
501
|
+
onChunk?: (chunk: ChatResponseDto, aggregatedText: string) => void;
|
|
502
|
+
onComplete?: (response: ChatResponseDto) => void;
|
|
503
|
+
onError?: (error: unknown) => void;
|
|
504
|
+
}
|
|
505
|
+
declare const sendMessage: (mapId: number, request: ChatRequestDto, options?: ChatRequestOptions, config?: ChatServiceConfig) => Promise<ChatResponseDto>;
|
|
506
|
+
declare const sendMessageStream: (mapId: number, request: ChatRequestDto, callbacks?: ChatStreamCallbacks, options?: ChatRequestOptions, config?: ChatServiceConfig) => Promise<ChatResponseDto>;
|
|
507
|
+
declare const createChatService: (config: ChatServiceConfig) => {
|
|
508
|
+
sendMessage: (mapId: number, request: ChatRequestDto, options?: ChatRequestOptions) => Promise<ChatResponseDto>;
|
|
509
|
+
sendMessageStream: (mapId: number, request: ChatRequestDto, callbacks?: ChatStreamCallbacks, options?: ChatRequestOptions) => Promise<ChatResponseDto>;
|
|
510
|
+
};
|
|
511
|
+
|
|
512
|
+
interface LayerStyle$1 {
|
|
513
|
+
color?: string;
|
|
514
|
+
weight?: number;
|
|
515
|
+
fillColor?: string;
|
|
516
|
+
fillOpacity?: number;
|
|
517
|
+
}
|
|
518
|
+
/**
|
|
519
|
+
* Resuelve el color de acento para una capa basado en su estilo.
|
|
520
|
+
* Prioridad: fillColor → color → null
|
|
521
|
+
*/
|
|
522
|
+
declare function resolveLayerAccent(style?: LayerStyle$1 | null): string | null;
|
|
523
|
+
/**
|
|
524
|
+
* Obtiene el color de acento para una capa, con fallback a un color neutral.
|
|
525
|
+
* @param style - El estilo de la capa
|
|
526
|
+
* @param fallback - Color de fallback (por defecto gris neutral)
|
|
527
|
+
*/
|
|
528
|
+
declare function getLayerColor(style?: LayerStyle$1 | null, fallback?: string): string;
|
|
529
|
+
/**
|
|
530
|
+
* Busca el estilo de una capa en un arreglo de mapLayers por su layerId.
|
|
531
|
+
*/
|
|
532
|
+
declare function getStyleByLayerId(layerId: string | number, mapLayers?: Array<{
|
|
533
|
+
layerId: number | string;
|
|
534
|
+
style?: LayerStyle$1 | null;
|
|
535
|
+
}>): LayerStyle$1 | null;
|
|
536
|
+
/**
|
|
537
|
+
* Obtiene el color de acento de una capa por su layerId.
|
|
538
|
+
*/
|
|
539
|
+
declare function getAccentByLayerId(layerId: string | number, mapLayers?: Array<{
|
|
540
|
+
layerId: number | string;
|
|
541
|
+
style?: LayerStyle$1 | null;
|
|
542
|
+
}>): string | null;
|
|
543
|
+
|
|
544
|
+
interface LayerSnapshot {
|
|
545
|
+
layerId: number | string;
|
|
546
|
+
visible: boolean;
|
|
547
|
+
opacity: number;
|
|
548
|
+
}
|
|
549
|
+
interface ZenitMapRef {
|
|
550
|
+
setLayerOpacity: (layerId: number | string, opacity: number) => void;
|
|
551
|
+
setLayerVisibility: (layerId: number | string, visible: boolean) => void;
|
|
552
|
+
fitBounds: (bbox: Bbox, options?: {
|
|
553
|
+
padding?: [number, number];
|
|
554
|
+
animate?: boolean;
|
|
555
|
+
}) => void;
|
|
556
|
+
setView: (coordinates: {
|
|
557
|
+
lat: number;
|
|
558
|
+
lon: number;
|
|
559
|
+
}, zoom?: number) => void;
|
|
560
|
+
getLayerSnapshot: () => LayerSnapshot[];
|
|
561
|
+
restoreLayerSnapshot: (snapshot: LayerSnapshot[]) => void;
|
|
562
|
+
highlightFeature: (layerId: number | string, featureId?: number | string) => void;
|
|
563
|
+
getMapInstance: () => L.Map | null;
|
|
564
|
+
}
|
|
565
|
+
interface ZenitMapProps {
|
|
566
|
+
client: ZenitClient;
|
|
567
|
+
mapId: number;
|
|
568
|
+
height?: string;
|
|
569
|
+
width?: string;
|
|
570
|
+
initialZoom?: number;
|
|
571
|
+
initialCenter?: [number, number];
|
|
572
|
+
showLayerPanel?: boolean;
|
|
573
|
+
overlayGeojson?: GeoJsonFeatureCollection | null;
|
|
574
|
+
overlayStyle?: PathOptions;
|
|
575
|
+
layerControls?: Array<{
|
|
576
|
+
layerId: number | string;
|
|
577
|
+
visible?: boolean;
|
|
578
|
+
opacity?: number;
|
|
579
|
+
}>;
|
|
580
|
+
layerStates?: EffectiveLayerState[];
|
|
581
|
+
layerGeojson?: Record<string | number, GeoJsonFeatureCollection | null | undefined>;
|
|
582
|
+
onLayerStateChange?: (states: EffectiveLayerState[]) => void;
|
|
583
|
+
onError?: (error: unknown, ctx: 'map') => void;
|
|
584
|
+
onLoadingChange?: (ctx: 'map', loading: boolean) => void;
|
|
585
|
+
onFeatureClick?: (feature: any, layerId?: number | string) => void;
|
|
586
|
+
onFeatureHover?: (feature: any, layerId?: number | string) => void;
|
|
587
|
+
featureInfoMode?: 'popup' | 'none';
|
|
588
|
+
mapLayers?: Array<{
|
|
589
|
+
layerId: number | string;
|
|
590
|
+
style?: LayerStyle$1 | null;
|
|
591
|
+
}>;
|
|
592
|
+
zoomToBbox?: Bbox | null;
|
|
593
|
+
zoomToGeojson?: GeoJsonFeatureCollection | null;
|
|
594
|
+
onZoomChange?: (zoom: number) => void;
|
|
595
|
+
onMapReady?: (map: L.Map) => void;
|
|
596
|
+
}
|
|
597
|
+
declare const ZenitMap: React.ForwardRefExoticComponent<ZenitMapProps & React.RefAttributes<ZenitMapRef>>;
|
|
598
|
+
|
|
599
|
+
interface LayerStyle {
|
|
600
|
+
color?: string;
|
|
601
|
+
weight?: number;
|
|
602
|
+
fillColor?: string;
|
|
603
|
+
fillOpacity?: number;
|
|
604
|
+
}
|
|
605
|
+
interface ZenitLayerManagerProps {
|
|
606
|
+
client: ZenitClient;
|
|
607
|
+
mapId: number | string;
|
|
608
|
+
side?: 'left' | 'right';
|
|
609
|
+
className?: string;
|
|
610
|
+
style?: React.CSSProperties;
|
|
611
|
+
height?: string;
|
|
612
|
+
layerStates?: EffectiveLayerState[];
|
|
613
|
+
onLayerStatesChange?: (states: EffectiveLayerState[]) => void;
|
|
614
|
+
mapZoom?: number;
|
|
615
|
+
autoOpacityOnZoom?: boolean;
|
|
616
|
+
autoOpacityConfig?: {
|
|
617
|
+
minZoom?: number;
|
|
618
|
+
maxZoom?: number;
|
|
619
|
+
minOpacity?: number;
|
|
620
|
+
maxOpacity?: number;
|
|
621
|
+
};
|
|
622
|
+
showUploadTab?: boolean;
|
|
623
|
+
showLayerVisibilityIcon?: boolean;
|
|
624
|
+
layerFeatureCounts?: Record<string | number, number | null | undefined>;
|
|
625
|
+
mapLayers?: Array<{
|
|
626
|
+
layerId: number | string;
|
|
627
|
+
geometryType?: string | null;
|
|
628
|
+
layerType?: string | null;
|
|
629
|
+
name?: string | null;
|
|
630
|
+
style?: LayerStyle | null;
|
|
631
|
+
bboxGeometry?: GeoJsonPolygon | null;
|
|
632
|
+
displayOrder?: number | null;
|
|
633
|
+
}>;
|
|
634
|
+
onZoomToLayer?: (layerId: number | string, bboxGeometry?: GeoJsonPolygon | null) => void;
|
|
635
|
+
}
|
|
636
|
+
declare const ZenitLayerManager: React.FC<ZenitLayerManagerProps>;
|
|
637
|
+
|
|
638
|
+
interface ZenitFeatureFilterPanelProps {
|
|
639
|
+
title?: string;
|
|
640
|
+
description?: string;
|
|
641
|
+
className?: string;
|
|
642
|
+
style?: React.CSSProperties;
|
|
643
|
+
filters?: LayerFilters;
|
|
644
|
+
onChange?: (filters: LayerFilters) => void;
|
|
645
|
+
children?: React.ReactNode;
|
|
646
|
+
}
|
|
647
|
+
declare const ZenitFeatureFilterPanel: React.FC<ZenitFeatureFilterPanelProps>;
|
|
648
|
+
|
|
649
|
+
interface FloatingChatBoxProps {
|
|
650
|
+
mapId?: number;
|
|
651
|
+
filteredLayerIds?: number[];
|
|
652
|
+
filters?: Record<string, unknown>;
|
|
653
|
+
userId?: number | null;
|
|
654
|
+
baseUrl?: string;
|
|
655
|
+
accessToken?: string;
|
|
656
|
+
getAccessToken?: () => string | Promise<string>;
|
|
657
|
+
onActionClick?: (action: SuggestedAction) => void;
|
|
658
|
+
}
|
|
659
|
+
declare const FloatingChatBox: React.FC<FloatingChatBoxProps>;
|
|
660
|
+
|
|
661
|
+
declare const useSendMessage: (config?: ChatServiceConfig) => {
|
|
662
|
+
sendMessage: (mapId: number, request: ChatRequestDto, options?: ChatRequestOptions) => Promise<ChatResponseDto>;
|
|
663
|
+
isLoading: boolean;
|
|
664
|
+
error: unknown;
|
|
665
|
+
};
|
|
666
|
+
declare const useSendMessageStream: (config?: ChatServiceConfig) => {
|
|
667
|
+
sendMessage: (mapId: number, request: ChatRequestDto, options?: ChatRequestOptions) => Promise<ChatResponseDto>;
|
|
668
|
+
isStreaming: boolean;
|
|
669
|
+
streamingText: string;
|
|
670
|
+
completeResponse: ChatResponseDto | null;
|
|
671
|
+
error: unknown;
|
|
672
|
+
reset: () => void;
|
|
673
|
+
};
|
|
674
|
+
|
|
675
|
+
interface ZoomOpacityOptions {
|
|
676
|
+
minZoom?: number;
|
|
677
|
+
maxZoom?: number;
|
|
678
|
+
minFactor?: number;
|
|
679
|
+
maxFactor?: number;
|
|
680
|
+
minOpacity?: number;
|
|
681
|
+
maxOpacity?: number;
|
|
682
|
+
}
|
|
683
|
+
declare function clampNumber(value: number, min: number, max: number): number;
|
|
684
|
+
declare function clampOpacity(value: number): number;
|
|
685
|
+
declare function isPolygonLayer(layerType?: string, geometryType?: string): boolean;
|
|
686
|
+
declare function getZoomOpacityFactor(zoom: number, options?: ZoomOpacityOptions): number;
|
|
687
|
+
declare function getLayerZoomOpacityFactor(zoom: number, layerType?: string, geometryType?: string, options?: ZoomOpacityOptions): number;
|
|
688
|
+
declare function getEffectiveLayerOpacity(baseOpacity: number, zoom: number, layerType?: string, geometryType?: string, options?: ZoomOpacityOptions): number;
|
|
689
|
+
|
|
690
|
+
export { type FilterValue as $, type GeoJsonGeometryCollection as A, type Bbox as B, type LayerDataStrategy as C, DEFAULT_MAX_FEATURES_FULL_GEOJSON as D, type ApiEnvelope as E, type FilterMultipleMetadata as F, type GeoJsonFeature as G, type HttpClientOptions as H, type ApiResponseData as I, type LayerMetadata as J, type GeoJsonBBoxRequest as K, type LayerFilters as L, type MapDto as M, type NormalizedMapLayer as N, type GeoJsonIntersectRequest as O, type LayerAoi as P, type ResolveLayerStrategyParams as Q, type RefreshResponse as R, type SdkTokenValidateResponse as S, type ResolveLayerStrategyResult as T, type UserSummary as U, type ValidateResponse as V, type LoadLayerDataParams as W, type LoadLayerDataResult as X, type LayerFeatureCatalogItem as Y, type ZenitSdkConfig as Z, type LayerFeaturesCatalogDto as _, type GeoJsonFeatureCollection as a, type FilterMultipleLayerMeta as a0, type FilterMultipleWithFallbackResult as a1, type LayerBaseState as a2, type LayerOverrideState as a3, type EffectiveLayerState as a4, initLayerStates as a5, applyLayerOverrides as a6, resetOverrides as a7, type ChatServiceConfig as a8, type ChatRequestOptions as a9, getZoomOpacityFactor as aA, getLayerZoomOpacityFactor as aB, getEffectiveLayerOpacity as aC, type ChatStreamCallbacks as aa, sendMessage as ab, sendMessageStream as ac, createChatService as ad, type ChatRequestDto as ae, type SuggestedAction as af, type ChatResponseDto as ag, ZenitMap as ah, type ZenitMapRef as ai, type LayerSnapshot as aj, type ZenitMapProps as ak, ZenitLayerManager as al, ZenitFeatureFilterPanel as am, FloatingChatBox as an, type FloatingChatBoxProps as ao, useSendMessage as ap, useSendMessageStream as aq, type LayerStyle$1 as ar, resolveLayerAccent as as, getLayerColor as at, getStyleByLayerId as au, getAccentByLayerId as av, type ZoomOpacityOptions as aw, clampNumber as ax, clampOpacity as ay, isPolygonLayer as az, type GeoJsonRequestOptions as b, type GeoJsonPolygon as c, ZenitClient as d, type LoginRequest as e, type LoginResponse as f, type MeResponse as g, ZenitAuthClient as h, type SdkTokenExchangeResponse as i, ZenitSdkAuthClient as j, type ZenitSdkError as k, HttpClient as l, ZenitMapsClient as m, type MapSettings as n, type MapLayerConfig as o, buildLayerFilters as p, buildFilterMultipleParams as q, shouldSkipGeojsonDownload as r, shouldUseFilterMultiple as s, buildAoiFromFeatureCollection as t, resolveLayerStrategy as u, buildLimitedMessage as v, ZenitLayersClient as w, type LayerDto as x, type LayerSummary as y, type GeoJsonPoint as z };
|